Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- thumbnail(){
- wget -cq "https://i3.ytimg.com/vi/$1/hqdefault.jpg" -O ~/.scripts/resources/thumbnails/$1.jpg
- }
- update(){
- notify-send -i 'none' -t 3000 "SubTube" "Started update..."
- i=0
- while read line; do
- vid_ids=$(wget -qO- $line | grep "ux-thumb-wrap"| head -n 5 | cut -d\" -f4 | cut -d\= -f2)
- while read vid_id; do
- if grep -Fxq $vid_id ~/.scripts/resources/seen.lst
- then
- continue
- else
- i=$((i+1))
- if [[ $1 != "init" ]]; then
- thumbnail $vid_id
- fi
- echo $vid_id >> ~/.scripts/resources/seen.lst
- fi
- done <<< "$vid_ids"
- done < ~/.scripts/resources/subscribes
- notify-send -i 'none' -t 3000 "SubTube" "$i new videos"
- }
- pick_thumbnails(){
- chosen=$(sxiv -tbo ~/.scripts/resources/thumbnails || notify-send -i 'none' -t 3000 "SubTube" "No videos to play")
- if [[ ! -z $chosen ]]; then
- while read choice; do
- id=$(echo "$choice" | sed 's/\/home\/infiniter\/.scripts\/resources\/thumbnails\/\([^.]\+\)\.jpg/\1/')
- rm $choice
- playing_name $id
- mpv "https://www.youtube.com/watch?v=$id"
- done <<< "$chosen"
- fi
- }
- clean(){
- # echo -en "" > ~/.scripts/resources/seen.lst
- rm ~/.scripts/resources/thumbnails/*
- }
- name(){
- cutted=$(echo "$1" | sed 's/.*\/\([^.]*\)\.jpg/\1/')
- title=$(wget --quiet -O - "https://www.youtube.com/watch?v=$cutted" | paste -s -d " " | sed -e 's!.*<head>\(.*\)</head>.*!\1!' | sed -e 's!.*<title>\(.*\)</title>.*!\1!' | sed 's/\s*-\s*YouTube//')
- notify-send -i 'none' -t 4000 "Title" "$title"
- }
- playing_name(){
- title=$(wget --quiet -O - "https://www.youtube.com/watch?v=$1" | paste -s -d " " | sed -e 's!.*<head>\(.*\)</head>.*!\1!' | sed -e 's!.*<title>\(.*\)</title>.*!\1!' | sed 's/\s*-\s*YouTube//')
- notify-send -i 'none' -t 4000 "Playing" "$title"
- }
- list(){
- while read sub; do
- wget --quiet -O - "$sub" | sed -n '/og\:title/p' | sed 's/.*content="\([^"]\+\).*/\1/'
- done < ~/.scripts/resources/subscribes
- }
- if [[ $1 == 'update' ]]; then
- update
- elif [[ $1 == 'init' ]]; then
- update init
- elif [[ $1 == 'play' ]]; then
- pick_thumbnails
- elif [[ $1 == 'clean' ]]; then
- clean
- elif [[ $1 == 'name' ]]; then
- name $2
- elif [[ $1 == 'add' ]]; then
- echo $2 >> ~/.scripts/resources/subscribes
- elif [[ $1 == 'list' ]]; then
- list
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement