#!/bin/bash
#
# FLVGET Plugin for "LIVEVIDEO" version 1.0
# http://www.livevideo.com/
#
# This plugin is released under GPL free license.
#
# Pablo Chinea <khertz@gmail.com>
#################################################

if [[ $1 == '-q' ]]
then
	echo "FLVGET_PLUGIN|LIVEVIDEO|livevideo.com"
	exit 0
fi

pl=$(wget -q "$1" -O - | grep "\.swf" | tr '>' '\n' | grep GetFlashPlayer | cut -d"'" -f2 | cut -d'=' -f2 | sed -e 's/%3a/:/g' -e 's/%2f/\//g' -e 's/%3f/\?/' -e 's/%3d/=/g' -e 's/%26/\&/g')
url=$(wget -q "$pl" -O - | tr '&' '\n' | grep video_id | cut -d'=' -f2 | sed -e 's/%3a/:/g' -e 's/%2f/\//g' -e 's/%3f/\?/' -e 's/%3d/=/g' -e 's/%26/\&/g')
filename=$(echo "$1" | sed -e 's/.*\/\(.*\)\.aspx/\1/').flv

echo "$url|$filename"
