diff options
author | Philipp Hagemeister <[email protected]> | 2014-08-22 18:19:56 +0200 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2014-08-22 18:19:56 +0200 |
commit | ed2d6a19607e965602d66ea90ac716118b739a16 (patch) | |
tree | 6a5317a45224428d088c331573e19d60b1e1b996 | |
parent | be843678b134a76b3509b0ced99dd9fff3867a25 (diff) | |
download | youtube-dl-ed2d6a19607e965602d66ea90ac716118b739a16.tar.gz youtube-dl-ed2d6a19607e965602d66ea90ac716118b739a16.zip |
[generic] Simplify playlist support (#2948)
-rw-r--r-- | youtube_dl/extractor/generic.py | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index 7246ea7fc..2ff691b45 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -16,6 +16,7 @@ from ..utils import ( ExtractorError, HEADRequest, + orderedSet, parse_xml, smuggle_url, unescapeHTML, @@ -292,15 +293,17 @@ class GenericIE(InfoExtractor): # YouTube embed via <data-embed-url=""> { 'url': 'https://play.google.com/store/apps/details?id=com.gameloft.android.ANMP.GloftA8HM', - 'md5': 'c267b1ab6d736057d64babaa37e07a66', 'info_dict': { - 'id': 'Ybd-qmqYYpA', + 'id': 'jpSGZsgga_I', 'ext': 'mp4', - 'title': 'Asphalt 8: Airborne - Chinese Great Wall - Android Game Trailer', - 'uploader': 'gameloftandroid', - 'uploader_id': 'gameloftandroid', - 'upload_date': '20140321', - 'description': 'md5:9c6dca5dd75b7131ce482ccf080749d6' + 'title': 'Asphalt 8: Airborne - Launch Trailer', + 'uploader': 'Gameloft', + 'uploader_id': 'gameloft', + 'upload_date': '20130821', + 'description': 'md5:87bd95f13d8be3e7da87a5f2c443106a', + }, + 'params': { + 'skip_download': True, } } ] @@ -493,6 +496,12 @@ class GenericIE(InfoExtractor): video_uploader = self._search_regex( r'^(?:https?://)?([^/]*)/.*', url, 'video uploader') + # Helper method + def _playlist_from_matches(matches, getter, ie=None): + urlrs = orderedSet(self.url_result(getter(m), ie) for m in matches) + return self.playlist_result( + urlrs, playlist_id=video_id, playlist_title=video_title) + # Look for BrightCove: bc_urls = BrightcoveIE._extract_brightcove_urls(webpage) if bc_urls: @@ -537,35 +546,15 @@ class GenericIE(InfoExtractor): (?:embed|v)/.+?) \1''', webpage) if matches: - urlrs = [self.url_result(unescapeHTML(tuppl[1]), 'Youtube') - for tuppl in matches] - # First, ensure we have a duplicate free list of entries - seen = set() - new_list = [] - theurl = tuple(url.items()) - if theurl not in seen: - seen.add(theurl) - new_list.append(url) - urlrs = new_list - return self.playlist_result( - urlrs, playlist_id=video_id, playlist_title=video_title) + return _playlist_from_matches( + matches, lambda m: unescapeHTML(m[1]), ie='Youtube') # Look for embedded Dailymotion player matches = re.findall( r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/.+?)\1', webpage) if matches: - urlrs = [self.url_result(unescapeHTML(tuppl[1])) - for tuppl in matches] - # First, ensure we have a duplicate free list of entries - seen = set() - new_list = [] - theurl = tuple(url.items()) - if theurl not in seen: - seen.add(theurl) - new_list.append(url) - urlrs = new_list - return self.playlist_result( - urlrs, playlist_id=video_id, playlist_title=video_title) + return _playlist_from_matches( + matches, lambda m: unescapeHTML(m[1])) # Look for embedded Wistia player match = re.search( @@ -679,18 +668,8 @@ class GenericIE(InfoExtractor): # Look for funnyordie embed matches = re.findall(r'<iframe[^>]+?src="(https?://(?:www\.)?funnyordie\.com/embed/[^"]+)"', webpage) if matches: - urlrs = [self.url_result(unescapeHTML(eurl), 'FunnyOrDie') - for eurl in matches] - # First, ensure we have a duplicate free list of entries - seen = set() - new_list = [] - theurl = tuple(url.items()) - if theurl not in seen: - seen.add(theurl) - new_list.append(url) - urlrs = new_list - return self.playlist_result( - urlrs, playlist_id=video_id, playlist_title=video_title) + return _playlist_from_matches( + matches, getter=unescapeHTML, ie='FunnyOrDie') # Look for embedded RUTV player rutv_url = RUTVIE._extract_url(webpage) |