|
@@ -1,19 +1,19 @@
|
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
HOST="http://beddy.uberzach.com:32400"
|
|
HOST="http://beddy.uberzach.com:32400"
|
|
|
|
|
+NUM_SERIES=10
|
|
|
|
|
+NUM_EPISODES=5
|
|
|
|
|
|
|
|
# Select a configuration mode
|
|
# Select a configuration mode
|
|
|
URL1="${HOST}/library/sections/2/recentlyViewedShows/"
|
|
URL1="${HOST}/library/sections/2/recentlyViewedShows/"
|
|
|
URL2_POST="allLeaves?unwatched=1"
|
|
URL2_POST="allLeaves?unwatched=1"
|
|
|
ELEMENT="Directory"
|
|
ELEMENT="Directory"
|
|
|
-NUM_EPISODES=5
|
|
|
|
|
MOVIES=0
|
|
MOVIES=0
|
|
|
if echo "${1}" | grep -iq Movie; then
|
|
if echo "${1}" | grep -iq Movie; then
|
|
|
MOVIES=1
|
|
MOVIES=1
|
|
|
URL1="${HOST}/library/sections/1/recentlyAdded/"
|
|
URL1="${HOST}/library/sections/1/recentlyAdded/"
|
|
|
URL2_POST=""
|
|
URL2_POST=""
|
|
|
ELEMENT="Video"
|
|
ELEMENT="Video"
|
|
|
- NUM_EPISODES=10
|
|
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
SERIES="`curl --silent "${URL1}" | \
|
|
SERIES="`curl --silent "${URL1}" | \
|
|
@@ -36,35 +36,35 @@ if [ "${MOVIES}" -gt 0 ]; then
|
|
|
SERIES="${UNWATCHED}"
|
|
SERIES="${UNWATCHED}"
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-nscount=0
|
|
|
|
|
|
|
+SERIES_COUNT=0
|
|
|
IFS=$'\n'
|
|
IFS=$'\n'
|
|
|
for i in $SERIES; do
|
|
for i in $SERIES; do
|
|
|
|
|
+ SERIES_COUNT=$(( $SERIES_COUNT + 1 ))
|
|
|
FILES="`curl --silent "${HOST}/library/metadata/${i}/${URL2_POST}" | \
|
|
FILES="`curl --silent "${HOST}/library/metadata/${i}/${URL2_POST}" | \
|
|
|
grep '<Part ' | \
|
|
grep '<Part ' | \
|
|
|
sed 's%^.*file="\([^\"]*\)".*$%\1%' | \
|
|
sed 's%^.*file="\([^\"]*\)".*$%\1%' | \
|
|
|
sed "s%^.*/media/%%"`"
|
|
sed "s%^.*/media/%%"`"
|
|
|
|
|
|
|
|
- scounts=()
|
|
|
|
|
|
|
+ SEASON_COUNTS=()
|
|
|
IFS=$'\n'
|
|
IFS=$'\n'
|
|
|
for j in $FILES; do
|
|
for j in $FILES; do
|
|
|
# Find the season number and increment the count
|
|
# Find the season number and increment the count
|
|
|
# Account no-season items (i.e. movies) separately
|
|
# Account no-season items (i.e. movies) separately
|
|
|
- season="`echo "${j}" | sed 's%^.*/Season \([0-9]*\)/.*$%\1%'`"
|
|
|
|
|
- if ! echo "${season}" | grep -q '^[0-9]*$'; then
|
|
|
|
|
- season=-1
|
|
|
|
|
- nscount=$(( $nscount + 1 ))
|
|
|
|
|
|
|
+ SEASON="`echo "${j}" | sed 's%^.*/Season \([0-9]*\)/.*$%\1%'`"
|
|
|
|
|
+ if ! echo "${SEASON}" | grep -q '^[0-9]*$'; then
|
|
|
|
|
+ SEASON=-1
|
|
|
else
|
|
else
|
|
|
- scounts[$season]=$(( ${scounts[$season]} + 1 ))
|
|
|
|
|
|
|
+ SEASON_COUNTS[$SEASON]=$(( ${SEASON_COUNTS[$SEASON]} + 1 ))
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
- # For no-season items, output only NUM_EPISODES total
|
|
|
|
|
- if [ $season -lt 0 ]; then
|
|
|
|
|
- if [ $nscount -gt $NUM_EPISODES ]; then
|
|
|
|
|
|
|
+ # Limit the number of series (or movies)
|
|
|
|
|
+ if [ $SEASON -lt 0 ]; then
|
|
|
|
|
+ if [ $SERIES_COUNT -gt $NUM_SERIES ]; then
|
|
|
continue
|
|
continue
|
|
|
fi
|
|
fi
|
|
|
# Only output NUM_EPISODES files per season
|
|
# Only output NUM_EPISODES files per season
|
|
|
# This allows discontinous output, but that's desirable compared to only getting season 0
|
|
# This allows discontinous output, but that's desirable compared to only getting season 0
|
|
|
- elif [ ${scounts[$season]} -gt $NUM_EPISODES ]; then
|
|
|
|
|
|
|
+ elif [ ${SEASON_COUNTS[$SEASON]} -gt $NUM_EPISODES ]; then
|
|
|
continue
|
|
continue
|
|
|
fi
|
|
fi
|
|
|
|
|
|