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

[extractor/twitch] Update thumbnail size #6629

Merged
merged 7 commits into from Apr 22, 2023
Merged

Conversation

JC-Chung
Copy link
Contributor

@JC-Chung JC-Chung commented Mar 25, 2023

IMPORTANT: PRs without the template will be CLOSED

Description of your pull request and other information

Currently, using --write-thumbnail when downloading vod will only give you a 90*60 size thumbnail.
like https://www.twitch.tv/videos/1773257171
https://static-cdn.jtvnw.net/cf_vods/d2nvs31859zcd8/3afded6c325c0f62cc4e_dashducks_41995346187_1679578217//thumb/thumb0-90x60.jpg
> https://static-cdn.jtvnw.net/cf_vods/d2nvs31859zcd8/3afded6c325c0f62cc4e_dashducks_41995346187_1679578217//thumb/thumb0-0x0.jpg
Use thumbnail = re.sub(r"(\d+)x(\d+)\.jpg", "0x0.jpg", thumbnail) to replace the thumbnail with size 0*0 (original size?)
And Live even though the highest picture quality is 1920*1080, currently only get 1280*720 thumbnail, using the same code modified to 0*0
like https://www.twitch.tv/dashducks
https://static-cdn.jtvnw.net/previews-ttv/live_user_dashducks-1280x720.jpg
> https://static-cdn.jtvnw.net/previews-ttv/live_user_dashducks-0x0.jpg

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • 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?

🤖 Generated by Copilot at bc2e1f9

Summary

🛠️📺🆗

Refactor twitch.py to use a new method for thumbnail extraction that handles fallbacks better.

We'll haul away the old code, me hearties, haul away
We'll make the thumbnails better, with a fallback today
We'll use the extract_thumbs method, on the count of three
We'll refactor Twitch videos, and live streams, yo ho heave

Walkthrough

  • Add a new method _get_thumbnails to the TwitchBaseIE class that returns a list of two thumbnails with different resolutions for a given URL (link)
  • Replace the thumbnail field with a thumbnails field in the info dictionary of the TwitchVodIE and TwitchStreamIE classes that use the _get_thumbnails method to provide a fallback thumbnail option (link, link)
  • Remove the code that replaced the width and height parameters in the thumbnail URL with zeros in the TwitchVodIE class, as it is no longer needed (link)

@pukkandan
Copy link
Member

Return both as thumbnails

Return the original thumbnail and `0x0`, and add preference for `0x0`.
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
@bashonly bashonly added the site-bug Issue with a specific website label Mar 28, 2023
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
Copy link

@mauritzn mauritzn left a comment

Choose a reason for hiding this comment

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

Request change of overly static RegEx for thumbnail URL modification, to a more flexible RegEx.

yt_dlp/extractor/twitch.py Outdated Show resolved Hide resolved
@pukkandan pukkandan added the pending-fixes PR has had changes requested label Apr 12, 2023
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
@bashonly bashonly removed the pending-fixes PR has had changes requested label Apr 22, 2023
@bashonly bashonly merged commit 80b732b into yt-dlp:master Apr 22, 2023
11 checks passed
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants