Use per-file config for feeds; allow to hard code fetcher for feed
More flexible and easier to handle than reading from the input file.
This commit is contained in:
parent
3a723b9440
commit
cb1a4c743c
31
randrss
31
randrss
@ -8,13 +8,13 @@ DEFAULT_PER_ITEM="1-$random_default"
|
|||||||
|
|
||||||
echo "Current default sleep seconds range: $DEFAULT_PER_ITEM"
|
echo "Current default sleep seconds range: $DEFAULT_PER_ITEM"
|
||||||
if [ $# -lt 1 ] ; then
|
if [ $# -lt 1 ] ; then
|
||||||
echo "Usage: $0 inputfile fetchersfile [syncnow]"
|
echo "Usage: $0 feedsconfigdir fetchersfile [syncnow]"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
inputfile="$1"
|
feedsconfigdir="$1"
|
||||||
fetchersfile="$2"
|
fetchersfile="$2"
|
||||||
if [ ! -f "$inputfile" ] ; then
|
if [ ! -d "$feedsconfigdir" ] ; then
|
||||||
echo "inputfile does not exist or is not readable" 1>&2
|
echo "$feedsconfigdir does not exist or is not readable" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -28,21 +28,30 @@ if [ "$3" = "syncnow" ] ; then
|
|||||||
syncnow=1
|
syncnow=1
|
||||||
fi
|
fi
|
||||||
while true ; do
|
while true ; do
|
||||||
shuf "$inputfile" | while read line ; do
|
ls "$feedsconfigdir" | while read line ; do
|
||||||
url=$( echo "$line" | cut -d":" -f1,2 )
|
source "$feedsconfigdir/$line"
|
||||||
output=$( echo "$line" | cut -d":" -f3)
|
|
||||||
range=$( echo "$line" | cut -d":" -f4)
|
|
||||||
sleepfor=0
|
sleepfor=0
|
||||||
if [ -n "$range" ] ; then
|
if [ -n "$FEED_RANGE" ] ; then
|
||||||
sleepfor=$( shuf -i "$range" -n 1)
|
sleepfor=$( shuf -i "$range" -n 1)
|
||||||
else
|
else
|
||||||
sleepfor=$( shuf -i "$DEFAULT_PER_ITEM" -n 1)
|
sleepfor=$( shuf -i "$DEFAULT_PER_ITEM" -n 1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fetcher="$FEED_FETCHER"
|
||||||
|
if [ -z "$FEED_FETCHER" ] ; then
|
||||||
fetcher=$( shuf -n 1 "$fetchersfile" )
|
fetcher=$( shuf -n 1 "$fetchersfile" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e "$fetcher" ] ; then
|
||||||
|
echo "$fetcher does not exist" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
[ $syncnow -eq 1 ] || ( echo "Sleeping for $sleepfor seconds for $url, chosen fetcher $fetcher" && sleep "$sleepfor" )
|
[ $syncnow -eq 1 ] || ( echo "Sleeping for $sleepfor seconds for $url, chosen fetcher $fetcher" && sleep "$sleepfor" )
|
||||||
echo "Fetching $url with $fetcher"
|
echo "Fetching $FEED_URL with $fetcher"
|
||||||
torsocks ./$fetcher "$url" "$output" || echo "Failed to fetch $url"
|
torsocks "$fetcher" "$FEED_URL" "$FEED_OUTPUT" || echo "Failed to fetch $FEED_URL"
|
||||||
done
|
done
|
||||||
[ $syncnow -eq 1 ] && exit
|
[ $syncnow -eq 1 ] && exit
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user