Deprecated-Unsupported/Python Projects/MiniRoll/resources/cgi-bin/alphaList.cgi

105 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
headOut()
{
touch ../tmp/tmpalphaListing
letterIn=$(echo "$QUERY_STRING" | sed -n 's/^.*letter=\([^&]*\).*$/\1/p')
wget http://www.crunchyroll.com/videos/anime/alpha?group=$letterIn -O ../tmp/tmpalphaListing
sed 1,650d ../tmp/tmpalphaListing > ../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()
{
sed -n 's/.*title="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaTitles
head -n -6 ../tmp/preaTitles > ../tmp/aTitles
sed -n 's/.*src="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/preaImgList
sed -i '/.js/d' ../tmp/preaImgList
sed -i '/.gif/d' ../tmp/preaImgList
cat ../tmp/preaImgList > ../tmp/aImgList
sed -n 's/.*group_id="\([^"]*\).*/\1/p' ../tmp/alphaListing > ../tmp/tmpaGrpIds
head -n -7 ../tmp/tmpaGrpIds > ../tmp/aGrpIds
d=$(cat ../tmp/aGrpIds | wc -l) >> /dev/null ;
i="1"
while [ $i -le $d ]; do
title=$(sed -n "${i}p" ../tmp/aTitles);
imgLnk=$(sed -n "${i}p" ../tmp/aImgList);
groupID=$(sed -n "${i}p" ../tmp/aGrpIds);
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