proxyraye/gen.sh

84 lines
3.2 KiB
Bash
Raw Permalink Normal View History

2021-02-08 08:52:15 +00:00
#!/usr/bin/env sh
if [ -z "$1" ]; then
echo 'Wrong usage'
echo 'Do not run this file directly'
exit 1
fi
[ -e 'input.html' ] && rm 'input.html'
[ -e 'output.html' ] && rm 'output.html'
HTML_START="$(cat 'res/html_start')"
2023-01-28 18:03:00 +00:00
HTML_SEARCH='<form id="search" method="get" action="/"><input id="searchText" type="text" size="30" name="k" /><input id="searchButton" type="submit" value="Cerca" /></form>'
2023-01-28 18:22:56 +00:00
HTML_TOGGLER='<fieldset class="mobileResultToggler"><label for="remember"><input type="checkbox" role="switch" id="resToggler" name="resToggler">Mostra anteprime risultati</label></fieldset>'
2021-02-08 08:52:15 +00:00
HTML_END="$(cat 'res/html_end')"
HTML_STYLE="$(cat 'res/css.css')"
HTML_VIDEO=''
wget "https://www.xvideos.com$1" -O 'input.html'
echo "$1" | grep '^/video'
if [ $? = 0 ]; then
str="$(grep 'video_related=' 'input.html' | sed 's/,/\n/g')"
video="$(grep 'setVideoUrlHigh' 'input.html' | cut -d"'" -f2)"
2021-05-16 21:23:45 +00:00
video_low="$(grep 'setVideoUrlLow' 'input.html' | cut -d"'" -f2)"
if [ -z "$video" ]; then
video="$video_low"
fi
2021-02-08 08:52:15 +00:00
grep 'video-hd-mark' 'input.html'
if [ "$?" -eq 0 ]; then
video_hls="$(grep 'setVideoHLS' 'input.html' | cut -d"'" -f2)"
else
video_hls=''
fi
video_thumb="$(grep 'setThumbUrl' 'input.html' | cut -d"'" -f2 | sed 1q)"
thumbs="$(echo "$str" | grep '"i":' | sed 's/\\//g' | sed 's/"i"://g' | sed 's/"//g')"
urls="$(echo "$str" | grep '"u":' | sed 's/\\//g' | sed 's/"u"://g' | sed 's/"//g')"
2023-01-28 17:31:05 +00:00
HTML_VIDEO="<div id='videoWrapper'><video poster='$video_thumb' controls autoplay loop><source src='$video'/></video></div><div id='infoblock'>"
2021-02-08 08:52:15 +00:00
if [ ! -z "$video_hls" ]; then
2023-01-28 17:31:05 +00:00
HTML_VIDEO="$HTML_VIDEO<div id='infoblock'><h3>HD Stream: </h3><fieldset><input id='textLinkField' type='text' size='50' value='$video_hls'><input class='outline' id='copyLinkButton' type='submit' value='Copia link' /></fieldset><span>(incollalo dentro a VLC o simili)</span></div>"
2021-02-08 08:52:15 +00:00
fi
2023-01-28 17:31:05 +00:00
HTML_VIDEO="$HTML_VIDEO</div><hr />"
2021-02-08 08:52:15 +00:00
else
urls="$(grep -E -o '<div class="thumb"><a href="(.*)">' 'input.html' | cut -d'"' -f4)"
thumbs="$(echo "$i" | grep -E -o 'data-src="(.*)"' 'input.html' | cut -d'"' -f2)"
fi
echo "$thumbs" > thumbs.txt
echo "$urls" > urls.txt
echo "$HTML_START" >> output.html
2023-01-28 18:03:00 +00:00
if ["$HTML_VIDEO" != '']; then
echo "$HTML_SEARCH" >> output.html
echo "$HTML_TOGGLER" >> output.html
else
echo "$HTML_VIDEO" >> output.html
echo "$HTML_SEARCH" >> output.html
echo "$HTML_TOGGLER" >> output.html
fi
2023-01-28 17:31:05 +00:00
echo "<section class='transparentResults'>" >> output.html
2021-02-08 08:52:15 +00:00
for i in $(seq "$(wc -l urls.txt | cut -d' ' -f1)"); do
url="$(tail -n "+$i" urls.txt | sed 1q)"
2021-02-08 08:52:15 +00:00
title="$(echo "$url" | cut -d'/' -f5 | sed 's/_/ /g')"
if [ -z "$title" ]; then
title="$(echo "$url" | cut -d'/' -f3 | sed 's/_/ /g')"
fi
if [ "$title" = "THUMBNUM" ]; then
title="$(echo "$url" | cut -d'/' -f4 | sed 's/_/ /g')"
fi
thumb="$(tail -n "+$i" thumbs.txt | sed 1q | sed 's/THUMBNUM/1/g')"
2023-01-28 17:31:05 +00:00
echo "<div class='thumbnailWrapper'><a class='thumbnailLink' href='$url'><img class='thumbnailImg' src='$thumb'/><span class='thumbnailText'>$title</span></a></div>" >> output.html
2021-02-08 08:52:15 +00:00
done
2021-09-28 15:04:10 +00:00
echo "</section>" >> output.html
2021-09-28 15:04:10 +00:00
echo "<style>" >> output.html
2021-02-08 08:52:15 +00:00
echo "$HTML_STYLE" >> output.html
2021-09-28 15:04:10 +00:00
echo "</style>" >> output.html
2021-02-08 08:52:15 +00:00
echo "$HTML_END" >> output.html
rm 'thumbs.txt' 'urls.txt' 'input.html'