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

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

id=$(wget -q "$1" -O - | grep "/share/" | sed -e 's/^.*share\/\([0-9]*\).*$/\1/')
url=$(wget -q "http://www.ugoto.com/playvideo.php?cid=$id" -O - | cut -d'&' -f1 | cut -d'=' -f2 | sed -e 's/%3A/:/g' -e 's/%2F/\//g')
filename=$(echo "$url" | sed -e 's/.*\/\(.*\)$/\1/' -e 's/\-.*\././')

echo "$url|$filename"
