This repository has been archived on 2020-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
musik/dl.sh

66 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/bash
2012-02-27 16:59:03 +00:00
2013-12-26 11:19:34 +00:00
pwd=$(dirname $0)
2012-02-27 16:59:03 +00:00
2012-03-05 21:46:25 +00:00
# Don't do anything if this script is already launched
if [ ! -e /tmp/dlEnCours ]; then
for f in "$pwd"/users/*.dlist; do
if [ `cat $f | wc -l` -gt 0 ]; then
touch /tmp/dlEnCours
2013-12-26 11:19:34 +00:00
lign=`sed '2,$d' "$f" | tr -d '\n'`
2012-03-05 21:46:25 +00:00
2013-12-26 11:19:34 +00:00
while [ -n "$lign" ] && [ `cat "$f" | wc -l` -gt 0 ]
2012-03-05 21:46:25 +00:00
do
if [ -z "$lign" ]; then
2013-12-26 11:19:34 +00:00
sed -i '1d' "$f"
lign=`sed '2,$d' "$f" | tr -d '\n'`
2012-03-05 21:46:25 +00:00
fi
echo "Action: $lign"
if [ "$lign" = "clear" ]; then
2013-12-26 11:19:34 +00:00
echo "-- " >> "$f.done"
2012-03-05 21:46:25 +00:00
else
2013-12-26 11:19:34 +00:00
"$pwd"/youtube-dl --skip-download "$lign"
size=`"$pwd"/youtube-dl --skip-download "$lign" | grep "File size"`
if echo $size | grep -E " [1234]?[0-9]{1,2}\.[0-9]+M "
then
2013-12-26 11:19:34 +00:00
echo "$lign" >> "$pwd"/database
2013-12-26 11:19:34 +00:00
"$pwd"/youtube-dl --get-title --get-thumbnail --get-filename "$lign" >> "$pwd"/database
echo "-- " >> "$pwd"/database
2013-12-26 11:19:34 +00:00
echo "$lign" > "$f.ec"
# "$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"
echo "$lign" >> "$f.ec"
echo "${f:$((${#pwd} + 7)):4}"
if [ "${f:$((${#pwd} + 7)):4}" == "nemu" ]; then
echo "nemu convertion"
2013-12-26 11:19:34 +00:00
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=vorbis "$lign"
else
2013-12-26 11:19:34 +00:00
"$pwd"/youtube-dl --no-progress -c -k -o "$pwd/content/%(id)s.%(ext)s" --extract-audio --audio-format=mp3 "$lign"
fi
2013-12-26 11:19:34 +00:00
echo "" > "$f.ec"
2013-12-26 11:19:34 +00:00
echo "$lign" >> "$f.done"
2013-12-26 11:19:34 +00:00
chgrp www-data "$f.done" "$f.ec"
chmod g+rw "$f.done" "$f.ec"
else
echo $size
fi
fi
2012-03-05 21:46:25 +00:00
#Remove the action from the file
2013-12-26 11:19:34 +00:00
sed -i '1d' "$f"
chgrp www-data "$f"
chmod g+rw "$f"
2012-03-05 21:46:25 +00:00
#What's next?
2013-12-26 11:19:34 +00:00
lign=`sed '2,$d' "$f" | tr -d '\n'`
2012-03-05 21:46:25 +00:00
done
fi
2012-02-27 16:59:03 +00:00
done
2012-03-05 21:46:25 +00:00
rm /tmp/dlEnCours 2> /dev/null
2012-02-27 16:59:03 +00:00
fi