openzim / youtube

Create a ZIM file from a Youtube channel/username/playlist
GNU General Public License v3.0
44 stars 26 forks source link

Fails if thumbnail is too small #104

Closed rgaudin closed 4 years ago

rgaudin commented 4 years ago

Scrapers fails if thumbnail can't be resized-down. We should account for that and resize-up in this (rare) case. We'll fix it here and then backport to zimscraperlib.

[youtube2zim::2020-06-18 08:58:42,109] ERROR:FAILED. An error occurred: 'Image is too small, Image size : (336, 188), Required size : [480, 270]
rgaudin commented 4 years ago

Video with low thumbnail: https://www.youtube.com/watch?v=5_G2L748abQ and the retrieved file hqdefault.jpg 336x188

What's funny is that youtube-dl reports this as biggest:

youtube-dl --list-thumbnails 5_G2L748abQ
[youtube] 5_G2L748abQ: Downloading webpage
[info] Thumbnails for 5_G2L748abQ:
ID  width  height URL
0   168    94     https://i.ytimg.com/vi/5_G2L748abQ/hqdefault.jpg?sqp=-oaymwEYCKgBEF5IVfKriqkDCwgBFQAAiEIYAXAB&rs=AOn4CLBMcSiRwgfK-PdG3weyQfwA4WjGQQ
1   196    110    https://i.ytimg.com/vi/5_G2L748abQ/hqdefault.jpg?sqp=-oaymwEYCMQBEG5IVfKriqkDCwgBFQAAiEIYAXAB&rs=AOn4CLB1r0huaij0n0xmZRKAt5bMNGNnXA
2   246    138    https://i.ytimg.com/vi/5_G2L748abQ/hqdefault.jpg?sqp=-oaymwEZCPYBEIoBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLBoPogiCL9JvFu4LTtsyq67iOpvuA
3   336    188    https://i.ytimg.com/vi/5_G2L748abQ/hqdefault.jpg?sqp=-oaymwEZCNACELwBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLDv3cwuP5EupbNQGf4-tlsul9VB2Q

But if you fetch this same URL without the parameters, then it's 480x360…

Anyway we need to deal with what youtube-dl sends us (ie. what the uploader sent) and work from that ; so either upscale or insert centered in black frame.

satyamtg commented 4 years ago

https://github.com/openzim/python_scraperlib/pull/25 shall handle this.

rgaudin commented 4 years ago

Great. We shall still use allow_upscaling=True.