This repository has no description
695 B
40 lines
1{ pkgs, ... }:
2
3pkgs.writeScriptBin "mpv-poll" ''
4 #! ${pkgs.bash}/bin/bash
5
6 pl=$1
7 hist=''${HISTORY:-"./mpv_history"}
8 mpv_options=''${MPV_OPTIONS:-""}
9
10 lastYT=""
11
12 play_video () {
13 toPlay=$1
14 echo $toPlay >> $hist
15 mpv $mpv_options $toPlay
16 }
17
18 if ! [ -e $hist ]; then
19 touch $hist
20 fi
21
22 while :
23 do
24 if [ -s $pl ]; then
25 toPlay=$(head -1 $pl)
26 sed -i '1d' $pl
27 if $(echo $toPlay | grep -Eq 'https?://(www.)?youtube.com/watch'); then
28 lastYT=$toPlay
29 fi
30 play_video $toPlay
31 else
32 if [ -n "$lastYT" ]; then
33 next=$(yt-next $lastYT)
34 lastYT=$next
35 play_video $next
36 fi
37 sleep 1
38 fi
39 done
40''