I am very new to python, I'm wondering how I would just get the maxres thumbnail to print, instead of literally everything about the video. Sorry if the answer is a bit obvious, I am a bit new to python and programming in general.
from apiclient.discovery import build
DEVELOPER_KEY = 'xxxxxx'
youtube = build('youtube', 'v3', developerKey=DEVELOPER_KEY)
ids = '6Gw-RyTRMns'
results = youtube.videos().list(id=ids, part='snippet').execute()
for result in results.get('items', []):
print(results)
I'm also wondering if there is a way to grab a URL to a picture from a description of a given video and have it saved to a folder.
This has been made easy thanks to YouTube. They use links like the one below to retreive thumbnails at different resolutions. Assuming all you need is the URL, just format a string like this:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
You can find a similar question here: How do I get a YouTube video thumbnail from the YouTube API?
You can find more information on the Api here: https://developers.google.com/youtube/v3/
To iterate over a channel you can find another similar question here: python: get all youtube video urls of a channel
To download the images you could use something like this.
import urllib
urllib.urlretrieve("http://img.youtube.com/vi/ytvideo/0.jpg")
For those reading this answer now, the updated url method is:
http://img.youtube.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With