2 from pathlib import Path
3 from subprocess import run
4 from directories import Directories
8 project_home = dirs.get_home()
9 audio_dir = dirs.get_audio_dir()
10 video_dir = dirs.get_video_dir()
12 audio_title = Path.joinpath(audio_dir, '%(title)s.%(ext)s')
13 video_title = Path.joinpath(video_dir, '%(title)s.%(ext)s')
15 batch_dl_file = Path.joinpath(project_home, 'batch_dl.txt')
16 requirements = Path.joinpath(project_home, 'requirements.txt')
18 parser = argparse.ArgumentParser(description='A wrapper script to yt-dlp')
20 parser.add_argument('--batch', '-b', type=bool, help='Perform batch download')
22 args = parser.parse_args()
25 format = str(input('Audio or Video?: ')).lower()
29 run(['yt-dlp', '-x', '-f', 'ba', '--audio-format', 'mp3', '-o', f'{audio_title}', '-a', f'{batch_dl_file}'])
31 run(['yt-dlp', '-f', 'bv*[ext=mp4]+ba[ext=m4a]/b[ext=mp4] / bv*+ba/b', '--sponsorblock-remove', 'sponsor,selfpromo,interaction', '-o', f'{video_title}', '-a', f'{batch_dl_file}'])
33 print("Response must be 'Audio' or 'Video'!")
36 downloads_complete = False
37 while downloads_complete != True: # type: ignore
38 format = str(input('Audio or Video?: ')).lower()
40 url = str(input('Enter URL here: '))
46 run(['yt-dlp', '-x', '-f', 'ba', '--audio-format', 'mp3', '-o', f'{audio_title}', f'{url}'])
48 do_continue = str(input("Do you want to convert another file? (y/n): ")).lower()
53 downloads_complete = True
56 print("Answer must be Y or N!")
58 run(['yt-dlp', '-f', 'bv*[ext=mkv]+ba[ext=m4a]/b[ext=mkv] / bv*+ba/b', '--sponsorblock-remove', 'sponsor,selfpromo,interaction', '-o', f'{video_title}', f'{url}'])
60 do_continue = str(input("Do you want to convert another file? (y/n): ")).lower()
65 downloads_complete = True
68 print("Answer must be Y or N!")
70 print("Response must be 'Audio' or 'Video'!")
72 run(['pip', 'install', '--update', '-r', f'{requirements}'])
74 if not audio_dir.exists():
77 if not video_dir.exists():
80 if args.batch == True: