From ec3c4a0b2d4993324acd6bc00545836ac00759ce Mon Sep 17 00:00:00 2001 From: Vito Graffagnino Date: Sat, 19 Sep 2020 16:40:47 +0100 Subject: added .vimrc and urlportal --- urlportal.sh | 245 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+) create mode 100755 urlportal.sh (limited to 'urlportal.sh') diff --git a/urlportal.sh b/urlportal.sh new file mode 100755 index 0000000..60f358c --- /dev/null +++ b/urlportal.sh @@ -0,0 +1,245 @@ +#!/bin/bash +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://github.com/gotbletu +# gotbleu@gmail.com + +# _ _ _ +# _ _ _ __| |_ __ ___ _ __| |_ __ _| | +# | | | | '__| | '_ \ / _ \| '__| __/ _` | | +# | |_| | | | | |_) | (_) | | | || (_| | | +# \__,_|_| |_| .__/ \___/|_| \__\__,_|_| +# |_| +# DESC: custom way to handle url (similar idea to xdg-open, mailcap) +# works with just about all programs (e.g w3m, rtv, newsboat, urlview ...etc) +# DEMO: https://www.youtube.com/watch?v=2jyfrmBYzVQ +# install: lynx youtube-dl task-spooler newsboat rtv w3m mpv urlview tmux feh plowshare streamlink curl coreutils + + +# newsboat: +# vim ~/.newsboat/config +# browser ~/.scripts/urlportal.sh + +# rtv: +# vim ~/.bashrc +# export RTV_BROWSER=~/.scripts/urlportal.sh + +# w3m: +# vim ~/.w3m/keymap +# open url under cursor (default: Esc+Shift+M); e.g 2+Esc+Shift+M +# keymap e EXTERN_LINK ~/.scripts/urlportal.sh + +# urlview: +# vim ~/.urlview +# COMMAND ~/.scripts/urlportal.sh + +# references: +# cirrusuk http://arza.us/paste/piper +# obosob https://github.com/michael-lazar/rtv/issues/78#issuecomment-125507472 +# budlabs - mpv queue https://www.youtube.com/watch?v=-vbr3-mHoRs +# https://github.com/budlabs/youtube/blob/master/letslinux/032-queue-files-in-mpv/openvideo +# ji99 - mpv queue script https://www.reddit.com/r/commandline/comments/920p5d/bash_script_for_queueing_youtube_links_in_mpv/ + + +BROWSERCLI="w3m" +BROWSER="qutebrowser" +# DEFAULT="xdg-open" +# DEFAULT="chromium --incognito" +# DEFAULT="w3m" +DEFAULT="$BROWSERCLI" +## long videos like youtube +VIDEO_QUEUE="tsp mpv --ontop --no-border --force-window --autofit=500x280 --geometry=-15-53" +VIDEO_DL="mpsyt dlurl" +## short videos/animated gif clips +VIDEO_CLIP="mpv --loop --quiet --ontop --no-border --force-window --autofit=900x600 --geometry=-15+60" +IMAGEGUI="feh -. -x -B black -g 900x600-15+60" +IMAGECLI="w3m -o display_image=1 -o imgdisplay=w3mimgdisplay" +LIVEFEED="tsp streamlink" +DDL_PATH=~/Downloads/plowshare +DDL_QUEUE_FAST=~/.config/plowshare/queuefast.txt + + +# enable case-insensitive matching +shopt -s nocasematch + +url="$1" +case "$url" in + *gfycat.com/*|*streamable.com/*) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *v.redd.it/*|*video.twimg.com/*|*dailymotion.com*) + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *youtube.com/watch*|*youtu.be/*|*clips.twitch.tv/*) + $VIDEO_DL "$url" + ;; + *twitch.tv/*) + $LIVEFEED "$url" + ;; + *pornhub.com/*|*xvideos.com/*) + # $VIDEO_QUEUE "$url" + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *reddit.com/r/*) + tmux new-window -n rtv && tmux send-keys "rtv -l $url && tmux kill-pane" 'Enter' + ;; + *glodls.to/*|*eogli.org/*|*limetorrents.io/*|*limetorrents.cc/*|*pornoshara.tv/item*|*rustorrents.net/details*|*xxx-tracker.com/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *thepiratebay.org/*|*torrentdownloads.me/*|*yourbittorrent2.com/*|*torlock2.com/*|*bt-scene.cc/*|*rarbg.to/*|*ettorrent.xyz/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *1337x.to/*|*eztv.ag/*|*extratorrent.ag/*|*yts.am/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *22pixx.xyz/ia-i/*) + cleanurl="$(printf $url | sed 's/ia-i/i/g' | sed 's/\.html//g')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *freebunker.com/*) + cleanurl="$(printf $url | sed 's@img\/@tn\/i@')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imagerar.com/t/*) + cleanurl="$(printf $url | sed 's@/t@/u@')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imagerar.com/imgy-u/*) + cleanurl="$(printf $url | sed 's/imgy-u/u/g' | sed 's/.html//g')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imageshtorm.com/upload/small/*|*hotimage.uk/upload/small/*|*hdmoza.com//upload/small/*|*nikapic.ru/upload/small/*|*imagedecode.com/upload/small/*|*trans.firm.in//upload/small/*) + # nohup $IMAGEGUI "$(printf $url | sed 's/small/big/')" > /dev/null 2>&1 & + cleanurl="$(printf $url | sed 's/small/big/')" + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + ;; + *imageshtorm.com/img*) + # nohup $IMAGEGUI "$(printf $url | sed 's/small/big/')" > /dev/null 2>&1 & + cleanurl="$(curl -s "$url" | grep onclick | grep -oP ' /dev/null 2>&1 & + ;; + *i.imgur.com/*| *imgur.com/*.*) + # nohup $IMAGEGUI "$url" > /dev/null 2>&1 & + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' && tmux kill-pane" 'Enter' + ;; + *imgur.com/*) + # tmux split-window && tmux send-keys "lynx -source "$url" | grep post-image-container | grep -oP '
/dev/null 2>&1 & + ;; + *.pdf|*.ps) + zathura "$url" + ;; + *.gif) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *zippyshare.com/*|*mediafire.com/file/*|*sendspace.com/file/*) + if pgrep -f $DDL_QUEUE_FAST > /dev/null + then + echo "$url" >> $DDL_QUEUE_FAST + else + echo "$url" >> $DDL_QUEUE_FAST + cat $DDL_QUEUE_FAST | awk '!x[$0]++' | sponge $DDL_QUEUE_FAST + tmux split-window -fv -p 20 && tmux send-keys "until [[ \$(cat $DDL_QUEUE_FAST | grep -v '#' | wc -l) -eq 0 ]]; do mkdir -p $DDL_PATH && cd $DDL_PATH && plowdown -m $DDL_QUEUE_FAST -o $DDL_PATH ; done" 'Enter' + fi + ;; + *.mp4|*.mkv|*.avi|*.wmv|*.m4v|*.mpg|*.mpeg|*.flv|*.ogm|*.ogv|*.gifv) + $VIDEO_QUEUE "$url" + ;; + *.mp3|*.m4a|*.wav|*.ogg|*.oga|*.flac) + # create queue fifo files if it does not exist + if [[ ! -p /tmp/mpvinput ]]; then + mkfifo /tmp/mpvinput + fi + + # check if process mpv exist (e.g mpv --input-file=/tmp/mpvinput filename.mp3) + if pgrep -f mpvinput > /dev/null + then + # if mpv is already running then append new url/files to queue + # echo loadfile \"${url/'/\\'}\" append-play > /tmp/mpvinput + echo loadfile \"$url\" append-play > /tmp/mpvinput + # nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + else + # if mpv is not running then start it (initial startup) + # mpv --no-video --input-file=/tmp/mpvinput "$1" + tmux split-window -fv -p 20 && tmux send-keys "mpv --no-video --input-file=/tmp/mpvinput \"$url\" && exit" 'Enter' + fi + # Note: use "<" or ">" hotkeys to skip between songs/audio queue list on mpv + ;; + http*|https*|*|*.html) + # $DEFAULT "$url" + tmux new-window -n browse && tmux send-keys "$DEFAULT '$url' && tmux kill-pane" 'Enter' + ;; +esac + -- cgit v1.2.3