X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fgeneric.py;h=9db27f9aa32730460af728f690ec131014667185;hb=1997eb00784c3e307a228fa64d5a994140520365;hp=cf245d9cde8a5c4a2aefe0b3e196838689e439a5;hpb=77477fa4c916599e7eaa236a3f3eb5703923cf91;p=youtube-dl diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index cf245d9cd..9db27f9aa 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -35,9 +35,10 @@ class GenericIE(InfoExtractor): _TESTS = [ { 'url': 'http://www.hodiho.fr/2013/02/regis-plante-sa-jeep.html', - 'file': '13601338388002.mp4', - 'md5': '6e15c93721d7ec9e9ca3fdbf07982cfd', + 'md5': '85b90ccc9d73b4acd9138d3af4c27f89', 'info_dict': { + 'id': '13601338388002', + 'ext': 'mp4', 'uploader': 'www.hodiho.fr', 'title': 'R\u00e9gis plante sa Jeep', } @@ -46,8 +47,9 @@ class GenericIE(InfoExtractor): { 'add_ie': ['Bandcamp'], 'url': 'http://bronyrock.com/track/the-pony-mash', - 'file': '3235767654.mp3', 'info_dict': { + 'id': '3235767654', + 'ext': 'mp3', 'title': 'The Pony Mash', 'uploader': 'M_Pallante', }, @@ -73,9 +75,10 @@ class GenericIE(InfoExtractor): { # https://github.com/rg3/youtube-dl/issues/2253 'url': 'http://bcove.me/i6nfkrc3', - 'file': '3101154703001.mp4', 'md5': '0ba9446db037002366bab3b3eb30c88c', 'info_dict': { + 'id': '3101154703001', + 'ext': 'mp4', 'title': 'Still no power', 'uploader': 'thestar.com', 'description': 'Mississauga resident David Farmer is still out of power as a result of the ice storm a month ago. To keep the house warm, Farmer cuts wood from his property for a wood burning stove downstairs.', @@ -236,6 +239,56 @@ class GenericIE(InfoExtractor): 'uploader_id': 'rbctv_2012_4', }, }, + # Condé Nast embed + { + 'url': 'http://www.wired.com/2014/04/honda-asimo/', + 'md5': 'ba0dfe966fa007657bd1443ee672db0f', + 'info_dict': { + 'id': '53501be369702d3275860000', + 'ext': 'mp4', + 'title': 'Honda’s New Asimo Robot Is More Human Than Ever', + } + }, + # Dailymotion embed + { + 'url': 'http://www.spi0n.com/zap-spi0n-com-n216/', + 'md5': '441aeeb82eb72c422c7f14ec533999cd', + 'info_dict': { + 'id': 'k2mm4bCdJ6CQ2i7c8o2', + 'ext': 'mp4', + 'title': 'Le Zap de Spi0n n°216 - Zapping du Web', + 'uploader': 'Spi0n', + }, + 'add_ie': ['Dailymotion'], + }, + # YouTube embed + { + 'url': 'http://www.badzine.de/ansicht/datum/2014/06/09/so-funktioniert-die-neue-englische-badminton-liga.html', + 'info_dict': { + 'id': 'FXRb4ykk4S0', + 'ext': 'mp4', + 'title': 'The NBL Auction 2014', + 'uploader': 'BADMINTON England', + 'uploader_id': 'BADMINTONEvents', + 'upload_date': '20140603', + 'description': 'md5:9ef128a69f1e262a700ed83edb163a73', + }, + 'add_ie': ['Youtube'], + 'params': { + 'skip_download': True, + } + }, + # MTVSercices embed + { + 'url': 'http://www.gametrailers.com/news-post/76093/north-america-europe-is-getting-that-mario-kart-8-mercedes-dlc-too', + 'md5': '35727f82f58c76d996fc188f9755b0d5', + 'info_dict': { + 'id': '0306a69b-8adf-4fb5-aace-75f8e8cbfca9', + 'ext': 'mp4', + 'title': 'Review', + 'description': 'Mario\'s life in the fast lane has never looked so good.', + }, + }, ] def report_download_webpage(self, video_id): @@ -320,11 +373,17 @@ class GenericIE(InfoExtractor): } def _real_extract(self, url): + if url.startswith('//'): + return { + '_type': 'url', + 'url': self.http_scheme() + url, + } + parsed_url = compat_urlparse.urlparse(url) if not parsed_url.scheme: default_search = self._downloader.params.get('default_search') if default_search is None: - default_search = 'auto_warning' + default_search = 'error' if default_search in ('auto', 'auto_warning'): if '/' in url: @@ -332,9 +391,19 @@ class GenericIE(InfoExtractor): return self.url_result('http://' + url) else: if default_search == 'auto_warning': - self._downloader.report_warning( - 'Falling back to youtube search for %s . Set --default-search to "auto" to suppress this warning.' % url) + if re.match(r'^(?:url|URL)$', url): + raise ExtractorError( + 'Invalid URL: %r . Call youtube-dl like this: youtube-dl -v "https://www.youtube.com/watch?v=BaW_jenozKc" ' % url, + expected=True) + else: + self._downloader.report_warning( + 'Falling back to youtube search for %s . Set --default-search "auto" to suppress this warning.' % url) return self.url_result('ytsearch:' + url) + elif default_search == 'error': + raise ExtractorError( + ('%r is not a valid URL. ' + 'Set --default-search "ytsearch" (or run youtube-dl "ytsearch:%s" ) to search YouTube' + ) % (url, url), expected=True) else: assert ':' in default_search return self.url_result(default_search + url) @@ -442,8 +511,13 @@ class GenericIE(InfoExtractor): # Look for embedded YouTube player matches = re.findall(r'''(?x) - (?:]+?src=|embedSWF\(\s*) - (["\'])(?P(?:https?:)?//(?:www\.)?youtube\.com/ + (?: + ]+?src=| + ]+?src=| + embedSWF\(?:\s* + ) + (["\']) + (?P(?:https?:)?//(?:www\.)?youtube\.com/ (?:embed|v)/.+?) \1''', webpage) if matches: @@ -456,7 +530,7 @@ class GenericIE(InfoExtractor): matches = re.findall( r']+?src=(["\'])(?P(?:https?:)?//(?:www\.)?dailymotion\.com/embed/video/.+?)\1', webpage) if matches: - urlrs = [self.url_result(unescapeHTML(tuppl[1]), 'Dailymotion') + urlrs = [self.url_result(unescapeHTML(tuppl[1])) for tuppl in matches] return self.playlist_result( urlrs, playlist_id=video_id, playlist_title=video_title) @@ -482,6 +556,22 @@ class GenericIE(InfoExtractor): if mobj: return self.url_result(mobj.group(1), 'BlipTV') + # Look for embedded condenast player + matches = re.findall( + r']*?content="(.*?bandcamp\.com.*?)"', webpage) if mobj is not None: @@ -502,7 +592,7 @@ class GenericIE(InfoExtractor): return OoyalaIE._build_url_result(mobj.group('ec')) # Look for Aparat videos - mobj = re.search(r'