Created
February 27, 2019 01:48
-
-
Save AeliusSaionji/e059949b9c27d78cf4ab36f1f33f314a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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