SHARE
TWEET

Untitled

a guest May 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. thumbnail(){
  4.     wget -cq "https://i3.ytimg.com/vi/$1/hqdefault.jpg" -O ~/.scripts/resources/thumbnails/$1.jpg
  5. }
  6.  
  7. update(){
  8.     notify-send -i 'none' -t 3000 "SubTube" "Started update..."
  9.     i=0
  10.     while read line; do
  11.         vid_ids=$(wget -qO- $line | grep "ux-thumb-wrap"| head -n 5 | cut -d\" -f4 | cut -d\= -f2)
  12.         while read vid_id; do
  13.             if grep -Fxq $vid_id ~/.scripts/resources/seen.lst
  14.             then
  15.                 continue
  16.             else
  17.                 i=$((i+1))
  18.                 if [[ $1 != "init" ]]; then
  19.                     thumbnail $vid_id
  20.                 fi
  21.                 echo $vid_id >> ~/.scripts/resources/seen.lst
  22.             fi
  23.         done <<< "$vid_ids"
  24.     done < ~/.scripts/resources/subscribes
  25.     notify-send -i 'none' -t 3000 "SubTube" "$i new videos"
  26. }
  27.  
  28. pick_thumbnails(){
  29.     chosen=$(sxiv -tbo ~/.scripts/resources/thumbnails || notify-send -i 'none' -t 3000 "SubTube" "No videos to play")
  30.     if [[ ! -z $chosen ]]; then
  31.         while read choice; do
  32.             id=$(echo "$choice" | sed 's/\/home\/infiniter\/.scripts\/resources\/thumbnails\/\([^.]\+\)\.jpg/\1/')
  33.             rm $choice
  34.             playing_name $id
  35.             mpv "https://www.youtube.com/watch?v=$id"
  36.         done <<< "$chosen"
  37.     fi
  38. }
  39.  
  40. clean(){
  41.     # echo -en "" > ~/.scripts/resources/seen.lst
  42.     rm ~/.scripts/resources/thumbnails/*
  43. }
  44.  
  45. name(){
  46.     cutted=$(echo "$1" | sed 's/.*\/\([^.]*\)\.jpg/\1/')
  47.     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//')
  48.     notify-send -i 'none' -t 4000 "Title" "$title"
  49. }
  50.  
  51. playing_name(){
  52.     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//')
  53.     notify-send -i 'none' -t 4000 "Playing" "$title"
  54. }
  55.  
  56. list(){
  57.     while read sub; do
  58.         wget --quiet -O - "$sub" | sed -n '/og\:title/p' | sed 's/.*content="\([^"]\+\).*/\1/'
  59.     done < ~/.scripts/resources/subscribes
  60. }
  61.  
  62. if [[ $1 == 'update' ]]; then
  63.     update
  64. elif [[ $1 == 'init' ]]; then
  65.     update init
  66. elif [[ $1 == 'play' ]]; then
  67.     pick_thumbnails
  68. elif [[ $1 == 'clean' ]]; then
  69.     clean
  70. elif [[ $1 == 'name' ]]; then
  71.     name $2
  72. elif [[ $1 == 'add' ]]; then
  73.     echo $2 >> ~/.scripts/resources/subscribes
  74. elif [[ $1 == 'list' ]]; then
  75.     list
  76. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top