Python 비디오 다운로더 문제

5951 단어 pythonprogramming
YouTube에서 동영상을 다운로드하도록 Python 프로그램을 프로그래밍했습니다.

링크를 넣고 다운로드를 시작하면 다음 오류가 발생합니다.

Exception in Tkinter callback

Traceback (most recent call last):

  File "C:\lib\tkinter\__init__.py", line 1892, in __call__

    return self.func(*args)

  File "d:\Youtube-Downloader.py", line 36, in DownloadVideo

    select = yt.streams.filter(progressive=True).first()

  File "C:\lib\site-packages\pytube\__main__.py", line 292, in streams

    return StreamQuery(self.fmt_streams)

  File "C:\lib\site-packages\pytube\__main__.py", line 177, in fmt_streams

    extract.apply_signature(stream_manifest, self.vid_info, self.js)

  File "C:\lib\site-packages\pytube\extract.py", line 409, in apply_signature

    cipher = Cipher(js=js)

  File "C:\lib\site-packages\pytube\cipher.py", line 43, in __init__

    self.throttling_plan = get_throttling_plan(js)

  File "C:\lib\site-packages\pytube\cipher.py", line 387, in get_throttling_plan

    raw_code = get_throttling_function_code(js)

  File "C:\lib\site-packages\pytube\cipher.py", line 301, in get_throttling_function_code

    code_lines_list = find_object_from_startpoint(js, match.span()[1]).split('\n')

AttributeError: 'NoneType' object has no attribute 'span'



다음 코드를 첨부합니다.

# Youtube Downloader
from cgitb import text
from logging import root
from random import choices
from secrets import choice
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from tkinter import filedialog
from typing_extensions import Self
from numpy import save
from pytube import YouTube
from soupsieve import select #pip install pytube3

Folder_Name = ""

#file location
def openLocation():
    global Folder_Name
    Folder_Name = filedialog.askdirectory()
    if(len(Folder_Name) > 1):
        locationError.config(text=Folder_Name, fg="green")
    else:
        locationError.config(text="اختر المجلد", fg="red")

#donwload video
def DownloadVideo():
    choice = ytdchoices.get()
    url = ytdEntry.get()

    if(len(url)>1):
        ytdError.config(text="")
        yt = YouTube(url)

        if(choice == choices[0]):
            select = yt.streams.filter(progressive=True).first()

        elif(choice == choices[1]):
            select = yt.streams.filter(progressive=True, file_extension='mp4').last()

        elif(choice == choices[2]):
            select = yt.streams.filter(only_audio=True).first()

        else:
            ytdError.config(text="ألصق الرابط مجدداً", fg="red")

    #download function
    select.download(Folder_Name)
    ytdError.config(text="تم الانتهاء من التحميل!!")

# -------- دالة من نحن --------
def about():
    messagebox.showinfo("Techmakers - Hussein Ouda", "[email protected] : مرحبا بكم في برنامج تحميل الفيديوهات والصوتيات")

root = Tk()
root.title("Techmakers: v 1.0 Youtube Downloader")
root.geometry("650x410+340+10") #set window
root.resizable(False, False)
root.columnconfigure(0, weight=1) #set all content in center.

f1=Frame(root, width=580, height=100, bg='whitesmoke', bd=3, relief=GROOVE)
f1.place(x=30, y=130)
f2=Frame(root, width=580, height=55, bg='whitesmoke', bd=3, relief=GROOVE)
f2.place(x=30, y=250)

#Ytd Link Label
t = Label(root, text="برنامج تحميل الفيديوهات والصوتيات", bg='#FF5F00', fg='#EEEEEE', font=("Tajawal", 15, 'bold'))
t.pack(fill='x')

ytdLabel = Label(root, text="ألصق رابط الفيديو",fg='#00092C', font=("Tajawal", 15, 'bold'))
ytdLabel.pack()

#Entry Box
ytdEntryVar = StringVar()
ytdEntry = Entry(root, width=52, justify='center', font=("Tajawal", 15), bg='#B20600', fg='#00092C', textvariable=ytdEntryVar)
ytdEntry.pack()

#Error Msg
ytdError = Label(root, text="ملاحظات التحميل", fg="#B20600", font=("Tajawal", 10))
ytdError.pack()

#Asking save file label
saveLabel = Label(root, text="اختر مكان حفظ الفيديو", bg="whitesmoke", fg='#00092C', font=("Tajawal", 15, 'bold'))
saveLabel.place(x=390, y=140)

#btn of save file
saveEntry = Button(root, width=20, font=("Tajawal", 10, 'bold'), bg="#00092C", fg="#EEEEEE", text="مسار الحفظ", command=openLocation, cursor='sizing')
saveEntry.place(x=410, y=180)

#Error Msg location
locationError = Label(root, text="لم يتم اختيار مسار حفظ الفيديو", bg='whitesmoke', fg="#B20600", font=("Tajawal", 15))
locationError.place(x=100, y=190)

#Download Quality
ytdQuality = Label(root, text="", bg='whitesmoke', font=("Tajawal", 15, 'bold'))
ytdQuality.place(x=430, y=255)

#combobox
choices = ["720p", "144p", "صوت فقط"]
ytdchoices = ttk.Combobox(root, values=choices)
ytdchoices.place(x=260, y=265)

#download btn
downloadbtn = Button(root, text="بدء التحميل", width=20, font=("Tajawal", 10, 'bold'), bg="#00092C", fg="#EEEEEE", command=DownloadVideo, cursor='clock')
downloadbtn.place(x=40, y=255)

#developer Label
about_btn = Button(root, text='من نحن', width=20, font=("Tajawal", 10, 'bold'), bg='#FF5F00', fg='#EEEEEE', bitmap='info',command=about, cursor='heart')
about_btn.place(x=350, y=350, height=30)

#Close program
exit_btn = Button(root, text='إغلاق البرنامج', width=20, font=("Tajawal", 10, 'bold'), bg='#FF5F00', fg='#EEEEEE', cursor='cross', command=root.quit)
exit_btn.place(x=265, y=350, width=80, height=30)


root.mainloop()



도와주세요

좋은 웹페이지 즐겨찾기