Skip to content

Instantly share code, notes, and snippets.

@pcolby
Created August 13, 2016 03:01
Show Gist options
  • Save pcolby/87bff064b14466907c596612df6f2751 to your computer and use it in GitHub Desktop.
Save pcolby/87bff064b14466907c596612df6f2751 to your computer and use it in GitHub Desktop.
#!/bin/bash
COLLECTIONS_DIR=~/.kodi/addons/screensaver.video/resources/collections
VIDEOS_DIR=~/.kodi/userdata/addon_data/screensaver.video/videos
while IFS= read -d '' -r COLLECTION; do
echo "$COLLECTION"
VIDEOS=`awk 'BEGIN{FS="[<>]";OFS="|"}{if($2=="filename")FILENAME=$3;if($2=="primary")print FILENAME,$3}' "$COLLECTION"`
for VIDEO in ${VIDEOS[@]}; do
FILENAME=`echo "$VIDEO" | cut -d'|' -f1`
URL=`echo "$VIDEO" | cut -d'|' -f2`
echo " $FILENAME"
if [ ! -e "$VIDEOS_DIR/$FILENAME" ]; then
wget -O "$VIDEOS_DIR/$FILENAME" "$URL"
fi
done
done < <(find "$COLLECTIONS_DIR" -name '*.xml' -type f -not -name 'appletv.xml' -print0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment