diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-17 17:16:04 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-10-17 17:16:04 +0200 |
commit | 144b3fc3d26c25cc38ddabca8988496699e4bd0d (patch) | |
tree | c8449dc48d2c1d8b2b1beae4485757fb821b6040 /.local/bin | |
parent | Added ncmpc config (diff) | |
download | dotfiles-bsd-144b3fc3d26c25cc38ddabca8988496699e4bd0d.tar.gz dotfiles-bsd-144b3fc3d26c25cc38ddabca8988496699e4bd0d.tar.bz2 dotfiles-bsd-144b3fc3d26c25cc38ddabca8988496699e4bd0d.tar.xz dotfiles-bsd-144b3fc3d26c25cc38ddabca8988496699e4bd0d.tar.zst dotfiles-bsd-144b3fc3d26c25cc38ddabca8988496699e4bd0d.zip |
Pretty cool script
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/mpv-view.pl | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/.local/bin/mpv-view.pl b/.local/bin/mpv-view.pl new file mode 100755 index 0000000..3e17dd7 --- /dev/null +++ b/.local/bin/mpv-view.pl @@ -0,0 +1,74 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Scalar::Util qw(looks_like_number); +use Term::ANSIColor; + +sub get_size +{ + my $size; + my $answer; + + $size = 0; + $answer = 0; + print + "1) 0\n" . + "2) 240\n" . + "3) 360\n" . + "4) 480\n" . + "5) 720\n" . + "6) 1080\n" . + "\n" . + "> "; + $answer = <STDIN>; + if (!looks_like_number($answer) || $answer == 0 || $answer == 1 || $answer > 6) { + $size = 0; + } + elsif ($answer == 2) { + $size = 240; + } + elsif ($answer == 3) { + $size = 360; + } + elsif ($answer == 4) { + $size = 480; + } + elsif ($answer == 5) { + $size = 720; + } + elsif ($answer == 6) { + $size = 1080; + } + return $size; +} + +sub main +{ + my $size; + + if ($#ARGV + 1 == 0) { + print STDERR "URL needed\n"; + exit 1; + } + $size = get_size(); + if ($size != 0) { + exec( + 'mpv', + '--ytdl-format=[height<=' . $size . ']', + $ARGV[0] + ); + } + else { + exec( + 'mpv', + $ARGV[0] + ); + } + print "$size\n"; + exit 0; +} + +main(); + +__END__ |