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

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

id=$(wget -q "$1" -O - | grep '"movie"' | sed -e 's/.*id%3D\([0-9]*\).*/\1/')
url=$(wget -q "http://www.flurl.com/play_flash.php?id=$id" -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/.*\/\(.*\)_u_.*$/\1/' -e 's/_*$//').flv

echo "$url|$filename"
