This commit is contained in:
overflowerror 2017-01-06 16:25:24 +01:00
parent 2c6bf267e6
commit 8d1db20b8c
2 changed files with 248 additions and 0 deletions

111
movie-dl Executable file
View file

@ -0,0 +1,111 @@
#!/bin/bash
domain="http://putlockers.ch"
search="$1"
file="$2"
echo "Searching for \"$search\"..."
results="$(wget -O - "$domain/search/search.php?q=$search" 2> /dev/null | sed "s/<a/\\n/g" | grep -v "/a-z/" | grep -v "/year/" | grep -v "/genre/" | grep -v "/tv" | grep -v "/yesterday/" | grep -v "/today/" | grep -v "featured" | grep -v "/contact/" | grep "href=" | grep "title=" | awk -F\" '{ print $2 " \"" $4 "\"" }' | grep -v "\"Homepage\"" | uniq)"
echo
num=$(echo "$results" | wc -l)
if test $num = 0; then
echo "No results."
exit 1
fi
url=""
name=""
if test $num != 1; then
echo "$num versions found:"
echo
i=1
echo "$results" | while read url name; do
echo $i: $name
i=$((i+1))
done
while true; do
echo
read -p "Choose wisely: " n
if test "$n" -ge 1 -a "$n" -le "$num" 2> /dev/null; then
url=$(echo "$results" | sed -n "${n}p")
name=$(echo $url | awk -F\" '{ print $2}')
url=$(echo $url | awk '{ print $1}')
break
else
echo "Please type a number from 1 to $num."
fi
done
else
name=$(echo $results | awk -F\" '{ print $2 }')
url=$(echo $results | awk '{ print $1 }')
fi
echo
echo $name it is.
echo
if test "$file" = ""; then
echo "No file given."
echo Use \"$name.mp4\"?
read -p "yes/no: " yn
if test "$yn" = "yes" -o "$yn" = "YES" -o "$yn" = "y"; then
name="$name.mp4"
else
echo Aborting.
exit 0
fi
fi
if test "$file" = "debug"; then
echo "URL: $url"
exit 0
fi
ydlw() {
lshift="$2"
file="$3"
youtube-dl -o "$file" --newline --no-warnings "$1" 2> /dev/null | grep --line-buffered "[download]" | grep --line-buffered "% of " | while read line; do
value=$(echo $line | awk '{ print $2 }' | awk -F% '{ print $1}')
steps=40
scaled=$(printf %.0f $(echo $value \* $steps / 100 + 0.5 | bc))
echo -ne "$lshift["
for i in $(seq 1 $steps); do
if test $scaled -ge $i; then
echo -ne \#
else
echo -ne " "
fi
done
echo -ne "] ($value%) \r"
done
if test ${PIPESTATUS[0]} != 0; then
return -1
fi
echo
echo "${lshift}Done."
return 0
}
echo
mirror=1
wget -O - "$url" 2>/dev/null | grep "Version" | awk -F"href" '{ print $2 }' | awk -F\" '{ print $2 }' | while read line; do
echo "Trying mirror $mirror..."
ydlw "$line" " " "$file"
if test $? = 0; then
echo "SUCCESS!"
exit 42
fi
echo " nope"
mirror=$((mirror+1))
done
if test $? = 42; then
exit 0
fi
echo "FAIL!"

137
series-dl Executable file
View file

@ -0,0 +1,137 @@
#!/bin/bash
signalhandler() {
echo
echo "Signal caught."
pkill -TERM -P $$
exit 9
}
trap signalhandler SIGHUP SIGINT SIGTERM
host="http://serienstream.to"
search=$1
echo "Searching for \"$search\"..."
url=$(wget -cO - "$host/serien" 2> /dev/null | grep -B 1 "$search" | grep "/serie/stream/" | awk -F"\"" '{ print $2 }')
if test "$url" = ""; then
echo " Not found."
exit 1
fi
name=$(echo $url | awk -F/ '{ print $4 }')
if test $(echo $name | wc -l) != 1; then
echo name | while read line; do
echo " - $line"
done
exit 0
fi
echo " found $name";
seasons=$(wget -cO - "$host$url" 2> /dev/null | grep "title=\"Staffel" | grep -v "data-episode" | wc -l)
echo
echo "There are $seasons seasons."
season=$2
if test "$season" = "search"; then
exit 0
fi
dls() {
host=$1
url=$2
season=$3
episodes=$(wget -cO - "$host$url/staffel-$season" 2> /dev/null | grep "title=\"Staffel" | grep "data-episode" | wc -l)
echo "Downloading season $season ($episodes episodes)..."
mkdir -p $name/s$season
pushd $name/s$season > /dev/null
for i in $(seq 1 $episodes); do
echo " episode $i ..."
dl $host $url $season $i
if test $? != 0; then
echo " FAILED!"
else
echo " SUCCESS!"
fi
done
popd > /dev/null
echo "Done"
}
ydlw() {
lshift="$2"
file="$3"
youtube-dl -o "$file" --newline --no-warnings "$1" 2> /dev/null | grep --line-buffered "[download]" | grep --line-buffered "% of " | while read line; do
value=$(echo $line | awk '{ print $2 }' | awk -F% '{ print $1}')
steps=40
scaled=$(printf %.0f $(echo $value \* $steps / 100 + 0.5 | bc))
echo -ne "$lshift["
for i in $(seq 1 $steps); do
if test $scaled -ge $i; then
echo -ne \#
else
echo -ne " "
fi
done
echo -ne "] ($value%) \r"
done
if test ${PIPESTATUS[0]} != 0; then
return -1
fi
echo
echo "${lshift}Done."
return 0
}
dl() {
host=$1
url=$2
name=$(echo $url | awk -F/ '{ print $4 }')
season=$3
episode=$4
wget -cO - "$host/$url/staffel-$season/episode-$episode" 2> /dev/null | grep "<a href=\"/out/" | awk -F"\"" '{ print $2; }' | while read link; do
trap "exit 9" SIGINT
ydlw "$host$link" " " "$name-s$season-e$episode.mp4"
if test $? = 0; then
exit 42
fi
echo " nope"
echo " trying next mirror"
done
if test $? = 42; then
return 0;
fi
echo " No suitable download found."
return 1
}
if test "$season" = ""; then
for i in $(seq 1 $seasons); do
dls $host $url $i
done
exit 0
fi
if test "$season" -gt "$seasons"; then
echo "Season $season not found."
exit 2
fi
dls $host $url $season