SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV v7 Customizations
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV v7 Customizations This forums is for discussing and sharing user-created modifications for the SageTV version 7 application created by using the SageTV Studio or through the use of external plugins. Use this forum to discuss plugins for SageTV version 7 and newer.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-20-2014, 01:21 PM
HokiePerogi HokiePerogi is offline
Sage Advanced User
 
Join Date: Oct 2008
Posts: 187
Using sagex with phoenix views

Is there any way to use the sagex http interface and return media items belonging to a phoenix view?

For example, I create a custom phoenix view of all my blu-rays rated PG or lower and I want to use sagex to return me a list of all the media id's within that custom view.

I've been looking through the documentation, searching the forums and googling for quite a while now with no luck. I'm beginning to think it's not possible.


Thanks for the help!
__________________
Server: AMD Phenom II X6 3.20 GHz ♠ 16 GB RAM (15.7 usable)
Capture: HDHomeRun PRIME ♠ Ceton InfiniTV 4 PCIe (Clear-QAM only)
Tuning: OpenDCT v0.5.20-RC2
Software: Windows 7 Ultimate 64-bit ♠ SageTV v9.0.12.504 ♠ Java 1.8.0_111
Clients: 4 x STX-HD300 ♠ 3 x STX-HD200 ♠ MacOS Placeshifter
Reply With Quote
  #2  
Old 03-20-2014, 03:47 PM
Dargason Dargason is offline
Sage Expert
 
Join Date: Oct 2003
Posts: 516
I'm sure it's possible... the Phoenix for Android does it somehow, as does BMT.

You probably have to make a call to the phoenix api (Phoenix API Summary) but I don't really know how to do that...
Reply With Quote
  #3  
Old 03-20-2014, 07:25 PM
HokiePerogi HokiePerogi is offline
Sage Advanced User
 
Join Date: Oct 2008
Posts: 187
I'm guessing BMT and Phoenix for Android are using the the Java API's.

I'm in an iOS household, except for one old Android phone in a cabinet somewhere. So I would like to create a simple web application that has a very small subset of Phoenix for Android functionality.

Basically, my WebApp will be able to display any Phoenix view along with cover art for each item and click for more details and trailer functionality. I had already embarked on learning how to implement infinite scrolling when I stumbled up Phoenix for Android and saw someone beat me to the punch.

So..I will continue on my quest for an iOS or web-app version of the above. However, the first step is getting the MediaFileID's for each video in various Phoenix views. The first step is often the hardest I suppose!
__________________
Server: AMD Phenom II X6 3.20 GHz ♠ 16 GB RAM (15.7 usable)
Capture: HDHomeRun PRIME ♠ Ceton InfiniTV 4 PCIe (Clear-QAM only)
Tuning: OpenDCT v0.5.20-RC2
Software: Windows 7 Ultimate 64-bit ♠ SageTV v9.0.12.504 ♠ Java 1.8.0_111
Clients: 4 x STX-HD300 ♠ 3 x STX-HD200 ♠ MacOS Placeshifter
Reply With Quote
  #4  
Old 03-21-2014, 08:50 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Normal SageTV apis are accessed via the /sagex/api, phoenix apis are accessed via sagex/phoenix.

If you look at this python script (written for my Plex Channel) you'll get the idea of how to use the phoenix apis.

Code:
https://github.com/stuckless/sagetv-phoenix-plex-channel/blob/master/SageTVPhoenix.bundle/Contents/Services/Shared%20Code/sagex.pys
For example, to get the contents of a known view...

Code:
http://HOST:PORT/sagex/phoenix?c=phoenix.umb.CreateView&1=phoenix.view.util.recentrecordings
So, the command is the fully qualified Phoenix API and the &1, &2 are the parameters for that command.

The reply is json object that contains a "reply" node with the reply contents.
Reply With Quote
  #5  
Old 03-21-2014, 07:26 PM
HokiePerogi HokiePerogi is offline
Sage Advanced User
 
Join Date: Oct 2008
Posts: 187
That's exactly what I was looking for stuckless, thank you.

Now I'm just a little stuck with getting my .ajax call to work. I'm not sure if it is a "remote server" issue or not. My SageTV Jetty server port is 8009, while my webapp is going served via IIS on port 80.

The following code results in a parsing error on the response (I believe do to the function name missing in the jsonp response...json is coming back instead of a jsonp response):

Code:
function getViewFromSageTV(viewName) {
	var api_url = "http://192.168.1.80:8009/sagex/phoenix";
	$.ajax({
		url: api_url,
		type: "GET",
		dataType: "jsonp",
		jsonp: "jsoncallback",
		data: {
			c: "phoenix.umb.CreateView",
			1: viewName
		},
		beforeSend: function() {
		  alert("Sending");
		  $("#ajaxload").show();
		},
	    success: function (result) {
	      if (result.reply != null) {
		    viewModel.totalTitles(result.reply.id);
		    alert("Success");	
		    $("#ajaxload").hide();
		  }
		},
	    error: function (jqXHR, textStatus, errorThrown) {
		  $("#error").show();
		  $("#error").append(textStatus + " | " + errorThrown + " | "+ jqXHR.status + " | " + jqXHR.statusText + " | " + jqXHR.responseText);
		  //alert("Failed");
		}
	});
}
Screen shot of Firebug included in post.

I've also tried the following urls ( result in a 404) as per the information found here:

https://code.google.com/p/customsagetv/wiki/JsonRPC

http://192.168.1.80:8009/sagex/rpcJs...=1395449173935

http://192.168.1.80:8009/sagex/jsonR...=1395449222565


I also tried the sample code found on the JsonRPC Wiki, but it results in a 404 on the .ajax call.

I've also included a second screen shot of Fiddler showing the HTTP call to sagex and the raw response coming back. It shows the function wrapper missing from the expected jsonp response.


Is this a bug in the sagex api?
Attached Images
File Type: png Screen Shot 2014-03-21 at 9.20.53 PM.png (295.6 KB, 210 views)
File Type: png Screen Shot 2014-03-21 at 9.24.41 PM.png (385.8 KB, 226 views)
__________________
Server: AMD Phenom II X6 3.20 GHz ♠ 16 GB RAM (15.7 usable)
Capture: HDHomeRun PRIME ♠ Ceton InfiniTV 4 PCIe (Clear-QAM only)
Tuning: OpenDCT v0.5.20-RC2
Software: Windows 7 Ultimate 64-bit ♠ SageTV v9.0.12.504 ♠ Java 1.8.0_111
Clients: 4 x STX-HD300 ♠ 3 x STX-HD200 ♠ MacOS Placeshifter
Reply With Quote
  #6  
Old 03-22-2014, 07:32 AM
HokiePerogi HokiePerogi is offline
Sage Advanced User
 
Join Date: Oct 2008
Posts: 187
Hmmm. So it looks like by calling the Phoenix API from sagex we lose jsonp functionality. A non-Phoenix call to sagex of:

Code:
http://192.168.1.80:8009/sagex/api?c=GetNumberOfPlaylistItems&1=playlist:Showing&jsoncallback=dan
correctly provides the response:

Code:
dan({"Result":3})

I forked the sagex code from github last night so I could take a look in more detail. I found where the jsoncallback parameter is evaluated and the response wrapped by the function. I ran out of time before I could find where sagex wraps the phoenix api to determine if what I need is even possible.
__________________
Server: AMD Phenom II X6 3.20 GHz ♠ 16 GB RAM (15.7 usable)
Capture: HDHomeRun PRIME ♠ Ceton InfiniTV 4 PCIe (Clear-QAM only)
Tuning: OpenDCT v0.5.20-RC2
Software: Windows 7 Ultimate 64-bit ♠ SageTV v9.0.12.504 ♠ Java 1.8.0_111
Clients: 4 x STX-HD300 ♠ 3 x STX-HD200 ♠ MacOS Placeshifter
Reply With Quote
  #7  
Old 03-25-2014, 02:27 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Yeah, unfortunately, I never did implement for jsonp for the phoenix apis... which is more of an oversight than anything else.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
upgraded phoenix & stv, now views not loading JonTom Phoenix 13 05-09-2013 04:55 PM
sagex-api - how can I tell if it works? gveres SageTV v7 Customizations 2 01-27-2012 10:56 PM
User Categories in Phoenix views Fuzzy Phoenix 4 01-02-2012 09:19 AM


All times are GMT -6. The time now is 01:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.