Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[svt] fix issue #26428 (SVT play extractor broken) #26438

Closed
wants to merge 1 commit into from
Closed

[svt] fix issue #26428 (SVT play extractor broken) #26438

wants to merge 1 commit into from

Conversation

hakanw
Copy link

@hakanw hakanw commented Aug 25, 2020

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Fix issue #26428 (svt play extractor broken)

@hakanw hakanw changed the title fix issue #26428 fix issue #26428 (SVT play extractor broken) Aug 26, 2020
@hakanw hakanw changed the title fix issue #26428 (SVT play extractor broken) [svt] fix issue #26428 (SVT play extractor broken) Aug 26, 2020
@hakanw
Copy link
Author

hakanw commented Aug 29, 2020

ping @dstftw , can you have a look at this fix which seems to fix all problems with the svt extractor? Thanks!

@@ -225,7 +225,8 @@ def _real_extract(self, url):
return info_dict

svt_id = self._search_regex(
r'<video[^>]+data-video-id=["\']([\da-zA-Z-]+)',
(r'<video[^>]+data-video-id=["\']([\da-zA-Z-]+)',
r'"content":\{"id":"([\da-zA-Z-]+)'),
Copy link
Contributor

@wader wader Aug 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe using the already parsed json is a bit stabler? Something like this:

diff --git a/youtube_dl/extractor/svt.py b/youtube_dl/extractor/svt.py
index e12389cad..d446bc114 100644
--- a/youtube_dl/extractor/svt.py
+++ b/youtube_dl/extractor/svt.py
@@ -224,9 +224,11 @@ class SVTPlayIE(SVTPlayBaseIE):
                 self._adjust_title(info_dict)
                 return info_dict

-        svt_id = self._search_regex(
-            r'<video[^>]+data-video-id=["\']([\da-zA-Z-]+)',
-            webpage, 'video id')
+        svt_id = try_get(data, lambda x: x['statistics']['dataLake']['content']['id'], compat_str)
+        if not svt_id:
+            svt_id = self._search_regex(
+                r'<video[^>]+data-video-id=["\']([\da-zA-Z-]+)',
+                webpage, 'video id')

         return self._extract_by_video_id(svt_id, webpage)

Could possible instead or also use svtId or videoSvtId in the __svtplay_apollo json structure?

@wader
Copy link
Contributor

wader commented Aug 30, 2020

BTW I have some additional fixes unrelated to this in #25184 they will conflict with this change but seems to be quite easy to fix.

@dstftw dstftw closed this in 5ed05f2 Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants