我已经编写了一些代码(顺便说一句,我仍然是python和编程方面的新手),我想制作一个tkinter窗口,其中有一个文本框,显示控制台中打印的所有内容,还有一个按钮,运行main()函数。你知道吗
我的现有代码:
import pafy
import os
from pydub import AudioSegment
def downloadSound(videourl):
url = str(videourl)
video = pafy.new(url)
bestaudio = video.getbestaudio()
print(video.title, video.author, video.length)
bestaudio.download()
def linklister(linklist):
f = open('links.txt','r')
for line in f:
linklist.append(line.strip())
f.close()
def converter():
dirlist = os.listdir()
songlist = []
for i in dirlist:
if ".webm" in i:
songlist.append(i)
for i in songlist:
sound = AudioSegment.from_file(i)
imp3 = i.replace(".webm", ".mp3")
sound.export(imp3, format="mp3", bitrate="192k")
print (i, "DONE")
def main():
ytlinks = []
linklister(ytlinks)
for i in ytlinks:
downloadSound(i)
print ("downlad complete, proceeding to conversion")
converter()
try:
main()
except Exception as e:
print (e)
print ("OPPS")
else:
pass
我没有测试过这个,但根据个人经验,这个tkinter代码工作,我无法检查它是否在你的工作。如果此代码不起作用,请在我放置注释的位置添加一个打印来测试它。你知道吗
相关问题 更多 >
编程相关推荐