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

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

data=$(wget -q "$1" -O - | grep flashvars | cut -d'"' -f4 | tr '&' '\n')

url=$(echo "$data" | grep mediaURL | cut -d'=' -f2)
filename=$(echo "$data" | grep normalizedTitle | cut -d'=' -f2).flv

echo "$url|$filename"
