i want to show a yt video's thumbnail using tkinter and pytube but it won't work
my code is as follow:
from tkinter import *
import urllib.request, io
from PIL import ImageTk, Image
from pytube import YouTube
sc= Tk()
def show_pic():
yt = YouTube('https://www.youtube.com/watch?v=sVPYIRF9RCQ')
raw_data = urllib.request.urlopen(yt.thumbnail_url).read()
im = Image.open(io.BytesIO(raw_data)).resize((200, 200))
image = ImageTk.PhotoImage(im)
c.create_image(0,0, anchor='nw', image=image)
c = Canvas(sc, width=200, height=200)
c.pack()
btn = Button(sc, text='Show', command=show_pic)
btn.pack()
sc.mainloop()
question from:
https://stackoverflow.com/questions/65920195/show-thumbnail-of-youtube-video-in-canvas-using-pytube-and-tkinter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…