From 836fd554a381aa7862bdf58ff59e7867c9dfc0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vidar=20Flesj=C3=B8?= Date: Sun, 14 Oct 2018 22:56:46 +0200 Subject: [PATCH] Fix Nuvid extractor --- youtube_dl/extractor/nuvid.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/nuvid.py b/youtube_dl/extractor/nuvid.py index ab6bfcd7f..9bb57ca33 100644 --- a/youtube_dl/extractor/nuvid.py +++ b/youtube_dl/extractor/nuvid.py @@ -25,29 +25,25 @@ class NuvidIE(InfoExtractor): 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 = [