diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-11-01 19:46:59 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-11-01 19:46:59 +0100 |
commit | e2da90c06414b25db78fdcd339eb8109a174d3cb (patch) | |
tree | 5899bda776022b3747fd0f79cb65c89585cc8dbc | |
parent | Renamed scripts (diff) | |
download | dotfiles-bsd-e2da90c06414b25db78fdcd339eb8109a174d3cb.tar.gz dotfiles-bsd-e2da90c06414b25db78fdcd339eb8109a174d3cb.tar.bz2 dotfiles-bsd-e2da90c06414b25db78fdcd339eb8109a174d3cb.tar.xz dotfiles-bsd-e2da90c06414b25db78fdcd339eb8109a174d3cb.tar.zst dotfiles-bsd-e2da90c06414b25db78fdcd339eb8109a174d3cb.zip |
Renamed
-rwxr-xr-x | .local/bin/linkview.pl | 46 | ||||
-rwxr-xr-x | .local/bin/mpview | 76 |
2 files changed, 122 insertions, 0 deletions
diff --git a/.local/bin/linkview.pl b/.local/bin/linkview.pl new file mode 100755 index 0000000..8baf8c0 --- /dev/null +++ b/.local/bin/linkview.pl @@ -0,0 +1,46 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use Term::ANSIColor; + +use constant { + MPV_PATH => '/home/jozan/.local/bin/mpview', + FETCH_PATH => '/usr/bin/fetch' +}; + +# ext="${1##*.}" +# mpvFiles="mkv mp4 gif" +# sxivFiles="png jpg jpeg jpe xpm" +# wgetFiles="flac mp3 mp3?source=feed opus pdf doc docx" +# +# cd ~/dl || exit +# +# if echo "$sxivFiles" | grep -w "$ext" > /dev/null; then +# nohup sxiv "$1" > /dev/null & +# elif echo "$mpvFiles" | grep -w "$ext" > /dev/null; then +# nohup mpv --loop --quiet "$1" > /dev/null & +# elif echo "$wgetFiles" | grep -w "$ext" > /dev/null; then +# clear +# fetch "$1" +# else +# clear +# mpv-view.pl "$1" +# fi + +sub main +{ + my $answer; + + if (@ARGV == 0) { + print STDERR "URL needed\n"; + exit 1; + } + print colored($ARGV[0], 'bold_green') . "\n"; + $answer = <STDIN>; + return; +} + +main(); + +__END__ diff --git a/.local/bin/mpview b/.local/bin/mpview new file mode 100755 index 0000000..a66a75b --- /dev/null +++ b/.local/bin/mpview @@ -0,0 +1,76 @@ +#!/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) { + print 'mpv --ytdl-format=[height<=' . $size . '] ' . $ARGV[0] . "\n"; + exec( + 'mpv', + '--ytdl-format=[height<=' . $size . ']', + $ARGV[0] + ); + } + else { + print 'mpv ' . $ARGV[0] . "\n"; + exec( + 'mpv', + $ARGV[0] + ); + } + print "$size\n"; + exit 0; +} + +main(); + +__END__ |