From 457f046c3ca82a2123eac2a80518d87287d828ad Mon Sep 17 00:00:00 2001 From: KatDestroyer Date: Fri, 25 Feb 2022 15:56:36 +0100 Subject: [PATCH] Changed to use `_smuggle_referer` Removed `std_headers` import to satisfy flake8 --- youtube_dl/extractor/dropout.py | 9 +++------ youtube_dl/extractor/vimeo.py | 9 ++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/dropout.py b/youtube_dl/extractor/dropout.py index 7630a793d..8db4efcff 100644 --- a/youtube_dl/extractor/dropout.py +++ b/youtube_dl/extractor/dropout.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from .common import InfoExtractor -from .vimeo import VHXEmbedIE +from .vimeo import VHXEmbedIE, VimeoIE from ..utils import ( clean_html, ExtractorError, @@ -11,8 +11,7 @@ from ..utils import ( get_elements_by_class, int_or_none, unified_strdate, - urlencode_postdata, - std_headers + urlencode_postdata ) @@ -139,8 +138,6 @@ class DropoutIE(InfoExtractor): raise ExtractorError('Incorrect username/password') def _real_extract(self, url): - std_headers['Referer'] = 'https://www.dropout.tv' # See issue 2858 - display_id = self._match_id(url) try: logged_in = self._login(display_id) @@ -166,7 +163,7 @@ class DropoutIE(InfoExtractor): return { '_type': 'url_transparent', 'ie_key': VHXEmbedIE.ie_key(), - 'url': embed_url, + 'url': VimeoIE._smuggle_referrer(embed_url, 'https://www.dropout.tv'), 'id': self._search_regex(r'embed.vhx.tv/videos/(.+?)\?', embed_url, 'id'), 'display_id': display_id, 'title': title, diff --git a/youtube_dl/extractor/vimeo.py b/youtube_dl/extractor/vimeo.py index 0b386f450..a77f7c7d4 100644 --- a/youtube_dl/extractor/vimeo.py +++ b/youtube_dl/extractor/vimeo.py @@ -1146,8 +1146,15 @@ class VHXEmbedIE(VimeoBaseInfoExtractor): return unescapeHTML(mobj.group(1)) if mobj else None def _real_extract(self, url): + url, data = unsmuggle_url(url, {}) + headers = std_headers.copy() + if 'http_headers' in data: + headers.update(data['http_headers']) + if 'Referer' not in headers: + headers['Referer'] = url + video_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) + webpage = self._download_webpage(url, video_id, headers=headers) config_url = self._parse_json(self._search_regex( r'window\.OTTData\s*=\s*({.+})', webpage, 'ott data'), video_id, js_to_json)['config_url']