Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

enhancement : #28 #29 #33

Merged
merged 2 commits into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2013
  1. change title : issues #28

    authored
  2. purify videos : issue # 29

    authored
This page is out of date. Refresh to see the latest.
Showing with 36 additions and 13 deletions.
  1. +32 −12 fuel/app/classes/controller/stream.php
  2. +4 −1 public/assets/js/player.js
View
44 fuel/app/classes/controller/stream.php
@@ -23,23 +23,22 @@ public function action_index()
$this->template->content->page = $page;
}
- private function _getVideoFromYouTube($anime_title, $category='OP')
+ private function _getVideoFromYouTube($anime_title, $class='OP')
{
- require_once 'HTTP/Request2.php';
- $baseurl = 'http://gdata.youtube.com/feeds/api/videos?alt=json&max-results=1&q=';
- $q = urlencode($anime_title . ' ' . $category);
+ $url = 'http://gdata.youtube.com/feeds/api/videos';
+ $url .= '?alt=json';
+ $url .= '&max-results='.'6';
+ //$url .= '&orderby='.'rating';
+ $url .= '&q='.urlencode($anime_title . ' ' . $class);
+ $url .= '&category='.urlencode('Music');
- $req = new HTTP_Request2($baseurl.$q);
+ require_once 'HTTP/Request2.php';
+ $req = new HTTP_Request2($url);
$res = $req->send();
$rows = json_decode($res->getBody(), true);
- /**
- * choose the best entry : see category term ?= Music or so
- **/
- //{{{
- // TODO
- //}}}
- $info = (array)$rows['feed']['entry'][0];
+
+ $info = $this->_chooseAptYouTubeVideo($rows['feed']['entry']);
$elms = explode('/',$info['id']['$t']);
$vhash = array_pop($elms);
@@ -50,6 +49,27 @@ private function _getVideoFromYouTube($anime_title, $category='OP')
return $return;
}
+ private function _chooseAptYouTubeVideo($list)
+ {
+ foreach($list as $k => $info){
+
+ if(
+ false
+ ){
+ continue;
+ }
+
+ $content_length = $info['media$group']['media$content'][0]['duration'];
+ if(
+ $content_length > 60*7
+ ){
+ continue;
+ }
+
+ return $info;
+ }
+ }
+
private function _getVideoFromSoundCloud($anime_title)
{
View
5 public/assets/js/player.js
@@ -134,9 +134,12 @@ function displayInfo(){
for(var i=0; i<trs.length; i++){
trs[i].setAttribute('class', 'animetr');
}
-
var tr = document.getElementById('index_' + String(__index));
tr.setAttribute('class', 'animetr nowplaying');
+
+ // change title
+ var title = document.getElementsByTagName('title');
+ title[0].innerHTML = __playlist[__index]['atitle'] + ' - あにきゃっち.net';
}
function enableEvaluateBtns(){
Something went wrong with that request. Please try again.