示例#1
0
function array_to_json(&$arr)
{
    echo "(";
    if (function_exists("json_encode")) {
        echo json_encode($arr);
    } else {
        $json = new Services_JSON();
        $json->encode($arr);
    }
    echo ")";
}
/* for auto-play-start on empty */
$playlist_empty = false;
$something_added = false;
$json = null;
$pl = get_playlist();
if (!$pl) {
    $v = array("connection" => PF_FAILURE);
    echo array_to_json($v);
    exit;
} else {
    if (isset($_GET['add']) || isset($_GET['ma']) || isset($_GET['searchadd'])) {
        /* for automatic playback start */
        try {
            $s = $pl->getStatus();
            if (isset($s['playlistlength']) && intval($s['playlistlength']) == 0) {
                $playlist_empty = true;
            }
        } catch (PEAR_Exception $e) {
            $v = array("connection" => PF_FAILURE);
            echo array_to_json($v);
示例#2
0
 /**
  * do the basic operation
  *
  * @param <type> $url
  * @return mixed string of url of false
  */
 function init($url)
 {
     /**
      * make the download have no script time limitation. it will excecuted forever
      * if they have to
      */
     ini_set('max_execution_time', 0);
     $vars = end(explode('?', $url));
     $pairs = explode('&', $vars);
     foreach ($pairs as $pair) {
         $var = explode('=', $pair);
         $data[$var[0]] = $var[1];
     }
     if ($data['v'] > 0) {
         $this->download_playlist(get_playlist($url));
         return $url;
     } else {
         $this->video_url = 'http://youtube.com/watch?v=' . $data['v'];
         $this->download_track($this->get_html($this->video_url));
         return $this->video_url;
     }
 }
示例#3
0
function get_playlist($me, $api, $offset = 0)
{
    $all_playlists = $api->getUserPlaylists($me->id, array('offset' => $offset));
    $total = $all_playlists->total;
    foreach ($all_playlists->items as $playlist) {
        if ($playlist->name == 'Play Later') {
            return $playlist;
        }
    }
    if ($offset + 20 <= $total) {
        get_playlist($me, $api, $offset + 20);
    } else {
        return false;
    }
}
            $rowtitles = get_row_titles("playlist");
            // get rows of gd-table playlist
            if (in_array($path_params[2], $rowtitles)) {
                render_result(get_playlist($path_params[1], $path_params[2]), "playlists", $type);
                /* render explicit info of playlist given by id */
            } elseif ($path_params[2] == "tracks") {
                render_result(get_tracklist($path_params[1]), "playlists", $type);
                /* render tracklist from playlist given by id */
            } else {
                render_result(get_playlist($path_params[1]), "playlists", $type);
                /* render all infos of playlist given by id (if wrong info is ordered) */
            }
        } else {
            render_result(get_playlist($path_params[1]), "playlists", $type);
            /* render all infos of playlist given by id */
        }
    } else {
        render_result(get_playlist(), "playlists", $type);
        /* render list of all playlists */
    }
}
/* not implemented yet
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request
	$input = file_get_contents("php://input");
	render_result(create_playlist_entry($input),null,$type); /* create playlist entry */
/*}*/
mysql_close($database);
?>


示例#5
0
<?php

$url = $argv[1];
mkdir('Songs', 0777);
if (strpos($url, 'playlist') !== false) {
    get_playlist($url);
} else {
    if (strpos($url, 'listen') !== false) {
        get_song($url);
    } else {
        echo "Input Parameter incorrect...";
    }
}
echo "Done!";
function get_song($song_url, $path = '/')
{
    $code_length = 7;
    $song_code = substr($song_url, strrpos($song_url, '/') - $code_length, $code_length);
    $song_name = substr($song_url, strrpos($song_url, '/') + 1);
    $ch = curl_init();
    # cURL configuration to get song
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-language' => 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3'));
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
示例#6
0
function view_playlist($playlist_id)
{
    $playlist_link = BASEURL;
    if (is_array($playlist_id) and isset($playlist_id['playlist_id'])) {
        $playlist = $playlist_id;
    } else {
        $playlist = get_playlist($playlist_id);
    }
    if (empty($playlist)) {
        return BASEURL;
    }
    $is_seo = SEO;
    $data = cb_do_action('view_playlist_link', array('playlist' => $playlist, 'seo_enabled' => $is_seo));
    if ($is_seo) {
        $playlist_link .= '/list/' . $playlist['playlist_id'] . '/' . SEO($playlist['playlist_name']);
    } else {
        $playlist_link .= '/view_playlist.php?list=' . $playlist_id;
    }
    $data = cb_do_action('view_playlist_link', array('playlist' => $playlist, 'seo_enabled' => $is_seo, 'playlist_link' => $playlist_link));
    if ($data) {
        return $data;
    }
    return $playlist_link;
}
示例#7
0
<?php

/*
 ******************************************************************
 | Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
 | @ Author : ArslanHassan
 | @ Software : ClipBucket , © PHPBucket.com
 *******************************************************************
*/
define('THIS_PAGE', 'view_playlist');
define('PARENT_PAGE', 'videos');
require 'includes/config.inc.php';
$pages->page_redir();
$list_id = mysql_clean($_GET['list_id']);
$playlist = get_playlist($list_id);
if (is_playlist_viewable($playlist) and isset($playlist)) {
    $items = get_playlist_items($list_id);
    if (!empty($items)) {
        $playlist['videos'] = $items;
    }
    cb_do_action('view_playlist', array('playlist' => $playlist));
    assign('playlist', $playlist);
    subtitle($playlist['playlist_name']);
} else {
    $Cbucket->show_page = false;
}
//Displaying The Template
template_files('view_playlist.html');
display_it();
示例#8
0
        //What we are getting
        $server_link = $_SERVER['REQUEST_URI'];
        $server_link_seo = explode('/', $server_link);
        $server_link_seo = $server_link_seo[count($server_link_seo) - 1];
        //Now finally Checking if both are equal else redirect to new link
        if ($vid_link_seo != $server_link_seo) {
            /*//Redirect to valid link leaving mark 301 Permanent Redirect
            		header ('HTTP/1.1 301 Moved Permanently');
             			header ('Location: '.$vid_link);
            		exit();*/
        }
    }
    //Checking for playlist
    $pid = $_GET['play_list'];
    if (!empty($pid)) {
        $plist = get_playlist($pid);
        if ($plist) {
            assign('playlist', $plist);
        }
    }
    //Calling Functions When Video Is going to play
    call_watch_video_function($vdo);
    subtitle($vdo['title']);
} else {
    $Cbucket->show_page = false;
}
//Return category id without '#'
$v_cat = $vdo['category'];
if ($v_cat[2] == '#') {
    $video_cat = $v_cat[1];
} else {
示例#9
0
function get_recommendations_from_playlist()
{
    require_once "../player/openstrands.php";
    $pl = get_playlist();
    $list = $pl->getPlaylistInfo();
    $artist = array();
    foreach ($list as $song) {
        if (isset($song['Artist']) && $song['Artist']) {
            $artist[$song['Artist']] = true;
        }
    }
    $artist = array_keys(array_change_key_case($artist));
    $pl->disconnect();
    header("Content-Type: text/xml; charset=UTF-8");
    $ret = strands_get_recommendations($artist);
    $res = array();
    if (!$ret || !count($ret)) {
        $res['result'] = is_array($ret) ? "notfound" : "failed";
        echo array_to_xml($res)->asXML();
        exit;
    }
    $db = get_database();
    foreach ($ret as $a) {
        $tmp = array();
        $tmp['name'] = $a;
        $tmp['album'] = $db->getMetadata("Album", "Artist", $a);
        $res[] = $tmp;
    }
    $out = array("result" => $res);
    $db->disconnect();
    echo array_to_xml($out)->asXML();
}