Example #1
0
function not_inDB()
{
    $inDB = inDB();
    $inArchive = inArchive();
    $not_inDB = array_diff($inArchive, $inDB);
    foreach ($not_inDB as $toAdd) {
        $ext = substr($toAdd, -3);
        if ($ext != 'php') {
            $data = new mp3Data($toAdd);
            $patch = mysql_escape_string($toAdd);
            $title = mysql_escape_string($data->getTitle());
            $artist = mysql_escape_string($data->getArtist());
            $album = mysql_escape_string($data->getAlbum());
            $genre = mysql_escape_string($data->getGenre());
            $playtime_seconds = mysql_escape_string($data->getPlaytime_seconds());
            $img = $data->getArt();
            if ($img == "") {
                $cover = "";
            } else {
                $cover = $album . ".jpg";
                if (!file_exists("/var/www/system/library/cover/" . $cover)) {
                    imagejpeg($img, "/var/www/system/library/cover/" . $cover);
                    imagedestroy($img);
                }
            }
        } elseif ($ext == "php") {
            $patch = mysql_escape_string($toAdd);
            $title = array_reverse(explode("/", $toAdd));
            $title = $title[0];
            $artist = '';
            $album = 'script';
            $genre = 'system';
            $playtime_seconds = '0';
            $cover = '';
        }
        $toInsert = "INSERT INTO tags (\n\t\t\tpatch,\n\t\t\ttitle,\n\t\t\tartist,\n\t\t\talbum,\n\t\t\tgenre,\n\t\t\tplaytime,\n\t\t\talbumart,\n\t\t\tlastmod\n\t\t\t)\n\t\t\tVALUE (\n\t\t\t'" . $patch . "',\n\t\t\t'" . $title . "',\n\t\t\t'" . $artist . "',\n\t\t\t'" . $album . "',\n\t\t\t'" . $genre . "',\n\t\t\t'" . $playtime_seconds . "',\n\t\t\t'" . $cover . "',\n\t\t\t'" . date("Y-m-d H:i:s", filemtime($toAdd)) . "'\n\t\t\t)";
        #		echo $toInsert."\n";
        mysql_query($toInsert) or die("insert error");
    }
}
Example #2
0
function _pluginChooseRecOrPlay($cid, $gmt = -1, $isVideo = true)
{
    // Please note that all global variables
    // are wiped out! Therefore we have to instantiate
    // a local instance here ....
    // don't break your head about login / logout at kartina!
    // we will load the cookie from file so no authentication
    // is needed here ... we also don't need username and PW ...
    $tmpKartAPI = new kartinaAPI();
    // load cookie ...
    $tmpKartAPI->loadCookie();
    $retMediaItems = array();
    if (($channelList = $tmpKartAPI->getChannelListXml()) !== FALSE) {
        // get channel info ...
        $domChanList = new DOMDocument();
        $domChanList->loadXML($channelList);
        $xpchan = new DOMXpath($domChanList);
        $chanitem = $xpchan->query("/response/groups/item/channels/item[id='" . $cid . "']");
        $chan = $chanitem->item(0);
        // there is only one such item ...
        $recname = $xpchan->query("name", $chan)->item(0)->nodeValue;
        $hasarch = (int) $xpchan->query("have_archive", $chan)->item(0)->nodeValue;
        /////////////////////////////////////////////////////////////////////////////
        // add epg info first ...
        // epg data array ...
        $epg_data = array('cid' => $cid, 'gmt' => $gmt);
        $epg_data_query = http_build_query($epg_data);
        // epg info image ...
        $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($epg_data_query)), 'dc:title' => "Информация", 'upnp:class' => "object.item.imageitem", 'res' => LOC_KARTINA_URL . "/epg2img.php?" . $epg_data_query, 'protocolInfo' => "http-get:*:image/JPEG:DLNA.ORG_PN=JPEG_LRG", 'resolution' => "1920x1080", 'colorDepth' => 24);
        /////////////////////////////////////////////////////////////////////////////
        // play item ...
        // if we have an archive, we can jump backward and forward.
        // To make this accessable, create a new play folder ...
        if ($gmt != -1 && $hasarch && inArchive($gmt, $tmpKartAPI->getLastServerTime())) {
            $data = array('action' => 'play_rewind', 'gmt' => $gmt, 'is_video' => $isVideo, 'cid' => $cid);
            simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Play / Rewind Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ")");
            $dataString = http_build_query($data, "", "&");
            $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . $dataString, 'dc:title' => "Просмотр / Перемотка", 'upnp:class' => 'object.container', 'upnp:album_art' => LOC_KARTINA_URL . "/images/play.png");
        } else {
            if ($gmt == -1) {
                // live stream doesn't allow forward / backward jumping ...
                // play data array ...
                $play_data = array('cid' => $cid, 'gmt' => $gmt, 'is_video' => $isVideo, 'dorec' => false);
                simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Play Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ", dorec=false)");
                $play_data_query = http_build_query($play_data);
                // add play item ...
                $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($play_data_query)), 'dc:title' => "Просмотр", 'upnp:class' => $isVideo ? "object.item.videoitem" : "object.item.audioitem", 'res' => LOC_KARTINA_URL . "/http-stream-recorder.php?" . $play_data_query, 'protocolInfo' => "http-get:*:*:*", 'upnp:album_art' => LOC_KARTINA_URL . "/images/play.png");
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // record entry ...
        if ($gmt == -1 || $hasarch && inArchive($gmt, $tmpKartAPI->getLastServerTime())) {
            // replace some funky characters which could lead to problems ...
            $recname = str_replace(" ", "_", $recname) . "-";
            $recname = str_replace("/", "-", $recname);
            $recname = str_replace("\\", "", $recname);
            // add date ...
            $recname .= $gmt === -1 ? date("d.m.y-H_i", $tmpKartAPI->getLastServerTime()) : date("d.m.y-H_i", $gmt);
            // rec data array ...
            $rec_data = array('cid' => $cid, 'gmt' => $gmt, 'is_video' => $isVideo, 'dorec' => true, 'recfile' => $recname);
            simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Rec Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ", dorec=true, " . "recfile=" . $recname . ")");
            $rec_data_query = http_build_query($rec_data);
            // add record item ...
            $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($rec_data_query)), 'dc:title' => "Запись в "" . $recname . ".ts"", 'upnp:class' => $isVideo ? "object.item.videoitem" : "object.item.audioitem", 'res' => LOC_KARTINA_URL . "/http-stream-recorder.php?" . $rec_data_query, 'protocolInfo' => "http-get:*:*:*", 'upnp:album_art' => LOC_KARTINA_URL . "/images/record.png");
        }
    }
    return $retMediaItems;
}