From d6669a296ff13e87a9b1e3e5d2b4e73f3653a2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vidar=20FLesj=C3=B8?= <31620802+vidaritos@users.noreply.github.com> Date: Thu, 31 May 2018 18:21:30 +0200 Subject: [PATCH 1/2] [Nuvid] Fix extractor (closes #15355) mp4 link is not found in html anymore, but must be fetched using hash-generated values upon page request to a json api. --- youtube_dl/extractor/nuvid.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/youtube_dl/extractor/nuvid.py b/youtube_dl/extractor/nuvid.py index ab6bfcd7f..7133b089f 100644 --- a/youtube_dl/extractor/nuvid.py +++ b/youtube_dl/extractor/nuvid.py @@ -22,32 +22,28 @@ class NuvidIE(InfoExtractor): } } - def _real_extract(self, url): + def _real_extract(self, url): video_id = self._match_id(url) - page_url = 'http://m.nuvid.com/video/%s' % video_id + page_url = 'https://m.nuvid.com/video/%s' % video_id webpage = self._download_webpage( page_url, video_id, 'Downloading video page') - # When dwnld_speed exists and has a value larger than the MP4 file's - # bitrate, Nuvid returns the MP4 URL - # It's unit is 100bytes/millisecond, see mobile-nuvid-min.js for the algorithm - self._set_cookie('nuvid.com', 'dwnld_speed', '10.0') - mp4_webpage = self._download_webpage( - page_url, video_id, 'Downloading video page for MP4 format') - html5_video_re = r'(?s)<(?:video|audio)[^<]*(?:>.*?]*)?\s+src=["\'](.*?)["\']', - video_url = self._html_search_regex(html5_video_re, webpage, video_id) - mp4_video_url = self._html_search_regex(html5_video_re, mp4_webpage, video_id) + video_hash_re = r'(?s)<(?:video|audio).+data-video_hash="(?P[^"]+)[^>]*(?:>)', + hash_time_re = r'(?s)<(?:video|audio).+data-hash_time="(?P[^"]+)[^>]*(?:>)', + video_hash = self._html_search_regex(video_hash_re, webpage, 'video_hash') + hash_time = self._html_search_regex(hash_time_re, webpage, 'hash_time') + + query = {'video_hash': video_hash, 'hash_time': hash_time, 'video_id': video_id} + player_source = self._download_json('https://m.nuvid.com/player_config', video_id, query=query) + mp4_video_url = player_source['source'] + formats = [{ - 'url': video_url, + 'url': mp4_video_url }] - if mp4_video_url != video_url: - formats.append({ - 'url': mp4_video_url, - }) title = self._html_search_regex( - [r'', + [r'
', r'
\s*]*>([^<]+)', r']+class="title_thumb">([^<]+)'], webpage, 'title').strip() thumbnails = [ From b3e5bc6a983f6dcae76db46dcbb4946370878af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vidar=20Flesj=C3=B8?= <31620802+vidaritos@users.noreply.github.com> Date: Thu, 31 May 2018 19:55:11 +0200 Subject: [PATCH 2/2] indent fix due to copy-paste mistake --- youtube_dl/extractor/nuvid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/nuvid.py b/youtube_dl/extractor/nuvid.py index 7133b089f..9bb57ca33 100644 --- a/youtube_dl/extractor/nuvid.py +++ b/youtube_dl/extractor/nuvid.py @@ -22,7 +22,7 @@ class NuvidIE(InfoExtractor): } } - def _real_extract(self, url): + def _real_extract(self, url): video_id = self._match_id(url) page_url = 'https://m.nuvid.com/video/%s' % video_id