Deprecated-Unsupported/Python Projects/other/MiniRoll/resources/cgi-bin/getVideo.cgi

130 lines
3.8 KiB
Plaintext
Raw Permalink Normal View History

2021-02-18 23:45:52 +00:00
#!/bin/bash
headOut()
{
letterIn=$(echo "$QUERY_STRING" | sed -n 's/^.*letter=\([^&]*\).*$/\1/p')
touch ../tmp/alphaListing
wget http://www.crunchyroll.com/videos/anime/alpha?group=$letterIn -O ../tmp/alphaListing
IFS=$'\n'
bgs=($(ls -L ../backgrounds/))
numdirs=${#bgs[@]}
index=$(( (( RANDOM % $numdirs ) - 2) + 1 ))
if [ -f ./000.jpg ]; then
bg="<div id="bg"><img src="./000.jpg"/></div>";
else
bg="<div id="bg"><img src="\"../backgrounds/${bgs[index]}"\"/></div>";
fi
echo '<!doctype html>
<html lang="en">
<head>
<title>MiniRoll App</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../themes/bodyCss.css" type="text/css">
<link rel="stylesheet" href="../themes/menuCss.css" type="text/css">
</head>
<body>
'${bg}'
<center>
<ul><a href="../index.html"><li>Home</li></a>
<li>
Layout
<ul>
<a href="../cgi-bin/listOnLeftTheme.cgi"><li>List On The Left</li></a>
<a href="../cgi-bin/gridTheme.cgi"><li>Grid</li></a>
<a href="../cgi-bin/centerList.cgi"><li>List Centered</li></a>
</ul>
</li>
<li>About</li>
<a href="../cgi-bin/quit.cgi"><li>Quit</li></a>
<a href="#" onclick="location.reload(true); return false;"><li>Refresh</li></a>
</ul>
</center>
<br>
' > ../tmp/alist.html
main
}
main()
{
if [[ -f ../tmp/preaTitles.txt && -f ../tmp/preaImgList.txt && -f ../tmp/aTitles.txt && -f ../tmp/aImgList.txt && -f ../tmp/aMediaIds.txt ]]
then
touch ../tmp/preaTitles.txt ;
touch ../tmp/preaImgList.txt ;
touch ../tmp/aTitles.txt ;
touch ../tmp/aImgList.txt ;
touch ../tmp/aMediaIds.txt ;
sed -n 's/.*title="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaTitles.txt
sed -n 's/.*src="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaImgList.txt
sed -n 's/.*group_id="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/aMediaIds.txt
else
sed -n 's/.*title="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaTitles.txt
sed -n 's/.*src="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaImgList.txt
sed -n 's/.*group_id="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/aGrpIds.txt
fi
d=$(cat ../tmp/aGrpIds.txt | wc -l) >> /dev/null ;
i="1"
while [ $i -le $d ]; do
title=$(sed -n "${i}p" ../tmp/preaTitles.txt);
imgLnk=$(sed -n "${i}p" ../tmp/preaImgList.txt);
if [[ "$imgLnk" == *".jpg"* ]]
then
echo "$imgLnk" >> ../tmp/aImgList.txt
else
echo "Not an img..."
fi
if [[ "$title" == *"Spring"* || "$title" == *"Summer"* \
|| "$title" == *"Fall"* || "$title" == *"Winter"* ]]
then
echo "Not a title..."
else
echo "$title" >> ../tmp/aTitles.txt ;
fi
i=$[$i++1];
done
i="1";
while [ $i -le $d ]; do
title=$(sed -n "${i}p" ../tmp/aTitles.txt);
imgLnk=$(sed -n "${i}p" ../tmp/aImgList.txt);
groupID=$(sed -n "${i}p" ../tmp/aGrpIds.txt);
vdoLnk="http://www.crunchyroll.com/swf/StandardVideoPlayer.swf?config_url=http%3A%2F%2Fwww.crunchyroll.com%2Fxml%2F%3Freq%3DRpcApiVideoPlayer_GetStandardConfig%26media_id%3D"$groupID""
echo '
<div class="lnksNdirs">
<a target="frame" href="'${vdoLnk}'" style="color:#00E8FF;">
<img src="'${imgLnk}'" /> <br>
'${title}'</a>
</div>' >> ../tmp/alist.html ;
i=$[$i++1];
done
endOut
}
endOut()
{
echo '
<iframe id="frame" name="frame" frameborder="0" class="iframer"></iframe>
</body>
</html>' >> ../tmp/alist.html
redirect
}
redirect()
{
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<head>"
echo "<title>Loading...</title>"
echo "<meta http-equiv='refresh' content='1;URL=../tmp/alist.html'>"
echo "</head>"
echo "<body style='background-color:#000000'>"
echo "<center>
<font color='#FFFFFF'>You will be redirected in a few seconds...</font>
<img style='width:30em;height:30em;margin-left:50%;margin-top:15%;' src='../icons/loading.gif'></img>"
echo "</center>"
echo "</body>"
echo "</html>"
}
headOut