From a4333e7689fe8980ac5ca161c4c29dd0c1a81ecf Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 5 Oct 2017 07:35:35 -0300 Subject: Reimplement playlist-mpv playlist-mplayer --- playlist-wget | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'playlist-wget') diff --git a/playlist-wget b/playlist-wget index 63422b9..0f33887 100755 --- a/playlist-wget +++ b/playlist-wget @@ -28,24 +28,19 @@ PLAYLIST_BASE="$(dirname $(dirname $PLAYLIST))" wget -c $PLAYLIST # Process each file -cat `basename $PLAYLIST` | while read file; do - dirname="`dirname "$file"`" +if [ "$BASENAME" == "playlist-wget" ]; then + cat `basename $PLAYLIST` | while read file; do + dirname="`dirname "$file"`" - if [ "$BASENAME" == "playlist-wget" ]; then # Download playlist and all it's files preseving the folder structure mkdir -p "$dirname" wget -c "$PLAYLIST_BASE/$file" -O "$file" - elif [ "$BASENAME" == "playlist-mpv" ]; then - # Play using mpv - mpv "$PLAYLIST_BASE/$file" - elif [ "$BASENAME" == "playlist-mplayer" ]; then - # Play using mplayer - mplayer "$PLAYLIST_BASE/$file" - fi -done - -# Remove playlist if on stream mode -# This should be implemented as a shell trap -#if [ "$BASENAME" == "playlist-mpv" ] || [ "$BASENAME" == "playlist-mplayer" ]; then -# rm `basename $PLAYLIST` -#fi + done +elif [ "$BASENAME" == "playlist-mpv" ]; then + # Play using mpv + # We could call mpv directly with the playlist URL, but then the file locations would be wrong + curl -s $PLAYLIST | sed -e "s|^|\"$PLAYLIST_BASE/|" -e 's|$|"|' -e 's|\n|\x0|' | xargs mpv +elif [ "$BASENAME" == "playlist-mplayer" ]; then + # Play using mplayer + curl -s $PLAYLIST | sed -e "s|^|\"$PLAYLIST_BASE/|" -e 's|$|"|' -e 's|\n|\x0|' | xargs mplayer +fi -- cgit v1.2.3