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

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

url=$(wget -q "$1" -O - | grep addVariable | grep url | cut -d'"' -f4 | sed -e 's/%3A/:/g' -e 's/%2F/\//g' -e 's/%3F/\?/' -e 's/%3D/=/')
filename=$(echo "$1" | sed -e 's/^.*\/\(.*\)$/\1/' | cut -d'_' -f2).flv

echo "$url|$filename"
