about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2011-09-06 23:56:32 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2011-09-06 23:56:32 +0200
commit9b0a8bc1982a2f10f6e79e9e8fe4a787e4d665e2 (patch)
tree7038982764f5eb58f587f45692cf10eeb04717f6
parente5e74ffb97106949c64000e3d4266d0bbf08cc7c (diff)
downloadyoutube-dl-9b0a8bc1982a2f10f6e79e9e8fe4a787e4d665e2.tar.gz
youtube-dl-9b0a8bc1982a2f10f6e79e9e8fe4a787e4d665e2.tar.xz
youtube-dl-9b0a8bc1982a2f10f6e79e9e8fe4a787e4d665e2.zip
myvideo.de support
-rwxr-xr-xyoutube-dl79
1 files changed, 79 insertions, 0 deletions
diff --git a/youtube-dl b/youtube-dl
index 153d4132f..f32716f1e 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -2954,6 +2954,82 @@ class BlipTVIE(InfoExtractor):
 			self._downloader.trouble(u'\nERROR: unable to download video')
 
 
+class MyVideoIE(InfoExtractor):
+	"""Information Extractor for myvideo.de."""
+
+	_VALID_URL = r'(?:http://)?(?:www\.)?myvideo\.de/watch/([0-9]+)/([^?/]+).*'
+
+	def __init__(self, downloader=None):
+		InfoExtractor.__init__(self, downloader)
+	
+	@staticmethod
+	def suitable(url):
+		return (re.match(MyVideoIE._VALID_URL, url) is not None)
+
+	def report_download_webpage(self, video_id):
+		"""Report webpage download."""
+		self._downloader.to_screen(u'[myvideo] %s: Downloading webpage' % video_id)
+
+	def report_extraction(self, video_id):
+		"""Report information extraction."""
+		self._downloader.to_screen(u'[myvideo] %s: Extracting information' % video_id)
+
+	def _real_initialize(self):
+		return
+
+	def _real_extract(self,url):
+		mobj = re.match(self._VALID_URL, url)
+		if mobj is None:
+			self._download.trouble(u'ERROR: invalid URL: %s' % url)
+			return
+
+		video_id = mobj.group(1)
+		simple_title = mobj.group(2).decode('utf-8')
+		# should actually not be necessary
+		simple_title = sanitize_title(simple_title)
+		simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', simple_title)
+
+		# Get video webpage
+		request = urllib2.Request('http://www.myvideo.de/watch/%s' % video_id)
+		try:
+			self.report_download_webpage(video_id)
+			webpage = urllib2.urlopen(request).read()
+		except (urllib2.URLError, httplib.HTTPException, socket.error), err:
+			self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % str(err))
+			return
+
+		self.report_extraction(video_id)
+		mobj = re.search(r'<link rel=\'image_src\' href=\'(http://is[0-9].myvideo\.de/de/movie[0-9]+/[a-f0-9]+)/thumbs/[^.]+\.jpg\' />',
+				 webpage)
+		if mobj is None:
+			self._downloader.trouble(u'ERROR: unable to extract media URL')
+			return
+		video_url = mobj.group(1) + ('/%s.flv' % video_id)
+
+		mobj = re.search('<title>([^<]+)</title>', webpage)
+		if mobj is None:
+			self._downloader.trouble(u'ERROR: unable to extract title')
+			return
+
+		video_title = mobj.group(1)
+		video_title = sanitize_title(video_title)
+
+		try:
+			print(video_url)
+			self._downloader.process_info({
+				'id':		video_id,
+				'url':		video_url,
+				'uploader':	u'NA',
+				'upload_date':  u'NA',
+				'title':	video_title,
+				'stitle':	simple_title,
+				'ext':		u'flv',
+				'format':	u'NA',
+				'player_url':	None,
+			})
+		except UnavailableVideoError:
+			self._downloader.trouble(u'\nERROR: Unable to download video')
+
 class PostProcessor(object):
 	"""Post Processor class.
 
@@ -3369,6 +3445,8 @@ def main():
 	facebook_ie = FacebookIE()
 	bliptv_ie = BlipTVIE()
 	vimeo_ie = VimeoIE()
+	myvideo_ie = MyVideoIE()
+
 	generic_ie = GenericIE()
 
 	# File downloader
@@ -3425,6 +3503,7 @@ def main():
 	fd.add_info_extractor(facebook_ie)
 	fd.add_info_extractor(bliptv_ie)
 	fd.add_info_extractor(vimeo_ie)
+	fd.add_info_extractor(myvideo_ie)
 
 	# This must come last since it's the
 	# fallback if none of the others work