Last version before Gearman
This commit is contained in:
parent
da8345eca6
commit
b3464284c7
49
dl.sh
49
dl.sh
@ -1,62 +1,63 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
pwd=`echo "$0" | sed -e "s/[^\/]*$//"`
|
pwd=$(dirname $0)
|
||||||
|
|
||||||
# Don't do anything if this script is already launched
|
# Don't do anything if this script is already launched
|
||||||
if [ ! -e /tmp/dlEnCours ]; then
|
if [ ! -e /tmp/dlEnCours ]; then
|
||||||
for f in "$pwd"/users/*.dlist; do
|
for f in "$pwd"/users/*.dlist; do
|
||||||
if [ `cat $f | wc -l` -gt 0 ]; then
|
if [ `cat $f | wc -l` -gt 0 ]; then
|
||||||
transmission-remote -asu 10 -as
|
|
||||||
touch /tmp/dlEnCours
|
touch /tmp/dlEnCours
|
||||||
|
|
||||||
lign=`sed '2,$d' $f | tr -d '\n'`
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
||||||
|
|
||||||
while [ -n "$lign" ] && [ `cat $f | wc -l` -gt 0 ]
|
while [ -n "$lign" ] && [ `cat "$f" | wc -l` -gt 0 ]
|
||||||
do
|
do
|
||||||
if [ -z "$lign" ]; then
|
if [ -z "$lign" ]; then
|
||||||
sed -i '1d' $f
|
sed -i '1d' "$f"
|
||||||
lign=`sed '2,$d' $f | tr -d '\n'`
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Action: $lign"
|
echo "Action: $lign"
|
||||||
if [ "$lign" = "clear" ]; then
|
if [ "$lign" = "clear" ]; then
|
||||||
echo "-- " >> $f.done
|
echo "-- " >> "$f.done"
|
||||||
transmission-remote -AS
|
|
||||||
else
|
else
|
||||||
$pwd/youtube-dl --skip-download "$lign"
|
"$pwd"/youtube-dl --skip-download "$lign"
|
||||||
size=`$pwd/youtube-dl --skip-download "$lign" | grep "File size"`
|
size=`"$pwd"/youtube-dl --skip-download "$lign" | grep "File size"`
|
||||||
if echo $size | grep -E " [1234]?[0-9]{1,2}\.[0-9]+M "
|
if echo $size | grep -E " [1234]?[0-9]{1,2}\.[0-9]+M "
|
||||||
then
|
then
|
||||||
echo "$lign" >> $pwd/database
|
echo "$lign" >> "$pwd"/database
|
||||||
|
|
||||||
$pwd/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> $pwd/database
|
"$pwd"/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> "$pwd"/database
|
||||||
echo "-- " >> $pwd/database
|
echo "-- " >> "$pwd"/database
|
||||||
|
|
||||||
echo "$lign" > $f.ec
|
echo "$lign" > "$f.ec"
|
||||||
$pwd/youtube-dl -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
# "$pwd"/youtube-dl -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
||||||
# $pwd/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
"$pwd"/youtube-dl --no-progress -c -o "$pwd/content/%(id)s.%(ext)s" "$lign"
|
||||||
echo "$lign" >> $f.ec
|
echo "$lign" >> "$f.ec"
|
||||||
echo "${f:$((${#pwd} + 7)):4}"
|
echo "${f:$((${#pwd} + 7)):4}"
|
||||||
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
|
||||||
echo "nemu convertion"
|
echo "nemu convertion"
|
||||||
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
|
||||||
else
|
else
|
||||||
$pwd/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
|
||||||
fi
|
fi
|
||||||
echo "" > $f.ec
|
echo "" > "$f.ec"
|
||||||
|
|
||||||
echo "$lign" >> $f.done
|
echo "$lign" >> "$f.done"
|
||||||
|
|
||||||
chown www-data:www-data $f.done $f.ec
|
chgrp www-data "$f.done" "$f.ec"
|
||||||
|
chmod g+rw "$f.done" "$f.ec"
|
||||||
else
|
else
|
||||||
echo $size
|
echo $size
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#Remove the action from the file
|
#Remove the action from the file
|
||||||
sed -i '1d' $f
|
sed -i '1d' "$f"
|
||||||
|
chgrp www-data "$f"
|
||||||
|
chmod g+rw "$f"
|
||||||
|
|
||||||
#What's next?
|
#What's next?
|
||||||
lign=`sed '2,$d' $f | tr -d '\n'`
|
lign=`sed '2,$d' "$f" | tr -d '\n'`
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user