From 0235e627b91ac503f14114a1402363fecbce9de3 Mon Sep 17 00:00:00 2001 From: dirkf Date: Fri, 28 Oct 2022 21:55:44 +0000 Subject: [PATCH] Improve extraction * use User-Agent Mozilla/5.0 * use Referer for manifests and downloads * finalise review comments --- youtube_dl/extractor/platzi.py | 67 +++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/youtube_dl/extractor/platzi.py b/youtube_dl/extractor/platzi.py index 7fef4d1b1..0bf916084 100644 --- a/youtube_dl/extractor/platzi.py +++ b/youtube_dl/extractor/platzi.py @@ -6,9 +6,12 @@ from ..compat import ( compat_str, ) from ..utils import ( + clean_html, ExtractorError, + get_element_by_class, int_or_none, str_or_none, + strip_or_none, try_get, urlencode_postdata, urljoin, @@ -100,38 +103,47 @@ class PlatziIE(PlatziBaseIE): def _real_extract(self, url): lecture_id = self._match_id(url) - webpage = self._download_webpage(url, lecture_id) + headers = {'User-Agent': 'Mozilla/5.0'} + webpage = self._download_webpage(url, lecture_id, headers=headers) data_preloaded_state = self._parse_json( self._search_regex( (r'window\s*.\s*__PRELOADED_STATE__\s*=\s*({.*?});?\s*