Created
January 22, 2022 15:26
-
-
Save getimiskon/a5e68f68df27b47f0be9c5678bacdd66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env raku | |
# Variables | |
my ($resolution, $mode, $video_link); # Main variables | |
my Bool $debug = True; # Debug mode. Should be turned off for actual use. | |
# Subroutines | |
sub intro { | |
say "YouTube CLI Viewer - Raku version"; | |
sleep 0.5; | |
} | |
sub playVideo { | |
if $debug eq True { | |
say "DEBUG: Resolution: " ~ $resolution ~ "p"; | |
} | |
shell "mpv '$video_link' --ytdl-format='bestvideo[height<=$resolution]+bestaudio/best'"; | |
} | |
sub downloadMode { | |
if $debug eq True { | |
say "DEBUG: Mode: download"; | |
} | |
die "ERROR: Download mode is not implemented yet"; | |
} | |
sub exitScript { | |
say "Exiting YouTube viewer..."; | |
sleep 0.75; | |
exit; | |
} | |
sub MAIN ($mode = 'viewer', $resolution = 720) { | |
intro; | |
if $debug eq True { | |
if @*ARGS[] eq '' { | |
say "DEBUG: Arguments: (no arguments)"; | |
} else { | |
say "DEBUG: Arguments: " ~ @*ARGS[]; | |
} | |
say "DEBUG: Resolution: " ~ $resolution ~ "p"; | |
} | |
sleep 0.5; | |
if $mode eq 'download' { | |
downloadMode; | |
} else { | |
if $debug eq True { | |
say "DEBUG: Mode: viewer"; | |
} | |
$video_link = prompt "Paste the video link: "; | |
if $video_link eq 'exit' { | |
exitScript; | |
} else { | |
say "Resolution: $resolution"; | |
playVideo; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment