Skip to content

Instantly share code, notes, and snippets.

@AeliusSaionji
Created February 27, 2019 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AeliusSaionji/e059949b9c27d78cf4ab36f1f33f314a to your computer and use it in GitHub Desktop.
Save AeliusSaionji/e059949b9c27d78cf4ab36f1f33f314a to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ $# -eq 0 ]; then
printf '%s\n' 'Specify the playlist file.'
printf '%s\n' './musicupdate playlist.m3u8'
exit
fi
# First, some tests
## Make sure file exists
if [ ! -f "$1" ]; then
printf '%s\n' 'File does not exist'
exit
fi
## Make sure the paths start with 'Music'
if ! grep -q '^Music' "$1"; then
printf '%s\n' 'Song paths must start with Music'
exit
fi
# Convert Windows paths
## Intermediate file prevents shell overwriting source
tr '\\' '/' <"$1">"$1.intermediate"
mv "$1.intermediate" "$1"
# Sync files
rsync aelius@192.168.1.101:/cygdrive/h/ --files-from="$1" /sdcard/ -tPi
# Make android path explicit
sed -i 's@^Music@/sdcard/Music@' "$1"
# Move playlist file to be used for android apps
## Some dumb apps don't support m3u8
mv "$1" "/sdcard/Playlists/$1.m3u"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment