1
1
mirror of https://github.com/neosubhamoy/pytubepp.git synced 2025-12-19 08:53:01 +05:30

(refactor): improved user prompts and default prompt indication

This commit is contained in:
2025-01-25 23:30:28 +05:30
parent 0b8f34111d
commit 48f9f06e23
2 changed files with 21 additions and 52 deletions

View File

@@ -452,10 +452,7 @@ def main():
downloader.download_stream(args.url, args.stream)
elif args.stream == 'mp3' and downloader.stream.get_by_itag(140):
print(f'\nYou have chosen to download mp3 stream! ( Captioning audio files is not supported )')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
answer = input('Do you still want to continue downloading? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, args.stream)
else:
@@ -469,10 +466,7 @@ def main():
downloader.download_stream(args.url, args.stream)
elif args.stream == 'mp3' and downloader.stream.get_by_itag(140):
print(f'\nYou have chosen to download mp3 stream! ( Captioning audio files is not supported )')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
answer = input('Do you still want to continue downloading? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, args.stream)
else:
@@ -481,10 +475,7 @@ def main():
downloader.download_stream(args.url, args.stream, downloader.default_caption)
else:
print(f'\nDefault caption not available! ( Default: {downloader.default_caption} | Available: {[caption.code for caption in downloader.captions.keys()] or "Nothing"} )')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
answer = input('Do you still want to continue downloading without caption? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, args.stream)
else:
@@ -505,10 +496,7 @@ def main():
else:
if downloader.maxres:
print(f'\nDefault stream not available! ( Default: {downloader.default_stream} | Available: {downloader.maxres} )')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
answer = input('Do you want to download the maximum available stream? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.maxres)
else:
@@ -519,10 +507,7 @@ def main():
downloader.download_stream(args.url, downloader.maxres, args.caption)
elif downloader.default_stream == 'mp3' and downloader.stream.get_by_itag(140):
print(f'\nDefault stream set to mp3! ( Captioning audio files is not supported )')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
answer = input('Do you still want to continue downloading? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.default_stream)
else:
@@ -532,10 +517,7 @@ def main():
else:
if downloader.maxres:
print(f'\nDefault stream not available! ( Default: {downloader.default_stream} | Available: {downloader.maxres} )')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
answer = input('Do you want to download the maximum available stream? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.maxres, args.caption)
else:
@@ -552,10 +534,7 @@ def main():
downloader.download_stream(args.url, downloader.maxres, downloader.default_caption)
else:
print(f'\nDefault caption not available! ( Default: {downloader.default_caption} | Available: {[caption.code for caption in downloader.captions.keys()] or "Nothing"} )')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
answer = input('Do you still want to continue downloading without caption? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.maxres)
else:
@@ -565,10 +544,7 @@ def main():
downloader.download_stream(args.url, downloader.default_stream)
elif downloader.default_stream == 'mp3' and downloader.stream.get_by_itag(140):
print(f'\nDefault stream set to mp3! ( Captioning audio files is not supported )')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading ? [yes/no]\n')
answer = input('Do you still want to continue downloading? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.default_stream)
else:
@@ -577,10 +553,7 @@ def main():
downloader.download_stream(args.url, downloader.default_stream, downloader.default_caption)
else:
print(f'\nDefault caption not available! ( Default: {downloader.default_caption} | Available: {[caption.code for caption in downloader.captions.keys()] or "Nothing"} )')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
answer = input('Do you still want to continue downloading without caption? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.default_stream)
else:
@@ -588,10 +561,7 @@ def main():
else:
if downloader.maxres:
print(f'\nDefault stream not available! ( Default: {downloader.default_stream} | Available: {downloader.maxres} )')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you want to download the maximum available stream ? [yes/no]\n')
answer = input('Do you want to download the maximum available stream? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
if downloader.default_caption == 'none':
downloader.download_stream(args.url, downloader.maxres)
@@ -599,14 +569,13 @@ def main():
downloader.download_stream(args.url, downloader.maxres, downloader.default_caption)
else:
print(f'\nDefault caption not available! ( Default: {downloader.default_caption} | Available: {[caption.code for caption in downloader.captions.keys()] or "Nothing"} )')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
while answer not in ['yes', 'y', 'no', 'n']:
print('Invalid answer! try again...!! answer with: [yes/y/no/n]')
answer = input('Do you still want to continue downloading without caption? [yes/no]\n')
answer = input('Do you still want to continue downloading without caption? [yes/No]: ').strip().lower()
if answer in ['yes', 'y']:
downloader.download_stream(args.url, downloader.maxres)
else:
print('Download cancelled! exiting...!!')
else:
print('Download cancelled! exiting...!!')
else:
print('Sorry, No downloadable video stream found....!!!')
else:

View File

@@ -21,8 +21,8 @@ def postinstall():
package_manager = 'winget' # Windows Package Manager
else:
print("OS: Windows (winget not enabled)")
user_input = input("WinGet is not available. Do you want to enable winget? (Make sure to login to Windows before enabling) [yes/no]: ").strip().lower()
if user_input in ['yes', 'y']:
user_input = input("WinGet is not available. Do you want to enable winget? (Make sure to login to Windows before enabling) [Yes/no]: ").strip().lower()
if user_input in ['yes', 'y', '']:
print("Enabling winget...")
subprocess.run(['powershell', '-Command', 'Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe'])
print("WinGet enabled successfully! Please restart your computer and re-run the post install script: pytubepp --postinstall")
@@ -43,8 +43,8 @@ def postinstall():
print("OS: Linux (dnf)")
distro_id = subprocess.run(['grep', '^ID=', '/etc/os-release'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
if distro_id.returncode == 0 and 'fedora' in distro_id.stdout.decode().strip() and ffmpeg_needed:
user_input = input("Looks like you are using Fedora. Do you want to enable RPM Fusion free and nonfree repositories? (answer no if already enabled) [yes/no]: ").strip().lower()
if user_input in ['yes', 'y']:
user_input = input("Looks like you are using Fedora. Do you want to enable RPM Fusion free and nonfree repositories? (answer no if already enabled) [Yes/no]: ").strip().lower()
if user_input in ['yes', 'y', '']:
print("Enabling RPM Fusion repositories...")
fedora_version = subprocess.run(['rpm', '-E', '%fedora'], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
if fedora_version.returncode == 0:
@@ -70,8 +70,8 @@ def postinstall():
package_manager = 'brew' # Homebrew for macOS
else:
print("OS: MacOS (brew not installed)")
user_input = input("Homebrew is not installed. Do you want to install Homebrew? [yes/no]: ").strip().lower()
if user_input in ['yes', 'y']:
user_input = input("Homebrew is not installed. Do you want to install Homebrew? [Yes/no]: ").strip().lower()
if user_input in ['yes', 'y', '']:
print("Installing Homebrew...")
subprocess.run('/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"', shell=True)
print("Homebrew installation completed! Please restart your mac and re-run the post install script: pytubepp --postinstall")
@@ -89,8 +89,8 @@ def postinstall():
if nodejs_needed:
print("- Node.js")
user_input = input("Do you want to proceed with the installation? [yes/no]: ").strip().lower()
if user_input not in ['yes', 'y']:
user_input = input("Do you want to proceed with the installation? [Yes/no]: ").strip().lower()
if user_input not in ['yes', 'y', '']:
print("Installation aborted! exiting...!!")
return