time = $_time; $this->videourl = $_videourl; $this->imageurl = $_imageurl; $this->title = $_title; if ($_title != null) { $path = "amazoncache/".md5($_title); if (file_exists($path)) { $this->imageurl = file_get_contents($path); } else { $parser = xml_parser_create(); xml_parse_into_struct($parser, file_get_contents("http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&Version=2007-10-29&Operation=ItemSearch&AssociateTag=amarok-20&AWSAccessKeyId=0N04TFAWZR6YVWWS3CG2&SearchIndex=DVD&ResponseGroup=Images&Keywords=".urlencode($_title)), $values, $index); xml_parser_free($parser); $this->imageurl = $values[$index["MEDIUMIMAGE"][0] + 1]["value"]; @mkdir("amazoncache"); file_put_contents($path, $this->imageurl); } if ($this->imageurl == "") $this->imageurl = "http://".$_SERVER["SERVER_NAME"]."/nothumb.png"; } else $this->imageurl = "http://".$_SERVER["SERVER_NAME"]."/nothumb.png"; } public function prettyTime() { $ret = (int)($this->time / 60).':'; $mod = (int)($this->time % 60); if ($mod < 10) $ret .= "0"; $ret .= $mod; return $ret; } public function isClip() { return $this->time != null; } public function hasImage() { return $this->imageurl != null; } } if ($_GET["password"] != "boxeeclip") exit; if ($_GET["type"] == "login") { echo "success"; exit; } require_once("api.php"); $api = new AnyClip("47ff842f-2eed-4715-9520-741e43342c8b"); $isMore = false; $isLess = false; define("PERPAGE", 20); if (!isset($_GET["start"])) $_GET["start"] = 0; function constructBackForward($list, $params) { global $isMore; global $isLess; if ($list->TotalItemCount > (intval($_GET["start"]) + PERPAGE)) $isMore = $_SERVER["SCRIPT_URI"]."?start=".(intval($_GET["start"]) + PERPAGE)."&".$params; if (intval($_GET["start"]) > 0) $isLess = $_SERVER["SCRIPT_URI"]."?start=".(intval($_GET["start"]) - PERPAGE)."&".$params; } function titleQuery($titles, $params) { global $videoArray; constructBackForward($titles, $params); if (count($titles->Items) > 0) foreach ($titles->Items as $title) $videoArray[] = new Video( $_SERVER["SCRIPT_URI"]."?type=clips&videocode=".$title->Code."&password=".$_GET["password"], null, $title->Thumbnails[0]->URL, $title->Name ); } function clipQuery($clips, $params) { global $videoArray; constructBackForward($clips, $params); if (count($clips->Items) > 0) foreach ($clips->Items as $clip) { $tagImplosion = ""; for ($i = 0; $i < count($clip->Tags); $i++) { if ($i > 0) $tagImplosion .= ", "; $tagImplosion .= $clip->Tags[$i]->Name; } $videoArray[] = new Video( "http://api.anyclip.com/?code=".$clip->Code."&autoPlay=true", intval(round((intval($clip->TimeOut) - intval($clip->TimeIn)) / 1000)), $clip->Thumbnails[0]->URL, $tagImplosion ); } } if ($_GET["type"] == "latest") titleQuery($api->titles(intval($_GET["start"]), PERPAGE) /*TODO: Until latest implemented on API side*/, "type=latest"); elseif ($_GET["type"] == "popular") titleQuery($api->titles(intval($_GET["start"]), PERPAGE) /*TODO: Until popular implemented on API side*/, "type=popular"); elseif ($_GET["type"] == "genre") titleQuery($api->titlesForGenre($_GET["genre"], intval($_GET["start"]), PERPAGE), "type=genre&genre=".$_GET["genre"]); elseif ($_GET["type"] == "search") clipQuery($api->searchClips($_GET["query"], intval($_GET["start"]), PERPAGE), "type=search&query=".$_GET["query"]); elseif ($_GET["type"] == "clips") clipQuery($api->clipsForTitle($_GET["videocode"], intval($_GET["start"]), PERPAGE), "type=clips&videocode=".$_GET["videocode"]); elseif ($_GET["type"] == "genres") { $genres = $api->genres(); if (count($genres->Items) > 0) foreach ($genres->Items as $genre) $videoArray[] = new Video($_SERVER["SCRIPT_URI"]."?type=genre&genre=".$genre->ID."&password=".$_GET["password"], null, null, $genre->Name); } header("Content-Type: text/xml; charset=UTF-8"); $doc = new DOMDocument(); $doc->encoding = "UTF-8"; $rss = $doc->createElement("rss"); $rss->appendChild(new DOMAttr("version", "2.0")); $rss->appendChild(new DOMAttr("xmlns:boxee", "http://boxee.tv/rss")); $rss->appendChild(new DOMAttr("xmlns:media", "http://search.yahoo.com/mrss/")); $channel = $doc->createElement("channel"); $node = $doc->createElement("title"); $node->appendChild($doc->createTextNode("AnyClip")); $channel->appendChild($node); $node = $doc->createElement("description"); $node->appendChild($doc->createTextNode("-")); $channel->appendChild($node); $node = $doc->createElement("language"); $node->appendChild($doc->createTextNode("en-us")); $channel->appendChild($node); if (count($videoArray) > 0) { foreach ($videoArray as $video) { $item = $doc->createElement("item"); $node = $doc->createElement("title"); $node->appendChild($doc->createTextNode($video->title)); $item->appendChild($node); if ($video->hasImage()) { $node = $doc->createElement("media:thumbnail"); $node->appendChild(new DOMAttr("url", $video->imageurl)); $item->appendChild($node); } $node = $doc->createElement("link"); if ($video->isClip()) { $node->appendChild($doc->createTextNode( "flash://www.anyclip.com/". "src=".urlencode($video->videourl). "&width=1280&height=720&bx-jsactions=".urlencode("http://".$_SERVER["SERVER_NAME"]."/flashcontroller.js") )); } else { $node->appendChild($doc->createTextNode(str_ireplace("http", "rss", $video->videourl))); } $item->appendChild($node); if ($video->isClip()) { $node = $doc->createElement("boxee:runtime"); $node->appendChild($doc->createTextNode($video->prettyTime())); $item->appendChild($node); $node = $doc->createElement("boxee:property"); $node->appendChild(new DOMAttr("name", "custom:duration")); $node->appendChild($doc->createTextNode($video->prettyTime())); $item->appendChild($node); } $node = $doc->createElement("boxee:property"); $node->appendChild(new DOMAttr("scheme", "urn:boxee:source")); $node->appendChild($doc->createTextNode("AnyClip")); $item->appendChild($node); $channel->appendChild($item); } } if ($isLess !== false) { $item = $doc->createElement("item"); $node = $doc->createElement("title"); $node->appendChild($doc->createTextNode("Previous 20")); $item->appendChild($node); $node = $doc->createElement("media:thumbnail"); $node->appendChild(new DOMAttr("url", "http://".$_SERVER["SERVER_NAME"]."/back.png")); $item->appendChild($node); $node = $doc->createElement("link"); $node->appendChild($doc->createTextNode(str_ireplace("http", "rss", $isLess)."&password=".$_GET["password"])); $item->appendChild($node); $node = $doc->createElement("boxee:property"); $node->appendChild(new DOMAttr("scheme", "urn:boxee:source")); $node->appendChild($doc->createTextNode("AnyClip")); $item->appendChild($node); $channel->appendChild($item); } if ($isMore !== false) { $item = $doc->createElement("item"); $node = $doc->createElement("title"); $node->appendChild($doc->createTextNode("Next 20")); $item->appendChild($node); $node = $doc->createElement("media:thumbnail"); $node->appendChild(new DOMAttr("url", "http://".$_SERVER["SERVER_NAME"]."/next.png")); $item->appendChild($node); $node = $doc->createElement("link"); $node->appendChild($doc->createTextNode(str_ireplace("http", "rss", $isMore)."&password=".$_GET["password"])); $item->appendChild($node); $node = $doc->createElement("boxee:property"); $node->appendChild(new DOMAttr("scheme", "urn:boxee:source")); $node->appendChild($doc->createTextNode("AnyClip")); $item->appendChild($node); $channel->appendChild($item); } $rss->appendChild($channel); $doc->appendChild($rss); $output = @$doc->saveXML(); header("Content-Length: ".strlen($output)); echo $output; exit; ?>