Created
March 21, 2019 10:56
-
-
Save varp/56c114d878cdba8889b0f307041be266 to your computer and use it in GitHub Desktop.
Generate m3u playlist with files from OneDrive folder
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
#!/usr/bin/env bash | |
onedrivecmd --version > /dev/null || { echo "Run `pip install onedrivecmd` and try again."; exit 1; } | |
[ $# -eq 0 ] && { echo "Help: m3u_from_onedrive.sh <folder> [playlist name]"; exit 1; } | |
folder=$1 | |
IFS=$'\n' files=( $(onedrivecmd list "od:$folder" | cut -f1 -d$'\t' | grep -v '/$' | xargs -0) ) | |
plname=$( [ -z $2 ] && basename $1 || $2 ) | |
echo "#EXT3MU ${plname}" | |
for f in ${files[@]} | |
do | |
normpath=$(echo "${f}" | sed -e 's|od:/||') | |
extinf="#EXTINF:1, $normpath" | |
echo "${extinf}" | |
echo "$(onedrivecmd direct "od:$folder$normpath")" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment