ValueError:无法解压缩的值太多(应为2)和Tkinter/pytube问题



我正在用tkinter在pytube中制作Youtube音频下载程序,以便将其放在图形界面中。它在一周前运行,但在我今天运行时不起作用。我不知道该怎么做,这是我希望任何人都能帮助我的代码。我修复了pytube中的密码错误,它删除了这个错误,我不知道这是怎么回事。

python版本:3.8

代码:

import tkinter as tk
from tkinter import filedialog
import os
from pytube import YouTube
root = tk.Tk()
root.title('Youtube to audio converter')
root.iconbitmap('000.ico')

root.geometry('600x400')
text1 = tk.Label(root, text='Youtube to audio converter:', fg="red", font=('TkDefaultFont', 18) ).place(x=150, y=0)
textEntry = tk.Entry(root, width=60)
textEntry.place(x = 120, y = 40)
text2 = tk.Label(root, text='Paste the link to the music video in the box and hit the button: ').place(x=115, y=65)
def download():
link = textEntry.get() 
print(link)
yt = YouTube(link)
t = yt.streams.filter(only_audio=True)
t[0].download()
button = tk.Button(root, text='Download', bg='#ff3d3d', font=('TkDefaultFont', 14), command=download).place(x=250, y =100)
text3 = tk.Label(root, text='Do you want it in mp3? If so, put the name in the box below (do not forget to put the extension .mp4) n Remember: if the file is not in the same directory it will not be converted.').place(x=30, y=150)
textEntry2 = tk.Entry(root, width=60)
textEntry2.place(x=120, y=190)
def convert():
archivo=textEntry2.get()
if os.path.isfile(archivo):
os.rename(archivo, archivo + '.mp3')
else:
text4 = tk.Label(root, text='That is not a file or file not found', font=('TkDefaultFont', 14)).place(x=170, y=280)

button2 = tk.Button(root, text='Convert to .mp3', bg='#ff3d3d', font=('TkDefaultFont', 14), command=convert ).place(x=220, y =220)
root.mainloop()

错误:

Exception in Tkinter callback
Traceback (most recent call last):
File "D:Python3.8libtkinter__init__.py", line 1883, in __call__
return self.func(*args)
File "InterfaceAudioDownloader.py", line 40, in download
yt = YouTube(link)
File "D:Python3.8libsite-packagespytube__main__.py", line 92, in __init__
self.descramble()
File "D:Python3.8libsite-packagespytube__main__.py", line 140, in descramble
apply_signature(self.player_config_args, fmt, self.js)
File "D:Python3.8libsite-packagespytubeextract.py", line 225, in apply_signature
cipher = Cipher(js=js)
File "D:Python3.8libsite-packagespytubecipher.py", line 31, in __init__
var, _ = self.transform_plan[0].split(".")
ValueError: too many values to unpack (expected 2)

再次感谢您的帮助!!

我记得读到youtube不断更改其API,以防止您剥离视频的音频。还有一个名为youtube dl的软件包可以进行音频剥离。由于youtube API再次更改,您必须每两周更新一次软件包。这很可能也是你正在经历的。

为了回答您的问题,transform_plan[0]的返回可能发生了变化,或者该值所依赖的任何结构都发生了变化。您应该回溯代码并找到变化点,或者创建回归测试,以便下次轻松找到这些问题。

最新更新