0

I already tried using pyinstaller. But it kept showed me 'Fail to execute script' error. I just want to make this code into exe file successfully. some said the problem was about relative path and absolute path. so i changed it by using os.path.join(os.path.abspath('Downloads')) but it didn't work. Btw,it is a program to collect some raps. and also, since i'm a baby coder,i would be grateful if you feedback about me code. if you can do Korean, you can answer me in Korean.

import pytube
import os
import glob
import time
def formatchange(s):
    s = str(s)
    s = s.replace("<", "").replace(">", "").replace("Stream: ", "").replace("itag=", "").replace("mime_type=", "").replace("abr=", "").replace("res=", "").replace("fps=", "").replace("vcodec=", "").replace("acodec=", "").replace("progressive=", "").replace("type=", "").replace(" ", ",").replace("\"", "").split(',')
    del s[0]
    return s

def audio_only(direct,title):
    files = glob.glob(f'{direct}\{title}\*.mp4')
    for x in files:
        if not os.path.isdir(x):
            filename = os.path.splitext(x)
            try:
                os.rename(x,filename[0] + '.mp3')
            except:
                pass
            
    
        
            
def main():
    while 1:
        vv = input("youtube video link>>> ")
        vv = vv.split('&')[0]
        yt = pytube.YouTube(vv)
        title = yt.title
        print(f'\ntitle: {title}\n')
        answer = input('continue??(y/n)>>>')
        if answer == 'y':
            break
        print("try again\n")
    
    videos = yt.streams

    typer = False
    down_dir = os.path.join(os.path.abspath('Downloads'))  #this thing
    print(down_dir)

    list1 = ["타입","화질","fps","코덱","순차주사방식유무","타입"]
    list2 = ["타입","음질","코덱","순차주사방식유무","타입"]

    for i in range(len(videos)):
        print("----------------------------------------")
        a = formatchange(videos[i])
        print(i,end = '\n\n')
        
        if 'video' in a[0]:
            if a[1] == "None":
                a[1] = '소리만 재생only audio'
            if a[4] == "False":
                a[4] = 'False 소리가 안들릴수 있습니다.there might be no audio'
            for i in range(len(list1)):
                print(f'{list1[i]}: {a[i]}')
                
        else:
            for i in range(len(list2)):
                print(f'{list2[i]}: {a[i]}')
        print('\n\n')

    asdf = True
    
    if len(videos) == 0:
        print('found None')
        asdf = False
        
    while 1:
        if asdf:
            i=input('숫자를 입력해 선택하시오.enter number>>> ')
            if i.isdigit() == True and 0<=int(i)<len(videos) :
                i = int(i)
                videos[i].download(down_dir)
                if 'audio' in formatchange(videos[i])[0]:
                    audio_only(down_dir,title)
                print('done')
                os.system('cls')
                break
            print('다시 시도 try agin')
        else:break
            

while 1:
    main()

0 Answers0