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

[reddit] try_get larger thumbnail images with fallback #27503

Closed
wants to merge 2 commits into from

Conversation

ozburo
Copy link
Contributor

@ozburo ozburo commented Dec 22, 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

The current RedditRIE extractor simply returns the root thumb url for thumbnails, which is very small. This improvement checks for a larger version and returns that instead.

@ozburo ozburo changed the title try_get larger thumnail images with fallback [reddit] try_get larger thumnail images with fallback Dec 22, 2020
@ozburo ozburo changed the title [reddit] try_get larger thumnail images with fallback [reddit] try_get larger thumbnail images with fallback Dec 22, 2020
@dstftw
Copy link
Collaborator

dstftw commented Dec 22, 2020

Extract all resolutions.

@ozburo
Copy link
Contributor Author

ozburo commented Dec 22, 2020

You mean extract all the available images into a thumbnails key and leave the existing thumbnail as is? I see what you mean, that would actually be better!

@ozburo
Copy link
Contributor Author

ozburo commented Dec 22, 2020

Yes, much nicer xD

Copy link
Collaborator

@dstftw dstftw left a comment

Choose a reason for hiding this comment

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

Read coding conventions.

images = try_get(
data, lambda x: x['preview']['images'][0]['resolutions']) or []
for image in images:
url = url_or_none(unescapeHTML(image['url']))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Breaks.

Comment on lines +130 to +131
'width': int_or_none(image['width']),
'height': int_or_none(image['height']),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Breaks.

thumbnails = []
images = try_get(
data, lambda x: x['preview']['images'][0]['resolutions']) or []
for image in images:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Breaks if ...['resolutions'] is not a list.

@@ -9,6 +9,7 @@
float_or_none,
try_get,
url_or_none,
unescapeHTML,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Alphabetic.

@dstftw dstftw closed this in 4046ffe Dec 30, 2020
ThirumalaiK pushed a commit to ThirumalaiK/youtube-dl that referenced this pull request Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants