From b9b34b70d2d53f83c541ad3e3a55f269e0c76f4e Mon Sep 17 00:00:00 2001 From: phan-ctrl <54398886+phan-ctrl@users.noreply.github.com> Date: Thu, 22 Aug 2019 17:19:55 +0700 Subject: [PATCH 1/4] [safari] Fix authentication Fix issue #22161 --- youtube_dl/extractor/safari.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py index 8d4806794..8c97d1aa2 100644 --- a/youtube_dl/extractor/safari.py +++ b/youtube_dl/extractor/safari.py @@ -71,6 +71,10 @@ class SafariBaseIE(InfoExtractor): # oreilly serves two same groot_sessionid cookies in Set-Cookie header # and expects first one to be actually set self._apply_first_set_cookie_header(urlh, 'groot_sessionid') + # Fix issue #22161 + # We need 2 more cookies to be able to login to oreilly + self._apply_first_set_cookie_header(urlh, 'orm-jwt') + self._apply_first_set_cookie_header(urlh, 'orm-rt') _, urlh = self._download_webpage_handle( auth.get('redirect_uri') or next_uri, None, 'Completing login',) From 18d9939ae3cc7d332d1e6abd55195a5807cdba80 Mon Sep 17 00:00:00 2001 From: phan-ctrl <54398886+phan-ctrl@users.noreply.github.com> Date: Mon, 26 Aug 2019 22:42:28 +0700 Subject: [PATCH 2/4] update fix for safari --- youtube_dl/extractor/safari.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py index 8c97d1aa2..7dc968b9a 100644 --- a/youtube_dl/extractor/safari.py +++ b/youtube_dl/extractor/safari.py @@ -70,11 +70,11 @@ class SafariBaseIE(InfoExtractor): # oreilly serves two same groot_sessionid cookies in Set-Cookie header # and expects first one to be actually set - self._apply_first_set_cookie_header(urlh, 'groot_sessionid') # Fix issue #22161 # We need 2 more cookies to be able to login to oreilly - self._apply_first_set_cookie_header(urlh, 'orm-jwt') - self._apply_first_set_cookie_header(urlh, 'orm-rt') + cookies = ['groot_sessionid', 'orm-jwt', 'orm-rt'] + for cookie in cookies: + self._apply_first_set_cookie_header(urlh, cookie) _, urlh = self._download_webpage_handle( auth.get('redirect_uri') or next_uri, None, 'Completing login',) From 95adb8ece0e7c883c1729cb1155ed5eb67577310 Mon Sep 17 00:00:00 2001 From: phan-ctrl <54398886+phan-ctrl@users.noreply.github.com> Date: Tue, 27 Aug 2019 09:02:23 +0700 Subject: [PATCH 3/4] inline list --- youtube_dl/extractor/safari.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py index 7dc968b9a..7e6322b8e 100644 --- a/youtube_dl/extractor/safari.py +++ b/youtube_dl/extractor/safari.py @@ -72,8 +72,7 @@ class SafariBaseIE(InfoExtractor): # and expects first one to be actually set # Fix issue #22161 # We need 2 more cookies to be able to login to oreilly - cookies = ['groot_sessionid', 'orm-jwt', 'orm-rt'] - for cookie in cookies: + for cookie in ('groot_sessionid', 'orm-jwt', 'orm-rt'): self._apply_first_set_cookie_header(urlh, cookie) _, urlh = self._download_webpage_handle( From e2af6be9a8fb696f0e176dabe749fb38bbbfe73c Mon Sep 17 00:00:00 2001 From: Sergey M Date: Tue, 27 Aug 2019 10:15:29 +0700 Subject: [PATCH 4/4] Update safari.py --- youtube_dl/extractor/safari.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/safari.py b/youtube_dl/extractor/safari.py index 7e6322b8e..bd9ee1647 100644 --- a/youtube_dl/extractor/safari.py +++ b/youtube_dl/extractor/safari.py @@ -68,10 +68,8 @@ class SafariBaseIE(InfoExtractor): raise ExtractorError( 'Unable to login: %s' % credentials, expected=True) - # oreilly serves two same groot_sessionid cookies in Set-Cookie header - # and expects first one to be actually set - # Fix issue #22161 - # We need 2 more cookies to be able to login to oreilly + # oreilly serves two same instances of the following cookies + # in Set-Cookie header and expects first one to be actually set for cookie in ('groot_sessionid', 'orm-jwt', 'orm-rt'): self._apply_first_set_cookie_header(urlh, cookie)