From 1df3186e0e2c49993f4230ec77a9de351177b271 Mon Sep 17 00:00:00 2001 From: ngld Date: Wed, 12 Aug 2015 16:01:47 +0200 Subject: [PATCH 01/22] [funnyordie] Handle protocol-relative URLs (fixes #6490) --- youtube_dl/extractor/funnyordie.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/funnyordie.py b/youtube_dl/extractor/funnyordie.py index dd87257c4..f5f13689c 100644 --- a/youtube_dl/extractor/funnyordie.py +++ b/youtube_dl/extractor/funnyordie.py @@ -53,7 +53,7 @@ class FunnyOrDieIE(InfoExtractor): for bitrate in bitrates: for link in links: formats.append({ - 'url': '%s%d.%s' % (link[0], bitrate, link[1]), + 'url': self._proto_relative_url('%s%d.%s' % (link[0], bitrate, link[1])), 'format_id': '%s-%d' % (link[1], bitrate), 'vbr': bitrate, }) From f0f3a6c99d2834ca8af87be4978c0040c3744628 Mon Sep 17 00:00:00 2001 From: ngld Date: Wed, 12 Aug 2015 18:07:27 +0200 Subject: [PATCH 02/22] [rtvnhnl] Added new extractor --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/rtvnhnl.py | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 youtube_dl/extractor/rtvnhnl.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index dad3ec87f..f026a4171 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -491,6 +491,7 @@ from .rtl2 import RTL2IE from .rtp import RTPIE from .rts import RTSIE from .rtve import RTVEALaCartaIE, RTVELiveIE, RTVEInfantilIE +from .rtvnhnl import RtvnhNlIE from .ruhd import RUHDIE from .rutube import ( RutubeIE, diff --git a/youtube_dl/extractor/rtvnhnl.py b/youtube_dl/extractor/rtvnhnl.py new file mode 100644 index 000000000..ce84900a0 --- /dev/null +++ b/youtube_dl/extractor/rtvnhnl.py @@ -0,0 +1,40 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class RtvnhNlIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P[0-9]+)' + _TEST = { + 'params': { + 'hls_prefer_native': True + }, + + 'url': 'http://www.rtvnh.nl/video/131946', + 'md5': '6e1d0ab079e2a00b6161442d3ceacfc1', + 'info_dict': { + 'id': '131946', + 'ext': 'mp4', + 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw', + 'thumbnail': 're:^https?://rtvnh-webfiles\.[^.]+\.amazonaws\.com/data/cache/[0-9]+/basedata/pf_image/[0-9.]+/[0-9\-a-f]+\.jpg$' + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + meta = self._parse_json(self._download_webpage('http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) + formats = self._extract_smil_formats('http://www.rtvnh.nl/video/smil?m=' + video_id, video_id) + + for item in meta['source']['fb']: + if item.get('type') == 'hls': + formats.extend(self._extract_m3u8_formats(item['file'], video_id, ext='mp4')) + elif item.get('type') == '': + formats.append({'url': item['file']}) + + return { + 'id': video_id, + 'title': meta['title'].strip(), + 'thumbnail': meta['image'], + 'formats': formats + } From fb124e37419668c34b4056575614776b0c64b401 Mon Sep 17 00:00:00 2001 From: ngld Date: Wed, 12 Aug 2015 20:21:32 +0200 Subject: [PATCH 03/22] [rtvnhnl] Relax the thumbnail check --- youtube_dl/extractor/rtvnhnl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtvnhnl.py b/youtube_dl/extractor/rtvnhnl.py index ce84900a0..0921e2648 100644 --- a/youtube_dl/extractor/rtvnhnl.py +++ b/youtube_dl/extractor/rtvnhnl.py @@ -17,7 +17,7 @@ class RtvnhNlIE(InfoExtractor): 'id': '131946', 'ext': 'mp4', 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw', - 'thumbnail': 're:^https?://rtvnh-webfiles\.[^.]+\.amazonaws\.com/data/cache/[0-9]+/basedata/pf_image/[0-9.]+/[0-9\-a-f]+\.jpg$' + 'thumbnail': 're:^http:.*\.jpg$' } } From d9ab5262b137962995af1b444f45f7f32dc33a77 Mon Sep 17 00:00:00 2001 From: ngld Date: Wed, 12 Aug 2015 20:26:13 +0200 Subject: [PATCH 04/22] [rtvnh] Renamed rtvnhnl -> rtvnh --- youtube_dl/extractor/__init__.py | 2 +- youtube_dl/extractor/{rtvnhnl.py => rtvnh.py} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename youtube_dl/extractor/{rtvnhnl.py => rtvnh.py} (94%) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index f026a4171..9a6308723 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -491,7 +491,7 @@ from .rtl2 import RTL2IE from .rtp import RTPIE from .rts import RTSIE from .rtve import RTVEALaCartaIE, RTVELiveIE, RTVEInfantilIE -from .rtvnhnl import RtvnhNlIE +from .rtvnh import RTVNHIE from .ruhd import RUHDIE from .rutube import ( RutubeIE, diff --git a/youtube_dl/extractor/rtvnhnl.py b/youtube_dl/extractor/rtvnh.py similarity index 94% rename from youtube_dl/extractor/rtvnhnl.py rename to youtube_dl/extractor/rtvnh.py index 0921e2648..f5c0b94a8 100644 --- a/youtube_dl/extractor/rtvnhnl.py +++ b/youtube_dl/extractor/rtvnh.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals from .common import InfoExtractor -class RtvnhNlIE(InfoExtractor): +class RTVNHIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P[0-9]+)' _TEST = { 'params': { @@ -17,7 +17,7 @@ class RtvnhNlIE(InfoExtractor): 'id': '131946', 'ext': 'mp4', 'title': 'Grote zoektocht in zee bij Zandvoort naar vermiste vrouw', - 'thumbnail': 're:^http:.*\.jpg$' + 'thumbnail': 're:^https?:.*\.jpg$' } } From d7dbfc7cc18c2d54d7e1752def6c4710c58b49fc Mon Sep 17 00:00:00 2001 From: ngld Date: Wed, 12 Aug 2015 20:51:28 +0200 Subject: [PATCH 05/22] Use native HLS implementation by default. --- youtube_dl/extractor/rtvnh.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/youtube_dl/extractor/rtvnh.py b/youtube_dl/extractor/rtvnh.py index f5c0b94a8..2799f01a6 100644 --- a/youtube_dl/extractor/rtvnh.py +++ b/youtube_dl/extractor/rtvnh.py @@ -7,10 +7,6 @@ from .common import InfoExtractor class RTVNHIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?rtvnh\.nl/video/(?P[0-9]+)' _TEST = { - 'params': { - 'hls_prefer_native': True - }, - 'url': 'http://www.rtvnh.nl/video/131946', 'md5': '6e1d0ab079e2a00b6161442d3ceacfc1', 'info_dict': { @@ -28,7 +24,7 @@ class RTVNHIE(InfoExtractor): for item in meta['source']['fb']: if item.get('type') == 'hls': - formats.extend(self._extract_m3u8_formats(item['file'], video_id, ext='mp4')) + formats.extend(self._extract_m3u8_formats(item['file'], video_id, ext='mp4', entry_protocol='m3u8_native')) elif item.get('type') == '': formats.append({'url': item['file']}) From 240ca32e57a027ff8cec8617c154bb7100bead1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:00:05 +0600 Subject: [PATCH 06/22] [rtvnh] Carry long lines --- youtube_dl/extractor/rtvnh.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/rtvnh.py b/youtube_dl/extractor/rtvnh.py index 2799f01a6..998a3c53d 100644 --- a/youtube_dl/extractor/rtvnh.py +++ b/youtube_dl/extractor/rtvnh.py @@ -19,12 +19,16 @@ class RTVNHIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - meta = self._parse_json(self._download_webpage('http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) - formats = self._extract_smil_formats('http://www.rtvnh.nl/video/smil?m=' + video_id, video_id) + + meta = self._parse_json(self._download_webpage( + 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) + formats = self._extract_smil_formats( + 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id) for item in meta['source']['fb']: if item.get('type') == 'hls': - formats.extend(self._extract_m3u8_formats(item['file'], video_id, ext='mp4', entry_protocol='m3u8_native')) + formats.extend(self._extract_m3u8_formats( + item['file'], video_id, ext='mp4', entry_protocol='m3u8_native')) elif item.get('type') == '': formats.append({'url': item['file']}) From f196047832a2da74d5adf75759877b5d95ec5b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:00:25 +0600 Subject: [PATCH 07/22] [rtvnh] Make thumbnail optional --- youtube_dl/extractor/rtvnh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtvnh.py b/youtube_dl/extractor/rtvnh.py index 998a3c53d..d576a3410 100644 --- a/youtube_dl/extractor/rtvnh.py +++ b/youtube_dl/extractor/rtvnh.py @@ -35,6 +35,6 @@ class RTVNHIE(InfoExtractor): return { 'id': video_id, 'title': meta['title'].strip(), - 'thumbnail': meta['image'], + 'thumbnail': meta.get('image'), 'formats': formats } From 60231c65b9a50e08967d748c3ed401488fed3587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:02:50 +0600 Subject: [PATCH 08/22] [rtvnh] Make SMIL not fatal --- youtube_dl/extractor/rtvnh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtvnh.py b/youtube_dl/extractor/rtvnh.py index d576a3410..202ea0181 100644 --- a/youtube_dl/extractor/rtvnh.py +++ b/youtube_dl/extractor/rtvnh.py @@ -23,7 +23,7 @@ class RTVNHIE(InfoExtractor): meta = self._parse_json(self._download_webpage( 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) formats = self._extract_smil_formats( - 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id) + 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id, fatal=False) for item in meta['source']['fb']: if item.get('type') == 'hls': From 2c919adb74893544ab6def1d56ff8ed37c282ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:11:55 +0600 Subject: [PATCH 09/22] [rtvnh] Check status code --- youtube_dl/extractor/rtvnh.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/rtvnh.py b/youtube_dl/extractor/rtvnh.py index 202ea0181..7c9d4b0cd 100644 --- a/youtube_dl/extractor/rtvnh.py +++ b/youtube_dl/extractor/rtvnh.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from .common import InfoExtractor +from ..utils import ExtractorError class RTVNHIE(InfoExtractor): @@ -22,6 +23,12 @@ class RTVNHIE(InfoExtractor): meta = self._parse_json(self._download_webpage( 'http://www.rtvnh.nl/video/json?m=' + video_id, video_id), video_id) + + status = meta.get('status') + if status != 200: + raise ExtractorError( + '%s returned error code %d' % (self.IE_NAME, status), expected=True) + formats = self._extract_smil_formats( 'http://www.rtvnh.nl/video/smil?m=' + video_id, video_id, fatal=False) @@ -31,7 +38,7 @@ class RTVNHIE(InfoExtractor): item['file'], video_id, ext='mp4', entry_protocol='m3u8_native')) elif item.get('type') == '': formats.append({'url': item['file']}) - + return { 'id': video_id, 'title': meta['title'].strip(), From 3b7130439aade87b628fa6dd727df5860323a68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:15:58 +0600 Subject: [PATCH 10/22] Credit @ngld for RTVNH (#6537) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index d16d34272..71c420165 100644 --- a/AUTHORS +++ b/AUTHORS @@ -137,3 +137,4 @@ Zach Bruggeman Tjark Saul slangangular Behrouz Abbasi +ngld From b6b2711298f8d43414deac939f92c7c3477826b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:17:15 +0600 Subject: [PATCH 11/22] [tweakers] Remove unused imports --- youtube_dl/extractor/tweakers.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/youtube_dl/extractor/tweakers.py b/youtube_dl/extractor/tweakers.py index 6eeffb1cc..f3198fb85 100644 --- a/youtube_dl/extractor/tweakers.py +++ b/youtube_dl/extractor/tweakers.py @@ -1,12 +1,6 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import ( - xpath_text, - xpath_with_ns, - int_or_none, - float_or_none, -) class TweakersIE(InfoExtractor): From e73c85cb23d278702357412479fd4b162a3abbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:18:49 +0600 Subject: [PATCH 12/22] [iqiyi] PEP 8 --- youtube_dl/extractor/iqiyi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/iqiyi.py b/youtube_dl/extractor/iqiyi.py index dfc6d58a0..393e67e35 100644 --- a/youtube_dl/extractor/iqiyi.py +++ b/youtube_dl/extractor/iqiyi.py @@ -201,7 +201,7 @@ class IqiyiIE(InfoExtractor): return raw_data def get_enc_key(self, swf_url, video_id): - enc_key = '3601ba290e4f4662848c710e2122007e' # last update at 2015-08-10 for Zombie + enc_key = '3601ba290e4f4662848c710e2122007e' # last update at 2015-08-10 for Zombie return enc_key def _real_extract(self, url): From 237c03c8eaa4da1713a635e87f98ac14430b35cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 01:19:23 +0600 Subject: [PATCH 13/22] [dhm] Remove unused import --- youtube_dl/extractor/dhm.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/youtube_dl/extractor/dhm.py b/youtube_dl/extractor/dhm.py index 127eb0439..44e0c5d4d 100644 --- a/youtube_dl/extractor/dhm.py +++ b/youtube_dl/extractor/dhm.py @@ -1,10 +1,7 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import ( - xpath_text, - parse_duration, -) +from ..utils import parse_duration class DHMIE(InfoExtractor): From 28479149ccf3425e6a6e35d3a155f6802629728a Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Thu, 13 Aug 2015 12:56:12 +0800 Subject: [PATCH 14/22] [theplatform] Fallback to hardcoded releaseUrl if not available Fixes #6546. Not adding a test case as test_NBC has the same problem. --- youtube_dl/extractor/theplatform.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/theplatform.py b/youtube_dl/extractor/theplatform.py index 83d833e30..0643eccaf 100644 --- a/youtube_dl/extractor/theplatform.py +++ b/youtube_dl/extractor/theplatform.py @@ -108,7 +108,11 @@ class ThePlatformIE(InfoExtractor): config_url = config_url.replace('swf/', 'config/') config_url = config_url.replace('onsite/', 'onsite/config/') config = self._download_json(config_url, video_id, 'Downloading config') - smil_url = config['releaseUrl'] + '&format=SMIL&formats=MPEG4&manifest=f4m' + if 'releaseUrl' in config: + release_url = config['releaseUrl'] + else: + release_url = 'http://link.theplatform.com/s/%s?mbr=true' % path + smil_url = release_url + '&format=SMIL&formats=MPEG4&manifest=f4m' else: smil_url = 'http://link.theplatform.com/s/%s/meta.smil?format=smil&mbr=true' % path From 6828c809e44fca7b19da3c62a11cea313a86b64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 21:07:14 +0600 Subject: [PATCH 15/22] [downloader/fragment] Respect --retries for fragment based downloaders (Closes #6549) --- youtube_dl/downloader/fragment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/downloader/fragment.py b/youtube_dl/downloader/fragment.py index 5f9d6796d..5a64b29ee 100644 --- a/youtube_dl/downloader/fragment.py +++ b/youtube_dl/downloader/fragment.py @@ -35,6 +35,7 @@ class FragmentFD(FileDownloader): 'quiet': True, 'noprogress': True, 'ratelimit': self.params.get('ratelimit', None), + 'retries': self.params.get('retries', 0), 'test': self.params.get('test', False), } ) From 7393746da213bec686f8425165854e5e383b7eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 21:10:11 +0600 Subject: [PATCH 16/22] [downloader/hls] Add _debug_cmd --- youtube_dl/downloader/hls.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/youtube_dl/downloader/hls.py b/youtube_dl/downloader/hls.py index 60dca0ab1..2b6c3370f 100644 --- a/youtube_dl/downloader/hls.py +++ b/youtube_dl/downloader/hls.py @@ -32,6 +32,8 @@ class HlsFD(FileDownloader): for opt in (ffpp.executable, '-y', '-i', url, '-f', 'mp4', '-c', 'copy', '-bsf:a', 'aac_adtstoasc')] args.append(encodeFilename(tmpfilename, True)) + self._debug_cmd(args) + retval = subprocess.call(args) if retval == 0: fsize = os.path.getsize(encodeFilename(tmpfilename)) From cb28e0338665c96b2d5b35d203b1d54a57f3feb1 Mon Sep 17 00:00:00 2001 From: nyuszika7h Date: Mon, 10 Aug 2015 19:27:16 +0200 Subject: [PATCH 17/22] [indavideo] Add new extractor Closes #2147. --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/indavideo.py | 79 +++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 youtube_dl/extractor/indavideo.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 9a6308723..3bcfa93bb 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -242,6 +242,7 @@ from .imdb import ( ) from .imgur import ImgurIE from .ina import InaIE +from .indavideo import IndavideoIE from .infoq import InfoQIE from .instagram import InstagramIE, InstagramUserIE from .internetvideoarchive import InternetVideoArchiveIE diff --git a/youtube_dl/extractor/indavideo.py b/youtube_dl/extractor/indavideo.py new file mode 100644 index 000000000..2a2cf2bd3 --- /dev/null +++ b/youtube_dl/extractor/indavideo.py @@ -0,0 +1,79 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .. import utils +from .common import InfoExtractor + + +class IndavideoIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P.+)' + _TESTS = [ + { + 'url': 'http://indavideo.hu/video/Cicatanc', + 'md5': 'c8a507a1c7410685f83a06eaeeaafeab', + 'info_dict': { + 'id': '1837039', + 'title': 'Cicatánc', + 'ext': 'mp4', + 'display_id': 'Cicatanc', + 'thumbnail': 're:^https?://.*\.jpg$', + 'description': '', + 'uploader': 'cukiajanlo', + 'uploader_id': '83729', + 'duration': 72, + 'age_limit': 0, + 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'] + }, + }, + { + 'url': 'http://indavideo.hu/video/Vicces_cica_1', + 'md5': '8c82244ba85d2a2310275b318eb51eac', + 'info_dict': { + 'id': '1335611', + 'title': 'Vicces cica', + 'ext': 'mp4', + 'display_id': 'Vicces_cica_1', + 'thumbnail': 're:^https?://.*\.jpg$', + 'description': 'Játszik a tablettel. :D', + 'uploader': 'Jet_Pack', + 'uploader_id': '491217', + 'duration': 7, + 'age_limit': 0, + 'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'], + }, + }, + ] + + def _real_extract(self, url): + video_disp_id = self._match_id(url) + webpage = self._download_webpage(url, video_disp_id) + + embed_url = self._html_search_regex(r'', webpage, 'embed_url') + video_hash = embed_url.split('/')[-1] + + payload = self._download_json('http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/' + video_hash, video_disp_id) + video_info = payload['data'] + + thumbnails = video_info.get('thumbnails') + if thumbnails: + thumbnails = [{'url': self._proto_relative_url(x)} for x in thumbnails] + + tags = video_info.get('tags') + if tags: + tags = [x['title'] for x in tags] + + return { + 'id': video_info.get('id'), + 'title': video_info['title'], + 'url': video_info['video_file'], + 'ext': 'mp4', + 'display_id': video_disp_id, + 'thumbnails': thumbnails, + 'description': video_info.get('description'), + 'uploader': video_info.get('user_name'), + # TODO: upload date (it's in CET/CEST) + 'uploader_id': video_info.get('user_id'), + 'duration': utils.int_or_none(video_info.get('length')), + 'age_limit': utils.int_or_none(video_info.get('age_limit')), + 'tags': tags, + } From 3c12a027d48a2d6d1162ab515df0308237aef881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 23:25:47 +0600 Subject: [PATCH 18/22] [indavideo] Split in two extractors, extract all formats and fix timestamp --- youtube_dl/extractor/__init__.py | 5 +- youtube_dl/extractor/indavideo.py | 178 +++++++++++++++++++----------- 2 files changed, 118 insertions(+), 65 deletions(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 3bcfa93bb..83d21bd15 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -242,7 +242,10 @@ from .imdb import ( ) from .imgur import ImgurIE from .ina import InaIE -from .indavideo import IndavideoIE +from .indavideo import ( + IndavideoIE, + IndavideoEmbedIE, +) from .infoq import InfoQIE from .instagram import InstagramIE, InstagramUserIE from .internetvideoarchive import InternetVideoArchiveIE diff --git a/youtube_dl/extractor/indavideo.py b/youtube_dl/extractor/indavideo.py index 2a2cf2bd3..b75715244 100644 --- a/youtube_dl/extractor/indavideo.py +++ b/youtube_dl/extractor/indavideo.py @@ -3,77 +3,127 @@ from __future__ import unicode_literals from .. import utils from .common import InfoExtractor +from ..utils import ( + int_or_none, + parse_age_limit, + parse_iso8601, +) + + +class IndavideoEmbedIE(InfoExtractor): + _VALID_URL = r'https?://(?:(?:embed\.)?indavideo\.hu/player/video/|assets\.indavideo\.hu/swf/player\.swf\?.*\b(?:v(?:ID|id))=)(?P[\da-f]+)' + _TESTS = [{ + 'url': 'http://indavideo.hu/player/video/1bdc3c6d80/', + 'md5': 'f79b009c66194acacd40712a6778acfa', + 'info_dict': { + 'id': '1837039', + 'ext': 'mp4', + 'title': 'Cicatánc', + 'description': '', + 'thumbnail': 're:^https?://.*\.jpg$', + 'uploader': 'cukiajanlo', + 'uploader_id': '83729', + 'timestamp': 1439193826, + 'upload_date': '20150810', + 'duration': 72, + 'age_limit': 0, + 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'], + }, + }, { + 'url': 'http://embed.indavideo.hu/player/video/1bdc3c6d80?autostart=1&hide=1', + 'only_matching': True, + }, { + 'url': 'http://assets.indavideo.hu/swf/player.swf?v=fe25e500&vID=1bdc3c6d80&autostart=1&hide=1&i=1', + 'only_matching': True, + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + + video = self._download_json( + 'http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/%s' % video_id, + video_id)['data'] + + video_id = video['id'] + title = video['title'] + + video_urls = video.get('video_files', []) + video_file = video.get('video_file') + if video: + video_urls.append(video_file) + video_urls = list(set(video_urls)) + + video_prefix = video_urls[0].rsplit('/', 1)[0] + + for flv_file in video.get('flv_files', []): + flv_url = '%s/%s' % (video_prefix, flv_file) + if flv_url not in video_urls: + video_urls.append(flv_url) + + formats = [{ + 'url': video_url, + 'height': self._search_regex(r'\.(\d{3,4})\.mp4$', video_url, 'height', default=None), + } for video_url in video_urls] + self._sort_formats(formats) + + timestamp = video.get('date') + if timestamp: + # upload date is in CEST + timestamp = parse_iso8601(timestamp + ' +0200', ' ') + + thumbnails = [{ + 'url': self._proto_relative_url(thumbnail) + } for thumbnail in video.get('thumbnails', [])] + + tags = [tag['title'] for tag in video.get('tags', [])] + + return { + 'id': video_id, + 'title': title, + 'description': video.get('description'), + 'thumbnails': thumbnails, + 'uploader': video.get('user_name'), + 'uploader_id': video.get('user_id'), + 'timestamp': timestamp, + 'duration': int_or_none(video.get('length')), + 'age_limit': parse_age_limit(video.get('age_limit')), + 'tags': tags, + 'formats': formats, + } class IndavideoIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P.+)' - _TESTS = [ - { - 'url': 'http://indavideo.hu/video/Cicatanc', - 'md5': 'c8a507a1c7410685f83a06eaeeaafeab', - 'info_dict': { - 'id': '1837039', - 'title': 'Cicatánc', - 'ext': 'mp4', - 'display_id': 'Cicatanc', - 'thumbnail': 're:^https?://.*\.jpg$', - 'description': '', - 'uploader': 'cukiajanlo', - 'uploader_id': '83729', - 'duration': 72, - 'age_limit': 0, - 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'] - }, + _VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P[^/#?]+)' + _TEST = { + 'url': 'http://indavideo.hu/video/Vicces_cica_1', + 'md5': '8c82244ba85d2a2310275b318eb51eac', + 'info_dict': { + 'id': '1335611', + 'display_id': 'Vicces_cica_1', + 'ext': 'mp4', + 'title': 'Vicces cica', + 'description': 'Játszik a tablettel. :D', + 'thumbnail': 're:^https?://.*\.jpg$', + 'uploader': 'Jet_Pack', + 'uploader_id': '491217', + 'timestamp': 1390821212, + 'upload_date': '20140127', + 'duration': 7, + 'age_limit': 0, + 'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'], }, - { - 'url': 'http://indavideo.hu/video/Vicces_cica_1', - 'md5': '8c82244ba85d2a2310275b318eb51eac', - 'info_dict': { - 'id': '1335611', - 'title': 'Vicces cica', - 'ext': 'mp4', - 'display_id': 'Vicces_cica_1', - 'thumbnail': 're:^https?://.*\.jpg$', - 'description': 'Játszik a tablettel. :D', - 'uploader': 'Jet_Pack', - 'uploader_id': '491217', - 'duration': 7, - 'age_limit': 0, - 'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'], - }, - }, - ] + } def _real_extract(self, url): - video_disp_id = self._match_id(url) - webpage = self._download_webpage(url, video_disp_id) + display_id = self._match_id(url) - embed_url = self._html_search_regex(r'', webpage, 'embed_url') - video_hash = embed_url.split('/')[-1] - - payload = self._download_json('http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/' + video_hash, video_disp_id) - video_info = payload['data'] - - thumbnails = video_info.get('thumbnails') - if thumbnails: - thumbnails = [{'url': self._proto_relative_url(x)} for x in thumbnails] - - tags = video_info.get('tags') - if tags: - tags = [x['title'] for x in tags] + webpage = self._download_webpage(url, display_id) + embed_url = self._search_regex( + r']+rel="video_src"[^>]+href="(.+?)"', webpage, 'embed url') return { - 'id': video_info.get('id'), - 'title': video_info['title'], - 'url': video_info['video_file'], - 'ext': 'mp4', - 'display_id': video_disp_id, - 'thumbnails': thumbnails, - 'description': video_info.get('description'), - 'uploader': video_info.get('user_name'), - # TODO: upload date (it's in CET/CEST) - 'uploader_id': video_info.get('user_id'), - 'duration': utils.int_or_none(video_info.get('length')), - 'age_limit': utils.int_or_none(video_info.get('age_limit')), - 'tags': tags, + '_type': 'url_transparent', + 'ie_key': 'IndavideoEmbed', + 'url': embed_url, + 'display_id': display_id, } From a34e19629c407a08cd9065223f26f1f5468a4423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 23:40:20 +0600 Subject: [PATCH 19/22] [indavideo] Relax _VALID_URL to match subdomains and add tests --- youtube_dl/extractor/indavideo.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/indavideo.py b/youtube_dl/extractor/indavideo.py index b75715244..550a7001b 100644 --- a/youtube_dl/extractor/indavideo.py +++ b/youtube_dl/extractor/indavideo.py @@ -44,7 +44,6 @@ class IndavideoEmbedIE(InfoExtractor): 'http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/%s' % video_id, video_id)['data'] - video_id = video['id'] title = video['title'] video_urls = video.get('video_files', []) @@ -78,7 +77,7 @@ class IndavideoEmbedIE(InfoExtractor): tags = [tag['title'] for tag in video.get('tags', [])] return { - 'id': video_id, + 'id': video.get('id') or video_id, 'title': title, 'description': video.get('description'), 'thumbnails': thumbnails, @@ -93,8 +92,8 @@ class IndavideoEmbedIE(InfoExtractor): class IndavideoIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P[^/#?]+)' - _TEST = { + _VALID_URL = r'https?://(?:.+?\.)?indavideo\.hu/video/(?P[^/#?]+)' + _TESTS = [{ 'url': 'http://indavideo.hu/video/Vicces_cica_1', 'md5': '8c82244ba85d2a2310275b318eb51eac', 'info_dict': { @@ -112,7 +111,22 @@ class IndavideoIE(InfoExtractor): 'age_limit': 0, 'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'], }, - } + }, { + 'url': 'http://index.indavideo.hu/video/2015_0728_beregszasz', + 'only_matching': True, + }, { + 'url': 'http://auto.indavideo.hu/video/Sajat_utanfutoban_a_kis_tacsko', + 'only_matching': True, + }, { + 'url': 'http://erotika.indavideo.hu/video/Amator_tini_punci', + 'only_matching': True, + }, { + 'url': 'http://film.indavideo.hu/video/f_hrom_nagymamm_volt', + 'only_matching': True, + }, { + 'url': 'http://palyazat.indavideo.hu/video/Embertelen_dal_Dodgem_egyuttes', + 'only_matching': True, + }] def _real_extract(self, url): display_id = self._match_id(url) From fb56131dd9cf3bfa31d7d6920a135281d151f803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 23:47:12 +0600 Subject: [PATCH 20/22] Credit @nyuszika7h for indavideo (#6517) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 71c420165..ded9e87d2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -138,3 +138,4 @@ Tjark Saul slangangular Behrouz Abbasi ngld +nyuszika7h From 594f51b85934878ff20b608f312d7f564e3a3d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Thu, 13 Aug 2015 23:47:49 +0600 Subject: [PATCH 21/22] [indavideo] Remove unused import --- youtube_dl/extractor/indavideo.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/indavideo.py b/youtube_dl/extractor/indavideo.py index 550a7001b..12fb5e8e1 100644 --- a/youtube_dl/extractor/indavideo.py +++ b/youtube_dl/extractor/indavideo.py @@ -1,7 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -from .. import utils from .common import InfoExtractor from ..utils import ( int_or_none, From 4d2ad866f347086d3a1cf4cb7e0a8cadd3c87748 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Fri, 14 Aug 2015 19:18:03 +0800 Subject: [PATCH 22/22] [README.md] Document format_id field in output template section (#6557) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 15baf75ce..8fa402ee2 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,7 @@ The `-o` option allows users to indicate a template for the output file names. T - `autonumber`: The sequence will be replaced by a five-digit number that will be increased with each download, starting at zero. - `playlist`: The name or the id of the playlist that contains the video. - `playlist_index`: The index of the video in the playlist, a five-digit number. + - `format_id`: The sequence will be replaced by the format code specified by `--format`. The current default template is `%(title)s-%(id)s.%(ext)s`.