#!/bin/bash headOut() { animeIn=$(echo "$QUERY_STRING" | sed -n 's/^.*anime=\([^&]*\).*$/\1/p') touch ../tmp/tmpShow ../tmp/animeShow wget http://www.crunchyroll.com/"${animeIn}" -O ../tmp/tmpShow sed 1,335d ../tmp/tmpShow > ../tmp/animeShow IFS=$'\n' bgs=($(ls -L ../backgrounds/)) numdirs=${#bgs[@]} index=$(( (( RANDOM % $numdirs ) - 2) + 1 )) if [ -f ./000.jpg ]; then bg="
"; else bg="
"; fi echo ' MiniRoll App '${bg}'

' > ../tmp/list.html main } main() { rm ../tmp/titles ../tmp/imgList sed -n 's/.*title="\([^"]*\).*/\1/p' ../tmp/animeShow > ../tmp/tmptitles sed -n 's/.*src="\([^"]*\).*/\1/p' ../tmp/animeShow > ../tmp/tmpimgList sed -n 's/.*data-thumbnailUrl="\([^"]*\).*/\1/p' ../tmp/animeShow >> ../tmp/tmpimgList sed -n 's/.*media_id="\([^"]*\).*/\1/p' ../tmp/animeShow > ../tmp/mediaIds d=$(cat ../tmp/mediaIds | wc -l) >> /dev/null ; junkCount="1" i="1" while [ $i -le $d ]; do title=$(sed -n "${i}p" ../tmp/tmptitles); if [[ "${title}" == *"Episode"* ]]; then echo "${title}" >> ../tmp/titles else junkCount=$[$junkCount++1]; fi i=$[$i++1]; done i="1" while [ $i -le $d ]; do image=$(sed -n "${i}p" ../tmp/tmpimgList); if [[ "${image}" == *".jpg"* && \ "${image}" != *"_full.jpg"* && \ "${image}" != *"_thumb.jpg"* ]]; then echo "${image}" >> ../tmp/imgList else junkCount=$[$junkCount++1]; fi i=$[$i++1]; done i="1" while [ $i -le $d ]; do title=$(sed -n "${i}p" ../tmp/titles); imgLnk=$(sed -n "${i}p" ../tmp/imgList) meiaID=$(sed -n "${i}p" ../tmp/mediaIds); vdoLnk="http://static.ak.crunchyroll.com/versioned_assets/StandardVideoPlayer.cc7e8515.swf?config_url=http%3A%2F%2Fwww.crunchyroll.com%2Fxml%2F%3Freq%3DRpcApiVideoPlayer_GetStandardConfig%26media_id%3D"$meiaID"video_format%3D106%26video_quality%3D61" echo '

'${title}'
' >> ../tmp/list.html ; i=$[$i++1]; done endOut } endOut() { echo ' ' >> ../tmp/list.html redirect } redirect() { echo "Content-type: text/html" echo "" echo "" echo "" echo "Loading..." echo "" echo "" echo "" echo "
You will be redirected in a few seconds...
" echo "" echo "" echo "" } headOut