mirror of
https://github.com/anatolykopyl/youtube-cdl.git
synced 2026-03-26 12:55:11 +00:00
🏗 Added Windows support
This commit is contained in:
36
main.py
36
main.py
@@ -1,14 +1,19 @@
|
|||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
#from rich import inspect
|
#from rich import inspect
|
||||||
|
import platform
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
from getch import getch
|
|
||||||
import youtube_dl
|
import youtube_dl
|
||||||
from get_channels import retrieve_youtube_subscriptions
|
from get_channels import retrieve_youtube_subscriptions
|
||||||
from print_logo import print_logo
|
from print_logo import print_logo
|
||||||
|
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
import msvcrt
|
||||||
|
else:
|
||||||
|
from getch import getch
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('-i', '--input', action='store', type=str,
|
parser.add_argument('-i', '--input', action='store', type=str,
|
||||||
help='Path to json file generated by previously running this program.')
|
help='Path to json file generated by previously running this program.')
|
||||||
@@ -25,7 +30,7 @@ download_all = args.all
|
|||||||
|
|
||||||
c = Console()
|
c = Console()
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
'format': 'best'
|
'format': 'best'
|
||||||
}
|
}
|
||||||
|
|
||||||
print_logo()
|
print_logo()
|
||||||
@@ -45,15 +50,26 @@ else:
|
|||||||
curr_channel += 1
|
curr_channel += 1
|
||||||
c.print(f'[dim][{curr_channel}/{len(all_channels)}]:[/dim] {ch["title"]} [cyan]\[y/n]')
|
c.print(f'[dim][{curr_channel}/{len(all_channels)}]:[/dim] {ch["title"]} [cyan]\[y/n]')
|
||||||
while True:
|
while True:
|
||||||
key = getch()
|
if platform.system() == 'Windows':
|
||||||
if key == "y":
|
key = str(msvcrt.getch())
|
||||||
ch['download'] = True
|
if key == "b'y'":
|
||||||
break
|
ch['download'] = True
|
||||||
elif key == "n":
|
break
|
||||||
ch['download'] = False
|
elif key == "b'n'":
|
||||||
break
|
ch['download'] = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
c.print('Press "y" or "n"', style='yellow')
|
||||||
else:
|
else:
|
||||||
c.print('Press "y" or "n"', style='orange')
|
key = getch()
|
||||||
|
if key == "y":
|
||||||
|
ch['download'] = True
|
||||||
|
break
|
||||||
|
elif key == "n":
|
||||||
|
ch['download'] = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
c.print('Press "y" or "n"', style='yellow')
|
||||||
|
|
||||||
c.print('All done! 🎉')
|
c.print('All done! 🎉')
|
||||||
c.print('Saving to download_list.json...', style='italic')
|
c.print('Saving to download_list.json...', style='italic')
|
||||||
|
|||||||
@@ -8,5 +8,4 @@ __ ______ __ __________ ______ ______ __________ __
|
|||||||
\ / / / / / / / / / / / / / __ / __/______/ / / / / / /
|
\ / / / / / / / / / / / / / __ / __/______/ / / / / / /
|
||||||
/ / /_/ / /_/ / / / / /_/ / /_/ / /__/_____/ /___/ /_/ / /___
|
/ / /_/ / /_/ / / / / /_/ / /_/ / /__/_____/ /___/ /_/ / /___
|
||||||
/_/\____/\____/ /_/ \____/_____/_____/ \____/_____/_____/
|
/_/\____/\____/ /_/ \____/_____/_____/ \____/_____/_____/
|
||||||
|
""", style='magenta')
|
||||||
""", style='magenta')
|
|
||||||
Reference in New Issue
Block a user