diff options
-rwxr-xr-x | playlist-wget | 29 |
1 files changed, 12 insertions, 17 deletions
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 |