<?php

class EWRmedio_Services_RuTube extends XenForo_Model
{
	public static function dumpMedia($service, $matches)
	{
		$client = new Zend_Http_Client('http://rutube.ru/api/video/'.$matches['sval1']);
		$feed = $client->request()->getBody();
		$json = json_decode($feed, true);
	
		if (empty($json['id']))
		{
			throw new XenForo_Exception(new XenForo_Phrase('media_url_did_not_retrieve_valid_data'), true);
		}
	
		$media = array(
			'media_value1' => $json['id'],
			'media_value2' => $json['track_id'],
			'media_thumb' => $json['thumbnail_url'],
			'media_title' => $json['title'],
			'media_description' => $json['description'],
			'media_duration' => $json['duration'],
			'media_keywords' => null,
		);
		
		return $media;
	}
}