From 48b2c5bd8a83df4b7d415e777bb90d80ccbe2bed Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 15 Aug 2017 16:24:57 +1200 Subject: [PATCH 1/4] Add extractor for NZOnScreen --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/nzonscreen.py | 77 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 youtube_dl/extractor/nzonscreen.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index fb79a1736..a8dbb6e95 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -740,6 +740,7 @@ from .nytimes import ( NYTimesArticleIE, ) from .nuvid import NuvidIE +from .nzonscreen import NZOnScreenIE from .nzz import NZZIE from .odatv import OdaTVIE from .odnoklassniki import OdnoklassnikiIE diff --git a/youtube_dl/extractor/nzonscreen.py b/youtube_dl/extractor/nzonscreen.py new file mode 100644 index 000000000..d11bf9de4 --- /dev/null +++ b/youtube_dl/extractor/nzonscreen.py @@ -0,0 +1,77 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re +import json + +from .common import InfoExtractor +from ..utils import ( + extract_attributes, +) + +class NZOnScreenIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?nzonscreen\.com/title/(?P[^/]+)' + _TEST = { + 'url': 'https://www.nzonscreen.com/title/watermark-2001', + 'md5': '7743cb2c319c27357bc75dd8bcde5d11', + 'info_dict': { + 'id': 'watermark-2001', + 'ext': 'm4v', + 'title': 'Watermark', + 'description': 'md5:c654662c3985fb0cef75812fbb378174', + #'thumbnail': r're:^https?://.*\.jpg$', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + # TODO more code goes here, for example ... + title = self._html_search_regex(r'

(.+?)

', + webpage, 'title') + main_clip = self._html_search_regex(r'data-video-config=\'(.+?)\'', + webpage, 'source') + main_clip = json.loads(main_clip) + + clips = self._html_search_regex(r'
]+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), + # TODO more properties (see youtube_dl/extractor/common.py) + } \ No newline at end of file From 32b2b4a70c01c86e25b342bd106ee00acd36e060 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 15 Aug 2017 16:25:21 +1200 Subject: [PATCH 2/4] Add extractor for NZOnScreen --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/nzonscreen.py | 77 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 youtube_dl/extractor/nzonscreen.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index fb79a1736..a8dbb6e95 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -740,6 +740,7 @@ from .nytimes import ( NYTimesArticleIE, ) from .nuvid import NuvidIE +from .nzonscreen import NZOnScreenIE from .nzz import NZZIE from .odatv import OdaTVIE from .odnoklassniki import OdnoklassnikiIE diff --git a/youtube_dl/extractor/nzonscreen.py b/youtube_dl/extractor/nzonscreen.py new file mode 100644 index 000000000..d11bf9de4 --- /dev/null +++ b/youtube_dl/extractor/nzonscreen.py @@ -0,0 +1,77 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re +import json + +from .common import InfoExtractor +from ..utils import ( + extract_attributes, +) + +class NZOnScreenIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?nzonscreen\.com/title/(?P[^/]+)' + _TEST = { + 'url': 'https://www.nzonscreen.com/title/watermark-2001', + 'md5': '7743cb2c319c27357bc75dd8bcde5d11', + 'info_dict': { + 'id': 'watermark-2001', + 'ext': 'm4v', + 'title': 'Watermark', + 'description': 'md5:c654662c3985fb0cef75812fbb378174', + #'thumbnail': r're:^https?://.*\.jpg$', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + # TODO more code goes here, for example ... + title = self._html_search_regex(r'

(.+?)

', + webpage, 'title') + main_clip = self._html_search_regex(r'data-video-config=\'(.+?)\'', + webpage, 'source') + main_clip = json.loads(main_clip) + + clips = self._html_search_regex(r'
]+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), + # TODO more properties (see youtube_dl/extractor/common.py) + } \ No newline at end of file From 61ac1af174b66e4b7c4ec7aaf9d0c8d40af29ea2 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 15 Aug 2017 16:27:04 +1200 Subject: [PATCH 3/4] Remove crap --- youtube_dl/extractor/nzonscreen.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/youtube_dl/extractor/nzonscreen.py b/youtube_dl/extractor/nzonscreen.py index d11bf9de4..c18d4952e 100644 --- a/youtube_dl/extractor/nzonscreen.py +++ b/youtube_dl/extractor/nzonscreen.py @@ -19,12 +19,6 @@ class NZOnScreenIE(InfoExtractor): 'ext': 'm4v', 'title': 'Watermark', 'description': 'md5:c654662c3985fb0cef75812fbb378174', - #'thumbnail': r're:^https?://.*\.jpg$', - # TODO more properties, either as: - # * A value - # * MD5 checksum; start the string with md5: - # * A regular expression; start the string with re: - # * Any Python type (for example int or float) } } @@ -70,8 +64,4 @@ class NZOnScreenIE(InfoExtractor): 'url': clip[fmt][definition + "_res"], }) - return self.playlist_result(entries, video_id, title, self._og_search_description(webpage)) - return { - #'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), - # TODO more properties (see youtube_dl/extractor/common.py) - } \ No newline at end of file + return self.playlist_result(entries, video_id, title, self._og_search_description(webpage)) \ No newline at end of file From b01862992f282335506f00fccc9b7255544ce57e Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Mon, 4 Sep 2017 10:02:46 +1200 Subject: [PATCH 4/4] Use multi_video instead of playlist --- youtube_dl/extractor/nzonscreen.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/nzonscreen.py b/youtube_dl/extractor/nzonscreen.py index c18d4952e..2ecf184f9 100644 --- a/youtube_dl/extractor/nzonscreen.py +++ b/youtube_dl/extractor/nzonscreen.py @@ -13,12 +13,11 @@ class NZOnScreenIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?nzonscreen\.com/title/(?P[^/]+)' _TEST = { 'url': 'https://www.nzonscreen.com/title/watermark-2001', - 'md5': '7743cb2c319c27357bc75dd8bcde5d11', + 'md5': '9d8885fb0d8aeae80a15e7191e54230a', 'info_dict': { 'id': 'watermark-2001', 'ext': 'm4v', 'title': 'Watermark', - 'description': 'md5:c654662c3985fb0cef75812fbb378174', } } @@ -26,7 +25,6 @@ class NZOnScreenIE(InfoExtractor): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - # TODO more code goes here, for example ... title = self._html_search_regex(r'

(.+?)

', webpage, 'title') main_clip = self._html_search_regex(r'data-video-config=\'(.+?)\'', @@ -34,7 +32,7 @@ class NZOnScreenIE(InfoExtractor): main_clip = json.loads(main_clip) clips = self._html_search_regex(r'