FAQ  •  Register  •  Login

serviidb.com

<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Tue Apr 10, 2012 10:27 am

Re: serviidb.com

You still have some strange usage/mix of array [] brackets and {} brackets in the wrong places.

Use the following for now as it will require the minimum amount of patching at the client end, I'll try and have a look at your code/library sometime this week to work out a better comprimise.

  Code:
{"Resource":"video","returnedSize":2,"totalSize":60}[{"show":"Blip TV Photoshop Users TV","region":"UK","url":"http:\/\/blip.tv\/photoshop-user-tv\/rss","resourceType":"RSS \/ Atom feed","plugin":"Blip TV"},{"show":"TV Highlights","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"}]
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Tue Apr 10, 2012 10:32 am

Re: serviidb.com

I think I can clean it up somemore when I get home.

Sent from my DROID RAZR using Tapatalk
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Tue Apr 10, 2012 5:26 pm

Re: serviidb.com

I thought I posted this this morning, but must have been to asleep to hit submit.

how is this?

  Code:
[{"Resource":"video","requestedSize":2,"totalSize":60},"items",{"show":"Blip TV Photoshop Users TV","region":"UK","url":"http:\/\/blip.tv\/photoshop-user-tv\/rss","resourceType":"RSS \/ Atom feed","plugin":"Blip TV"},{"show":"TV Highlights","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"}]


  Code:
[
    {
        "Resource": "video",
        "requestedSize": 2,
        "totalSize": 60
    },
    "items",
    {
        "show": "Blip TV Photoshop Users TV",
        "region": "UK",
        "url": "http://blip.tv/photoshop-user-tv/rss",
        "resourceType": "RSS / Atom feed",
        "plugin": "Blip TV"
    },
    {
        "show": "TV Highlights",
        "region": "UK",
        "url": "http://feeds.bbc.co.uk/iplayer/highlights/tv",
        "resourceType": "RSS / Atom feed",
        "plugin": "iPlayer (UK)"
    }
]
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Wed Apr 11, 2012 7:38 am

Re: serviidb.com

It is still not valid once you remove the miss placed start and end [ ] brackets. What you have done is build an array containing 4 blocks, the header info, the word items, and the first two (as seperate blocks) videos. At a minimum, the video items should be in their own array. Ideally, they should be a child of the header info, alternatively, the header info and video array could be child elements, but that is a little odd.


Could you commit your recent changes. looking at the current code, you will have to build the json parts bit by bit (json_encode($result) on the video array and add the resuling string the the header info), or add them to a more structured object before encoding them to json (or xml) in one go (which would be best for making xml building easy). At the moment, the library is acting as everything is in one big array togher, which it is not.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Wed Apr 11, 2012 7:47 am

Re: serviidb.com

All commits should be in the repository. I made the commits this afternoon, before I came to work.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Wed Apr 11, 2012 8:03 am

Re: serviidb.com

I took the front matter out and got this result.

  Code:
[{"show":"Blip TV Photoshop Users TV","region":"UK","url":"http:\/\/blip.tv\/photoshop-user-tv\/rss","resourceType":"RSS \/ Atom feed","plugin":"Blip TV"},{"show":"TV Highlights","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"Popular TV","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/popular\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"CBeebies","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/cbeebies\/list","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"Coppers","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/coppers\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Big Fat Gypsy Weddings","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/big-fat-gypsy-weddings\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"90210","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/90210\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Skins","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/skins\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Shameless","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/shameless\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"New Girl","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/new-girl\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"}]
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Wed Apr 11, 2012 8:34 am

Re: serviidb.com

another way

  Code:
[["TV Highlights","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","RSS \/ Atom feed","iPlayer (UK)"],["Popular TV","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/popular\/tv","RSS \/ Atom feed","iPlayer (UK)"],["CBeebies","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/cbeebies\/list","RSS \/ Atom feed","iPlayer (UK)"],["Coppers","UK","http:\/\/www.channel4.com\/programmes\/coppers\/4od","Web Resource","4oD (UK)"],["Big Fat Gypsy Weddings","UK","http:\/\/www.channel4.com\/programmes\/big-fat-gypsy-weddings\/4od","Web Resource","4oD (UK)"],["90210","UK","http:\/\/www.channel4.com\/programmes\/90210\/4od","Web Resource","4oD (UK)"],["Skins","UK","http:\/\/www.channel4.com\/programmes\/skins\/4od","Web Resource","4oD (UK)"],["Shameless","UK","http:\/\/www.channel4.com\/programmes\/shameless\/4od","Web Resource","4oD (UK)"],["New Girl","UK","http:\/\/www.channel4.com\/programmes\/new-girl\/4od","Web Resource","4oD (UK)"]]
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Wed Apr 11, 2012 8:41 am

Re: serviidb.com

moltra wrote:another way

  Code:
[["TV Highlights","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","RSS \/ Atom feed","iPlayer (UK)"],["Popular TV","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/popular\/tv","RSS \/ Atom feed","iPlayer (UK)"],["CBeebies","UK","http:\/\/feeds.bbc.co.uk\/iplayer\/cbeebies\/list","RSS \/ Atom feed","iPlayer (UK)"],["Coppers","UK","http:\/\/www.channel4.com\/programmes\/coppers\/4od","Web Resource","4oD (UK)"],["Big Fat Gypsy Weddings","UK","http:\/\/www.channel4.com\/programmes\/big-fat-gypsy-weddings\/4od","Web Resource","4oD (UK)"],["90210","UK","http:\/\/www.channel4.com\/programmes\/90210\/4od","Web Resource","4oD (UK)"],["Skins","UK","http:\/\/www.channel4.com\/programmes\/skins\/4od","Web Resource","4oD (UK)"],["Shameless","UK","http:\/\/www.channel4.com\/programmes\/shameless\/4od","Web Resource","4oD (UK)"],["New Girl","UK","http:\/\/www.channel4.com\/programmes\/new-girl\/4od","Web Resource","4oD (UK)"]]

All that is is an array of an array of strings and I couldn't parse it without a lot of effort and assumptions about the data
moltra wrote:
  Code:
[{"show":"Blip TV Photoshop Users TV","region":"UK","url":"http:\/\/blip.tv\/photoshop-user-tv\/rss","resourceType":"RSS \/ Atom feed","plugin":"Blip TV"},{"show":"TV Highlights","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"Popular TV","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/popular\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"CBeebies","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/cbeebies\/list","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"},{"show":"Coppers","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/coppers\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Big Fat Gypsy Weddings","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/big-fat-gypsy-weddings\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"90210","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/90210\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Skins","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/skins\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"Shameless","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/shameless\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"},{"show":"New Girl","region":"UK","url":"http:\/\/www.channel4.com\/programmes\/new-girl\/4od","resourceType":"Web Resource","plugin":"4oD (UK)"}]

This is correct, although it still ideally needs to be combined with the header info.

Just looking on https://bitbucket.org/moltra/serviidb-api/changesets, I can only see your commit from 3 days ago.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Wed Apr 11, 2012 8:51 am

Re: serviidb.com

something must have happened after I hit commit. I was getting ready for work and did not look at it again.

TaskDataManager.php file
  Code:
<?php

class TaskDataManager {

  public static function get($taskId, $format, $region, $title, $client, $num, $start) {
  echo $taskid . "\n";

  //Connect To Database
$hostname='.hostedresource.com';
$username='username';
$password='password';
$dbname='username';


  mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
  mysql_select_db($dbname);

$region= htmlspecialchars($region);
   $region=mysql_real_escape_string($region);
   $title= htmlspecialchars($title);
   $title= mysql_real_escape_string($title);
   $client= htmlspecialchars($client);
   $client=mysql_real_escape_string($client);

   //Verify that $num is not null and sets it to an interger. If it is null it is set to 10
$num = ( isset( $_GET['num']) && is_numeric( $_GET['num'] ) ) ? intval( $_GET['num'] ) : 10;
   //Verify that $start is not null and sets it to an interger. If it is null it is set to 0


$start = ( isset( $_GET['start'] ) && is_numeric( $_GET['start'] ) ) ? intval( $_GET['start'] ) : 0;
   
$format = ( isset( $_GET[`format`] )) ? htmlspecialchars( $_GET[`format`] ):"json";

//echo "start : " . $start . " Num : " .$num . "<br />";





  //echo 'taskid: ' . $taskId . "\n";

     Switch ($taskId) {
    Case 'plugin':
    //echo $input . "\n";
    $plgnsqlcount = 'SELECT taxonomy_term_data.name as name, field_revision_field_revision.field_revision_value as revision, file_managed.uri as url'
        . ' FROM taxonomy_term_data '
        . ' left join field_data_field_plugins on taxonomy_term_data.tid = field_data_field_plugins.field_plugins_tid '
        . ' left join field_revision_field_revision on field_revision_field_revision.revision_id = field_data_field_plugins.revision_id '
        . ' left join file_usage on field_data_field_plugins.entity_id = file_usage.id'
        . ' left join file_managed on file_usage.fid = file_managed.fid'
        . ' WHERE (field_data_field_plugins.bundle ="plugin")';
        //. ' ORDER BY weight LIMIT ' . $start.' , '.$num;
//echo $plgnsqlcount . "<br />";

// count returned rows in dataset
$resultcount=mysql_query($plgnsqlcount);
$count=mysql_num_rows($resultcount);
//echo $count . "<br />";

if ($num==0){
$num=$count;
}
//echo $num . "<br />";

$plgnsql=$plgnsqlcount .' ORDER BY weight LIMIT ' . $start.' , '.$num;


//echo $plgnsql;
    // Query Database
    $result = mysql_query($plgnsql);
//echo $result . "\n";
    // convert database array into local array
    $data = mysql_fetch_rowsarr($result,$taskId,$num,$count);
    // save local array
    //$response=$data;
//print_r($data);
    return $data;
    break;

    case 'video':

//echo "start : " . $start . " Num : " .$num . "<br />";

    //setup sql for video / title search.
    $sqlregion = "";
    $sqltitle = "";
//echo $region . "<br />";
$sqlregion = 'and (taxonomy_term_data.name = "worldwide" or ';
//echo $sqlregion . "<br />";

$sqlregion = $sqlregion . 'taxonomy_term_data.name like ';
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "'%";
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . $region;
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "%')";
//echo $sqlregion . "<br />";

//.$region. "%'")';

//echo $sqlregiontemp . "<br />";

//echo $title . "<br />";
    if (isset($title) && !is_null($title)) {
      $sqltitle = "and node.title like '%" .$title . "%'";
    }
//echo $sqltitle; "<br />";
    $videosqlcount = 'SELECT node.title as "show", taxonomy_term_data.name as region, field_data_field_url.field_url_value as url, '
.' repositoryType.repositoryType as resourceType, plugins.plugin'
        .' FROM node'
        .' left join field_data_field_region on field_data_field_region.revision_id=node.vid'
        .' left join taxonomy_term_data on taxonomy_term_data.tid=field_data_field_region.field_region_tid'
        .' left join field_data_field_url on field_data_field_url.revision_id = node.vid'
        .' left join field_data_field_plugins on field_data_field_plugins.revision_id=node.vid'
        .' left join field_data_field_media_source  on field_data_field_media_source.revision_id = node.vid'
        .' left join repositoryType on repositoryType.tid=field_data_field_media_source.field_media_source_tid'
        .' left join plugins on plugins.tid=field_data_field_plugins.field_plugins_tid'
        .' left join field_data_field_media_type on field_data_field_media_type.revision_id = node.vid'
        .' left join media_type on media_type.tid = field_data_field_media_type.field_media_type_tid'
        .' WHERE node.status<>0 and node.type="media_recourse"'
        .' and media_type.media_type ="video"'
        .$sqltitle
        .$sqlregion;


     //echo $videosqlcount . "<br />";
//echo "<br />";


// count returned rows in dataset
$resultcount=mysql_query($videosqlcount);
$count=mysql_num_rows($resultcount);
//echo $count . "<br />";

if ($num==0){
$num=$count;
}
//echo $num . "<br />";

$videosql=$videosqlcount .' ORDER BY weight LIMIT ' . $start.' , '.$num;
    // Query Database
//echo "<br />";

//echo $videosql . "<br />";


    $result = mysql_query($videosql);
    //echo $result . "\n";
    // convert database array into local array
//echo '[{"returnedSize":'.$num.',"totalSize":'.$count.'}]';
    $data = mysql_fetch_rowsarr($result,$taskId,$num,$count);
    // save local array
    //$response=$data;
//print_r($data);
//echo "<br />";

 //print_r(json_encode($data,JSON_FORCE_OBJECT));
//echo "<br />";

    return $data;
    break;

    Case 'user':
     $data='not developed yet';
     return $data;
    Break;

    Case 'audio';
    //echo "start : " . $start . " Num : " .$num . "<br />";

    //setup sql for audio / title search.
    $sqlregion = "";
    $sqltitle = "";
//echo $region . "<br />";
$sqlregion = 'and (taxonomy_term_data.name = "worldwide" or ';
//echo $sqlregion . "<br />";

$sqlregion = $sqlregion . 'taxonomy_term_data.name like ';
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "'%";
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . $region;
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "%')";
//echo $sqlregion . "<br />";

//.$region. "%'")';

//echo $sqlregiontemp . "<br />";

//echo $title . "<br />";
    if (isset($title) && !is_null($title)) {
      $sqltitle = "and node.title like '%" .$title . "%'";
    }
//echo $sqltitle; "<br />";
    $audiosqlcount = 'SELECT node.title as "show", taxonomy_term_data.name as region, field_data_field_url.field_url_value as url, '
.' repositoryType.repositoryType as resourceType, plugins.plugin'
        .' FROM node'
        .' left join field_data_field_region on field_data_field_region.revision_id=node.vid'
        .' left join taxonomy_term_data on taxonomy_term_data.tid=field_data_field_region.field_region_tid'
        .' left join field_data_field_url on field_data_field_url.revision_id = node.vid'
        .' left join field_data_field_plugins on field_data_field_plugins.revision_id=node.vid'
        .' left join field_data_field_media_source  on field_data_field_media_source.revision_id = node.vid'
       .' left join repositoryType on repositoryType.tid=field_data_field_media_source.field_media_source_tid'
       .' left join plugins on plugins.tid=field_data_field_plugins.field_plugins_tid'
       .' left join field_data_field_media_type on field_data_field_media_type.revision_id = node.vid'
       .' left join media_type on media_type.tid = field_data_field_media_type.field_media_type_tid'
       .' WHERE node.status<>0 and node.type="media_recourse"'
       .' and media_type.media_type ="audio"'
        .$sqltitle
        .$sqlregion;


     //echo $audiosqlcount . "<br />";
//echo "<br />";


// count returned rows in dataset
$resultcount=mysql_query($audiosqlcount);
$count=mysql_num_rows($resultcount);
//echo $count . "<br />";

if ($num==0){
$num=$count;
}
//echo $num . "<br />";

$audiosql=$audiosqlcount .' ORDER BY weight LIMIT ' . $start.' , '.$num;
    // Query Database
//echo "<br />";

//echo $audiosql . "<br />";

    $result = mysql_query($audiosql);
    //echo $result . "\n";
    // convert database array into local array
//echo '[{"returnedSize":'.$num.',"totalSize":'.$count.'}]';
    $data = mysql_fetch_rowsarr($result,$taskId,$num,$count);
    // save local array
    //$response=$data;
//print_r($data);
    return $data;
    break;

Case 'image':
//echo "start : " . $start . " Num : " .$num . "<br />";

    //setup sql for image / title search.
    $sqlregion = "";
    $sqltitle = "";
//echo $region . "<br />";
$sqlregion = 'and (taxonomy_term_data.name = "worldwide" or ';
//echo $sqlregion . "<br />";

$sqlregion = $sqlregion . 'taxonomy_term_data.name like ';
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "'%";
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . $region;
//echo $sqlregion . "<br />";
$sqlregion =$sqlregion . "%')";
//echo $sqlregion . "<br />";

//.$region. "%'")';

//echo $sqlregiontemp . "<br />";

//echo $title . "<br />";
    if (isset($title) && !is_null($title)) {
      $sqltitle = "and node.title like '%" .$title . "%'";
    }
//echo $sqltitle; "<br />";
    $imagesqlcount = 'SELECT node.title as "show", taxonomy_term_data.name as region, field_data_field_url.field_url_value as url, '
.' repositoryType.repositoryType as resourceType, plugins.plugin'
        .' FROM node'
        .' left join field_data_field_region on field_data_field_region.revision_id=node.vid'
        .' left join taxonomy_term_data on taxonomy_term_data.tid=field_data_field_region.field_region_tid'
        .' left join field_data_field_url on field_data_field_url.revision_id = node.vid'
        .' left join field_data_field_plugins on field_data_field_plugins.revision_id=node.vid'
        .' left join field_data_field_media_source  on field_data_field_media_source.revision_id = node.vid'
       .' left join repositoryType on repositoryType.tid=field_data_field_media_source.field_media_source_tid'
       .' left join plugins on plugins.tid=field_data_field_plugins.field_plugins_tid'
       .' left join field_data_field_media_type on field_data_field_media_type.revision_id = node.vid'
       .' left join media_type on media_type.tid = field_data_field_media_type.field_media_type_tid'
       .' WHERE node.status<>0 and node.type="media_recourse"'
       .' and media_type.media_type ="image"'
        .$sqltitle
        .$sqlregion;


     //echo $imagesqlcount . "<br />";
//echo "<br />";


// count returned rows in dataset
$resultcount=mysql_query($imagesqlcount);
$count=mysql_num_rows($resultcount);
//echo $count . "<br />";

if ($num==0){
$num=$count;
}
//echo $num . "<br />";

$imagesql=$imagesqlcount .' ORDER BY weight LIMIT ' . $start.' , '.$num;
    // Query Database
//echo "<br />";

//echo $imagesql . "<br />";


    $result = mysql_query($imagesql);
    //echo $result . "\n";
    // convert database array into local array
//echo '[{"returnedSize":'.$num.',"totalSize":'.$count.'}]';
    $data = mysql_fetch_rowsarr($result,$taskId,$num,$count);
    // save local array
    //$response=$data;
//print_r($data);
   return $data;

    break;




  }
  }

}
//***************************************************************************************************

  // Function for basic field validation (present and neither empty nor only white space
  function IsNullOrEmptyString($question){
  return (!isset($question) || trim($question)==='');
  }
//***************************************************************************************************

   function mysql_fetch_rowsarr($result, $taskId, $num, $count){
   // $got = array();

  if(mysql_num_rows($result) == 0)
    return $got;
 mysql_data_seek($result, 0);

//$row=mysql_fetch_assoc($result);     
//while($row=mysql_fetch_row($result)){

   while ($row = mysql_fetch_assoc($result)) {
  //print_r($row);
if($taskId=="plugin") {
   $beginurl = "http://serviidb.com/sites/default/files/";
   $replaceurl = "public://";
   $replacementurl = $beginurl . substr($row[URL],9);
   $row[URL]=$replacementurl;
   }

$got[]=$row;
}
//$apidata=array("Resource"=>$taskId,"requestedSize"=>$num,"totalSize"=>$count);
array_unshift($got,"items");
array_unshift($got,$apidata);
array_unshift($got,"requestedSize",$num);
array_unshift($got,"Resource",$taskId);
 

//$gotfront=array("resource"=>$taskId,"requestedSize"=>$num,"totalSize"=>$count);
//$got=a($gotfront,$got);
//$got=array(array("resource"=>$taskId,"requestedSize"=>$num,"totalSize"=>$count),$got);
//$apidata=json_encode($apidata);
//print_r($apidata);
return $got; 
}

?>


TaskHandler.php
  Code:
<?php
require_once 'TaskDataManager.php';
require_once('Array2XML.php');

//require_once("PhpJsonXmlArrayStringInterchanger.inc.php"); 
//$object=new PhpJsonXmlArrayStringInterchanger(); 
/**
 @uri /apidev/{taskId}
 */


class TaskHandler extends Resource {
       
public function get($request, $taskId, $data){
$time_start = microtime_float();
   
$region= htmlspecialchars($_GET["region"]);
   //$region=mysql_real_escape_string($region);
   $title= htmlspecialchars($_GET["title"]);
   //$title= mysql_real_escape_string($title);
   $client= htmlspecialchars($_GET["client"]);
   //$client=mysql_real_escape_string($client);
   
$format = ( isset( $_GET['format'] )) ? htmlspecialchars( $_GET['format'] ):"json";
//echo $format;
   
   //echo 'region : '. $region . "\n";
   //echo 'title : '. $title . "\n";
   //echo 'client : '. $client . "\n";
   //echo 'format : '. $format . "\n";
   
//echo $input;
//echo $format;      
$result = TaskDataManager::get($taskId, $format, $region, $title, $client, $num, $start);
$response = new Response($request);
                Switch($format){
      Case 'json':
$response->body = json_encode($result);

//$response->body = json_encode($result,JSON_FORCE_OBJECT);
      $response->addHeader('Content-type', 'application/json');
      break;
      Case 'xml':
//print_r($result);
                    // print array2xml($result);
                $response = Array2XML::createXML('resources', $result);

      break;
      Case 'html':
      $response->body = print_arr($result);
      $response->addHeader('Content-type', 'application/html');
      break;
                default:
                     $response->body = json_encode($result);
                      break;
}
      //echo "header added " . "\n";
      if($result){
         $response->code = Response::FOUND;
              }
       else {
      $response->code = Response::NOTFOUND;
      $response->body = "Task $taskId not found.";
                 }
$time_end=microtime_float();
//Echo "time_start : ". $time_start. "<br />" ;
//Echo "time_end : ". $time_end. "<br />";
$time=($time_end-$time_start);
//Echo "took $time microseconds to return response". "<br />";

      return $response;
   }
}
/** Prints the contents of an array with HTML special characters, linebreaks and spaces
* @param array $array
* @param bool $echo (default: true)
* @result bool/array
*/
function print_arr($array, $echo = false)
{
$array = print_r($array, true);
$array = htmlspecialchars($array);
$array = str_replace(" ", " ", $array);
$array = nl2br("”.$array.”");
if($echo == true)
{
echo $array;
return true;
}
return $array;
}
   
/** 
*Function returns XML string for input associative array. 
* @param Array $array Input associative array 
* @param String $wrap Wrapping tag 
* @param Boolean $upper To set tags in uppercase 
*/
function array2xml($array, $wrap='ROW0', $upper=true) {
     // set initial value for XML string     
$xml = '';   
 // wrap XML with $wrap TAG     
if ($wrap != null) {
         $xml .= "<$wrap>\n";
     }     
// main loop     
foreach ($array as $key=>$value) {
  // set tags in uppercase if needed         
if ($upper == true) {
 $key = strtoupper($key);
  }
         // append to XML string
        $xml .= "<$key>" . htmlspecialchars($value) . "</$key>";
    }
     // close wrap TAG if needed
    if ($wrap != null) {
        $xml .= "</$wrap>";
     }
    // return prepared XML string
    return $xml;

}
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}


?>


you will see alot of comments and echos since I am trying different things.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

kairoh

DLNA master

Posts: 180

Joined: Sun Aug 08, 2010 10:41 am

Location: France

Post Wed Apr 11, 2012 9:00 pm

Re: serviidb.com

moltra wrote:I thought I posted this this morning, but must have been to asleep to hit submit.

Beware of Mercurial : you have to "commit" THEN you have to "push" them to the online server (for example bitbucket).
Idem for the retrieval : you have to "pull" them from the online server THEN "update" your workspace.

moltra wrote:how is this?
  Code:
[{"Resource":"video","requestedSize":2,"totalSize":60},"items",{"show":"Blip TV Photoshop Users TV","region":"UK","url":"http:\/\/blip.tv\/photoshop-user-tv\/rss","resourceType":"RSS \/ Atom feed","plugin":"Blip TV"},{"show":"TV Highlights","region":"UK","url":"http:\/\/feeds.bbc.co.uk\/iplayer\/highlights\/tv","resourceType":"RSS \/ Atom feed","plugin":"iPlayer (UK)"}]


Concerning the json format, I totally agree with Will, this is a bit hard to read (and parse).
- Concerning variable name, i do prefer the lowerCamelCase, the "java style" named by Will.
- Concerning special char "/", it shouldn't be escaped (use the option : json_encode( "", JSON_UNESCAPED_SLASHES ) )
- BTW don't use JSON_FORCE_OBJECT option of json_encode()
- Globally, I will like to have this:
  Code:
{
"resource":"video", "returnedSize":2, "totalSize":60,
"items":[
   {"show":"Blip TV Photoshop Users TV","region":"UK","url":"http://blip.tv/photoshop-user-tv/rss","resourceType":"RSS / Atom feed","plugin":"Blip TV"},
   {"show":"TV Highlights","region":"UK", "url":"http://feeds.bbc.co.uk/iplayer/highlights/tv","resourceType":"RSS / Atom feed","plugin":"iPlayer (UK)"}
]
}

You can try it with this online parser
Serviio WebUI console developer : New Homepage | Support | Project | Issues

Samsung UA32C6600 | WinXP / Ubuntu 11.10 | Samsung Galaxy S | Freebox v6
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Thu Apr 12, 2012 12:19 am

Re: serviidb.com

I think I got it working except for the escaping of the special character "/" that command is in php 5.4 and godaddy is at 5.3 . I will look and see if there is a work around to get it not escaped.

Please check and see if the output of the
  Code:
get serviidb.com/apidev/video
is giving you the output you guys are looking for. actually plugin, video, image, audio all should give the same output format now.

  Code:
{"resource":"plugin","requestedSize":2,"totalSize":15,"items":[{"name":"Hulu (US)","revision":"1","url":"public:\/\/Hulu.groovy","URL":"http:\/\/serviidb.com\/sites\/default\/files\/"},{"name":"Hulu (US)","revision":"1","url":"public:\/\/createplugin\/Hulu_0.groovy","URL":"http:\/\/serviidb.com\/sites\/default\/files\/"}]}


Edit: I actually copied the files over the the serviidb.com/api retful service also so they both should be giving what you want.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Apr 12, 2012 7:13 am

Re: serviidb.com

That looks much better and will be very easy to parse, so thank you.

One question, why does the plugin content contain "url":"public:\/\/Hulu.groovy","URL":"http:\/\/serviidb.com\/sites\/default\/files\/" ?
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Thu Apr 12, 2012 7:37 am

Re: serviidb.com

I had made a change trying to unescape the "/" and forgot to take it out. I just noticed for some reason if I request 2 items, I am only getting 1 now. trying to figure out why

Fixed why I was not getting the request number of items.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Apr 12, 2012 1:10 pm

Re: serviidb.com

I'm going to be putting together some basic support for this in ServiiDroid and might get something done by the weekend/end of the weekend, so a few more quick points:

1) https://bitbucket.org/moltra/serviidb-a ... nedsize-to I would actually keep this how it is
2) can you change 'show' to 'name' or 'title' as it doesn't make sense for /image (what ever it is, keep it the same for video/audio and image so that I can use the same class to respresent them).
3) In your attempt to remove the excess \/ chars, you have removed the / from RSS/Atom feed
4) You have a search by title, It might be nice to also have a search by plugin and search by combined plugin/title e.g. the user types in hulu or 4oD or 'the big band theory' and it should match content with those string in either the plugin or the title fields.


One other thing, any thoughts on the idea to also include information about how to build custom urls viewtopic.php?f=17&t=5446&start=10#p39584
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Thu Apr 12, 2012 3:21 pm

Re: serviidb.com

will wrote:I'm going to be putting together some basic support for this in ServiiDroid and might get something done by the weekend/end of the weekend, so a few more quick points:

1) https://bitbucket.org/moltra/serviidb-a ... nedsize-to I would actually keep this how it is
2) can you change 'show' to 'name' or 'title' as it doesn't make sense for /image (what ever it is, keep it the same for video/audio and image so that I can use the same class to respresent them).
3) In your attempt to remove the excess \/ chars, you have removed the / from RSS/Atom feed
4) You have a search by title, It might be nice to also have a search by plugin and search by combined plugin/title e.g. the user types in hulu or 4oD or 'the big band theory' and it should match content with those string in either the plugin or the title fields.


One other thing, any thoughts on the idea to also include information about how to build custom urls viewtopic.php?f=17&t=5446&start=10#p39584


1. you mean returnedSize or requestedSize.

2. Yes I will change it to title.

3. Yes I removed that so it would be easier in the future. I actually removed it in the drupal database

4. It will be easy to add the title search. I just need to enter one line of sql. I already have it setup so that you can search region, title at the same time. and all searches are wildcard type searchs


I also need to setup the region as a request. Should take a few minutes, will get it today sometime. I was up all night working and will probably lay down in a little bit.

Yes I have thought about the custom urls and I think know how to do it. The thing I am trying to figure out is how to get them from the database. Since it is user specific, need user/password controls?

I am also still fighting to get the xml to work right.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Apr 12, 2012 3:30 pm

Re: serviidb.com

moltra wrote:1. you mean returnedSize or requestedSize.

2. Yes I will change it to title.

3. Yes I removed that so it would be easier in the future. I actually removed it in the drupal database

4. It will be easy to add the title search. I just need to enter one line of sql. I already have it setup so that you can search region, title at the same time. and all searches are wildcard type searchs


I also need to setup the region as a request. Should take a few minutes, will get it today sometime. I was up all night working and will probably lay down in a little bit.

Yes I have thought about the custom urls and I think know how to do it. The thing I am trying to figure out is how to get them from the database. Since it is user specific, need user/password controls?

I am also still fighting to get the xml to work right.


1) Keep it as returnedSize

4) Search by plugin (not title, assume that was a typo)

Custom urls/templates: Why would it be user specific? The idea would be that you would have none, one or multiple per plugin that describe in a form usable by clients, on how to build urls from the minimal amount of user input.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Thu Apr 12, 2012 3:46 pm

Re: serviidb.com

will wrote:
moltra wrote:1. you mean returnedSize or requestedSize.

2. Yes I will change it to title.

3. Yes I removed that so it would be easier in the future. I actually removed it in the drupal database

4. It will be easy to add the title search. I just need to enter one line of sql. I already have it setup so that you can search region, title at the same time. and all searches are wildcard type searchs


I also need to setup the region as a request. Should take a few minutes, will get it today sometime. I was up all night working and will probably lay down in a little bit.

Yes I have thought about the custom urls and I think know how to do it. The thing I am trying to figure out is how to get them from the database. Since it is user specific, need user/password controls?

I am also still fighting to get the xml to work right.


1) Keep it as returnedSize

4) Search by plugin (not title, assume that was a typo)

Custom urls/templates: Why would it be user specific? The idea would be that you would have none, one or multiple per plugin that describe in a form usable by clients, on how to build urls from the minimal amount of user input.



The way I was thinking, the user would log in serviidb and go to say picasa and they would enter their username for picasa and folder it they wanted a specific folder returned only.
Now to get this via the API it would have to be saved. That way it could be retrieved by the API for entry by serviidroid.

Or the API could return a generic url where the custom URL was complete, except for replacing one word in the URL with the username, or file name. The client could replace that word. This way the user never has to create and save a custom url on serviidb

Either or both is fine with me.

Hey, in the api there is also a client parameter, that way we can see what client is doing what and how often. Plus I will be logging response time with date/time and client so i can make sure that the API is not slowing the clients down.

I am going to be adding one more field to the results returned that is the nid (node id). If I can get the clients to send this back when the media source is added to serviio, I can track "installs" of the sources. I have not started writing that API yet, but it should be a straight put command with 2 parameters, client and nid.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Apr 12, 2012 3:58 pm

Re: serviidb.com

Your first one sounds quite different. Do you mean that the user would save urls on serviidb that only they could see? And then fetch them via their client?

What I was thinking would be much more like the second one, in that the clients could fetch the raw description of how to build an entry (title and url and info), that way if the content is not on serviidb when they search for it (either has not be put there, or is not feasable as it is unlimited e.g. youtube), then can quickly fill it in (see examples in the link), add it to their library, (and optionally in the future, upload it to serviidb).

So for picasa, ServiiDroid could download the description of how to build a url, and then generate a UI that asks for just their picasa username and folder and then builds the url and the title (plus other info) from that.

This info would be sperate e.g. /entry-template and would include all the info described in the link plus the plugin name as on ServiiDB
Last edited by will on Thu Apr 12, 2012 4:09 pm, edited 1 time in total.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

moltra

DLNA master

Posts: 1871

Joined: Thu Mar 24, 2011 11:00 pm

Location: Ohio USA

Post Thu Apr 12, 2012 4:07 pm

Re: serviidb.com

will wrote:Your first one sounds quite different. Do you mean that the user would save urls on serviidb that only they could see? And then fetch them via their client?

What I was thinking would be much more like the second one, in that the clients could fetch the raw description of how to build an entry (title and url and info), that way if the content is not on serviidb when they search for it (either has not be put there, or is not feasable as it is unlimited e.g. youtube), then can quickly fill it in (see examples in the link), add it to their library, (and optionally in the future, upload it to serviidb).

So for picasa, ServiiDroid could download the description of how to build a url, and then generate a UI that asks for just their picasa username and folder and then builds the url and the title (plus other info) from that.


so you would need the url and what words needed to be changed to complete it.

The client way sounds fine to me, the reason I was thinking the 1st was of storing them on serviidb, was I have setup serviidb to store RSS files and allow users to link to them with serviio. So the custom links was along the same lines, but like I said either or both does not matter to me.
Mark
Beta Tester Group
http://www.serviidb.com Online media resource repository

Netgear EVA2000 | Samsung BD-D5300 | XBOX 360 | Windows 7 | Mint Debian 12 | Raxz Maxx
HowTo: Provide supported formats of a device HowTo: Record a new ticket on Bitbucket
HowTo: Provide details of a video file that doesn't play HowTo: Turn on detailed logging
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Thu Apr 12, 2012 4:16 pm

Re: serviidb.com

Yes, i think what is shown below is everything at the moment. The two fields account for things like picasa with username and folder.
The api would return something that looks like this, and the clients would use it to build the url, title and get the other info. Once serviio supports fetching info about installed plugins, it can also use the plugin to confirm the user has the correct one installed, and in the future,offer to install it.
  Code:
inputTitle1=Search term                  -> Result stored in VALUE1
hint1=Serviio sony
inputTitle2=null                         -> Result stored in VALUE2
hint2=null
resultURL=http://gdata.youtube.com/feeds/videos?q=VALUE1
resultTitle=YouTube - VALUE1
mediaType=VIDEO
resourceType=FEED
spaceChar=+
plugin=YouTube


Gives url http://gdata.youtube.com/feeds/videos?q=serviio+sony title YouTube - Serviio sony


Storing rss feeds could be good as well, but I think that would almost be a seperate thing?
Last edited by will on Thu Apr 12, 2012 4:22 pm, edited 2 times in total.
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
PreviousNext

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 13 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.