SageTV Community  

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

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-22-2011, 03:25 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
What's in a Playlist?

I'm a bit stumped trying to figure out what type of Sage objects are stored in playlists. I have the following test code snippit that scans a playlist for a particular MediaFile by matching MediaFileIDs. (I'm using Sean's sagex-api.)

When I run the code I see that "item" is an Airing, but then "MF" comes back as null.

The playlist actually contains music so I expected that "item" would be a MediaFile Object. If I try GetMediaFileID(item) it comes back as 0.

I'm probably overlooking something obvious.

Code:
            Object[] items = PlaylistAPI.GetPlaylistItems(playlist); 

            for (Object item : items) {
                
                int ID = 0;

                if (MediaFileAPI.IsMediaFileObject(item)) {
                    System.out.println("MEDIAFILE");
                    ID = MediaFileAPI.GetMediaFileID(item);
                } else if (AiringAPI.IsAiringObject(item)) {
                    System.out.println("AIRING");
                    Object MF = AiringAPI.GetMediaFileForAiring(item);

                    if (MF == null) {
                        System.out.println("NULL MF");
                    }

                    ID = MediaFileAPI.GetMediaFileID(MF);
                } else if (ShowAPI.IsShowObject(item)) {
                    System.out.println("SHOW");
                } else {
                    System.out.println("UNKNOWN");
                }
System.out.println("IDs=" + ID + " : " + mediaFileID);
                if (ID == mediaFileID)
                    return true;
            }
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #2  
Old 01-22-2011, 03:52 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
I'm guessing it's some kind of pseudo-Airing object used for wrapping playlist items in a uniform way. Playing around with it in Expression Evaluator (always a good way to try stuff out before committing it to code), I find that it does respond sensibly to many AiringAPI methods such as IsAiringObject, GetAiringID, GetAiringTitle, and so on, but not apparently to GetMediaFileForAiring. MediaFileAPI and AlbumAPI methods do not appear to work.

By the way, according to the API docs for AddToPlaylist, Show objects are not valid playlist items. Only Airings, Albums, MediaFiles, and Playlists are allowed.
__________________
-- Greg
Reply With Quote
  #3  
Old 01-22-2011, 05:26 PM
Fonceur's Avatar
Fonceur Fonceur is offline
Sage Icon
 
Join Date: Jan 2008
Location: DDO, QC
Posts: 1,915
The problem might be in sagex-api, as using GKusnick Studio Tool, the following works:

Code:
if (pl.GetPlaylistItemTypeAt(i).equalsIgnoreCase("Airing"))
{
  airing = sageApiAiring.Wrap(pl.GetPlaylistItemAt(i));
  mf = airing.GetMediaFileForAiring();
}
else if (pl.GetPlaylistItemTypeAt(i).equalsIgnoreCase("Album"))
{
  album = sageApiAlbum.Wrap(pl.GetPlaylistItemAt(i));
  mf = album.GetAlbumTracks().get(0).GetMediaFileForAiring();
}
And so on...
__________________
SageTCPServer (2.3.5): Open source TCP interface to the SageTV API
MLSageTV (3.1.8)/Sage Media Server (1.13): SageTV plugin for MainLobby/CQC
TaSageTV (2.58)/TaSTVRemote (1.14): Monitor/control SageTV with an Android device
TbSageTV (1.02)/STVRemote (1.11): Monitor/control SageTV with a PlayBook 2
TiSageTV (1.64)/TiSTVRemote (1.09): Monitor/control SageTV with an iPhone/iPod/iPad
Reply With Quote
  #4  
Old 01-22-2011, 06:15 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Fonceur View Post
The problem might be in sagex-api, as using GKusnick Studio Tool, the following works:...
I've never used Greg's API. Maybe it's time to give it a shot.

Maybe there's a better way to do what I need. I was trying to write a simple method that returns a boolean indicating if a MediaFile is part of any playlist. (Because I want to use it in FilterByBoolMethod()) Is there an easier way to do this? I didn't see anything in (Core) PlaylistAPI or MediaFileAPI that provides this function....
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #5  
Old 01-22-2011, 07:02 PM
skiingwiz skiingwiz is offline
Sage Aficionado
 
Join Date: Jan 2005
Posts: 366
I can verify that this works using the sagex-api. The code I just ran is below. Every Airing Object successfully got a MediaFile Object and subsequently an ID.

I am running using the remote API provider and against the latest sagex release. How is your environment setup? And is the code that you posted exactly what is being run?

Code:
import sagex.api.AiringAPI;
import sagex.api.MediaFileAPI;
import sagex.api.PlaylistAPI;
import sagex.api.ShowAPI;


public class PlaylistTest {

    public static void main(String[] args) {
        Object[] playlists = PlaylistAPI.GetPlaylists();
        for(Object p : playlists) {
            Object[] items = PlaylistAPI.GetPlaylistItems(p); 

            for (Object item : items) {

                int ID = 0;

                if (MediaFileAPI.IsMediaFileObject(item)) {
                    System.out.println("MEDIAFILE");
                    ID = MediaFileAPI.GetMediaFileID(item);
                } else if (AiringAPI.IsAiringObject(item)) {
                    System.out.println("AIRING");
                    Object MF = AiringAPI.GetMediaFileForAiring(item);

                    if (MF == null) {
                        System.out.println("NULL MF");
                    }

                    ID = MediaFileAPI.GetMediaFileID(MF);
                    System.out.println("ID = " + ID);
                } else if (ShowAPI.IsShowObject(item)) {
                    System.out.println("SHOW");
                } else {
                    System.out.println("UNKNOWN");
                }
            }
        } 
    }
}
Reply With Quote
  #6  
Old 01-22-2011, 07:27 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by skiingwiz View Post
I can verify that this works using the sagex-api. The code I just ran is below. Every Airing Object successfully got a MediaFile Object and subsequently an ID.

I am running using the remote API provider and against the latest sagex release. How is your environment setup? And is the code that you posted exactly what is being run?
I'm not running remotely and the code I posted was cut and paste.

What's in your playlists? Mine are all music.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #7  
Old 01-22-2011, 07:39 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Just tried it again to make sure, MF is always null. The java code is attached, I'm building it as a JAR.
Attached Files
File Type: zip Playlist.zip (514 Bytes, 178 views)
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #8  
Old 01-22-2011, 07:43 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by Fonceur View Post
The problem might be in sagex-api, as using GKusnick Studio Tool, the following works:

Code:
if (pl.GetPlaylistItemTypeAt(i).equalsIgnoreCase("Airing"))
{
  airing = sageApiAiring.Wrap(pl.GetPlaylistItemAt(i));
  mf = airing.GetMediaFileForAiring();
}
else if (pl.GetPlaylistItemTypeAt(i).equalsIgnoreCase("Album"))
{
  album = sageApiAlbum.Wrap(pl.GetPlaylistItemAt(i));
  mf = album.GetAlbumTracks().get(0).GetMediaFileForAiring();
}
And so on...
People might believe there is some magic to the either the sagex-apis or greg's apis, but quite honestly, they both do something very similar, which is translate java apis into sage services... ie, everything eventually passes through SageAPI.call(). (That being said, there really is magic involved to get the apis working remotely )

Tom, I suspect that your issue in the algorithm... is you study fonceur's logic, he's doing something different that you. He's testing the GetPlaylistItemTypeAt against a string, and then getting the Album, and then getting the file. I suspect if you rewrote your existing logic to match his, it would probably work.
Reply With Quote
  #9  
Old 01-22-2011, 07:51 PM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
I'm not running remotely and the code I posted was cut and paste.
Off Topic, but, Tom, you really should try to get the sagex-apis working remotely. Writing and testing code on your desktop does make the development experience so much better. I probably would have given up sage development a long time ago, if I had to build and deploy the jar everytime I made a code change. For me, working heavily in phoenix and bmt, I only deploy a jar to my server shortly before I'm ready to publish it.

There really isn't much to getting things working remotely, so if you ever want to try it, just let me know, and I'll walk your through it. Once you have it setup, you'll ask yourself how you ever developed for sage without it
Reply With Quote
  #10  
Old 01-22-2011, 08:10 PM
PLUCKYHD PLUCKYHD is offline
SageTVaholic
 
Join Date: Dec 2007
Posts: 6,257
Quote:
Originally Posted by stuckless View Post
Off Topic, but, Tom, you really should try to get the sagex-apis working remotely. Writing and testing code on your desktop does make the development experience so much better. I probably would have given up sage development a long time ago, if I had to build and deploy the jar everytime I made a code change. For me, working heavily in phoenix and bmt, I only deploy a jar to my server shortly before I'm ready to publish it.

There really isn't much to getting things working remotely, so if you ever want to try it, just let me know, and I'll walk your through it. Once you have it setup, you'll ask yourself how you ever developed for sage without it
plus 100 on this statement. I would have gone suicidal if it wasn't for being able to test the code directly in my IDE and not having to redeploy the jar each time to test.

Thanks again for this stuckless life saver!!
Reply With Quote
  #11  
Old 01-23-2011, 03:24 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by stuckless View Post
Off Topic, but, Tom, you really should try to get the sagex-apis working remotely. Writing and testing code on your desktop does make the development experience so much better. I probably would have given up sage development a long time ago, if I had to build and deploy the jar everytime I made a code change. For me, working heavily in phoenix and bmt, I only deploy a jar to my server shortly before I'm ready to publish it.

There really isn't much to getting things working remotely, so if you ever want to try it, just let me know, and I'll walk your through it. Once you have it setup, you'll ask yourself how you ever developed for sage without it
If you are offering I won't turn you down. Just remember that you are dealing with a coding dinosaur who was born and raised on assembler language. My idea of an IDE is Macro Assembler
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #12  
Old 01-23-2011, 04:09 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by stuckless View Post
Tom, I suspect that your issue in the algorithm... is you study fonceur's logic, he's doing something different that you. He's testing the GetPlaylistItemTypeAt against a string, and then getting the Album, and then getting the file. I suspect if you rewrote your existing logic to match his, it would probably work.
This made no difference for me because all of my calls to GetPlaylistItemTypeAt() are coming back with "Airing" and subsequently GetMediaFileForAiring() comes back with null. About the best I can do at this point is match the results from GetShowEpisode() which is actually the song title.

GetAiringID() returns a valid ID for the playlist items, but it doesn't match the results from GetMediaFileID() for the song I pass into the method.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #13  
Old 01-23-2011, 08:11 AM
stuckless's Avatar
stuckless stuckless is offline
SageTVaholic
 
Join Date: Oct 2007
Location: London, Ontario, Canada
Posts: 9,713
Quote:
Originally Posted by tmiranda View Post
I'm not running remotely and the code I posted was cut and paste.

What's in your playlists? Mine are all music.
Quote:
Originally Posted by tmiranda View Post
If you are offering I won't turn you down. Just remember that you are dealing with a coding dinosaur who was born and raised on assembler language. My idea of an IDE is Macro Assembler
Here, I just posted this article. While the article is long, the steps are actually quite easy.
Reply With Quote
  #14  
Old 01-23-2011, 08:34 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Not really sure what your trying to do but albums are a wee bit funny (well to me they are )..... Anyway if your after the mediaid from an airing album you could try:

Code:
Album = GetElement(GetAlbumTracks(GetAlbumForFile(Airing)), i)
   MediaID = GetMediaFileID(Album)
I'm probably off target but you never know, one day I'll answer something correctly
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #15  
Old 01-23-2011, 08:50 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
The problem is that GetAlbumForFile(Airing) returns null. As Greg pointed out above, it seems when you get an "Airing" from a Playlist, it's not the same as a normal Airing.

I decided to go in a slightly different direction so I actually do not need to get the MediaFileID. Now I'm simply trying to get the Album Art associated with a Playlist Item which is also turning out to be strange because of the peculiar way Sage treats Playlist Items.

I'm looking for a place in the STV where the album art is obtained for a playlist item. So far I haven't found it. What the default STV normally does is start playing the playlist and then it gets the loaded media file and derives the various pieces of information from that.

__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #16  
Old 01-23-2011, 08:51 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by stuckless View Post
Here, I just posted this article. While the article is long, the steps are actually quite easy.
Thank you very much.
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #17  
Old 01-23-2011, 09:07 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Ok, I'll try again

Code:
PlayList = GetElement(GetPlaylists(), 0)
   PlayListItem = GetElement(GetPlaylistItems(PlayList), 0)
      PlayListAlbum = GetAlbumForFile(PlayListItem)
          GetAlbumArt(PlayListAlbum)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #18  
Old 01-23-2011, 09:24 AM
Fonceur's Avatar
Fonceur Fonceur is offline
Sage Icon
 
Join Date: Jan 2008
Location: DDO, QC
Posts: 1,915
Quote:
Originally Posted by jaminben View Post
Not really sure what your trying to do but albums are a wee bit funny (well to me they are )...
Not only to you... Since they have no ID or cover art, you basically have to tag them with one of their songs...
__________________
SageTCPServer (2.3.5): Open source TCP interface to the SageTV API
MLSageTV (3.1.8)/Sage Media Server (1.13): SageTV plugin for MainLobby/CQC
TaSageTV (2.58)/TaSTVRemote (1.14): Monitor/control SageTV with an Android device
TbSageTV (1.02)/STVRemote (1.11): Monitor/control SageTV with a PlayBook 2
TiSageTV (1.64)/TiSTVRemote (1.09): Monitor/control SageTV with an iPhone/iPod/iPad
Reply With Quote
  #19  
Old 01-23-2011, 09:46 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by jaminben View Post
Ok, I'll try again

Code:
PlayList = GetElement(GetPlaylists(), 0)
   PlayListItem = GetElement(GetPlaylistItems(PlayList), 0)
      PlayListAlbum = GetAlbumForFile(PlayListItem)
          GetAlbumArt(PlayListAlbum)
GetAlbumForFile() returns a null. (I've got a logfile full of traces to prove it. )
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #20  
Old 01-23-2011, 09:46 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Quote:
Originally Posted by Fonceur View Post
Not only to you... Since they have no ID or cover art, you basically have to tag them with one of their songs...
I don't understand what you mean, can you explain please?
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
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
Print PlayList wjohn SageTV Software 2 04-04-2009 11:37 PM
Playlist Problems Madeen SageTV Software 3 01-29-2008 05:53 PM
Movie Playlist lordmeatball SageTV Customizations 7 12-02-2006 03:34 AM
Playlist doesn't play Redrum SageTV Software 3 02-20-2006 03:57 AM


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


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