|
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. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Data Type Definitions and Access
Another Java/Studio noob question. I'm looking to modify some data that is of type sage.MediaFile[]. I understand that this variable is an array of sage.MediaFile objects (is that the right word?)
Two questions: 1. Where in the Sage docs can I find a definition of what's in each sage.MediaFile? 2. How do reference these items? For example, I remember from my C days that there would be a "struc" to define the object along the lines of: struc sage.MediaFile { int item1; int item2; string item3; } and if I had a variable (call it MyArray) that was an array of sage.MediaFile then I could address data like this: MyArray[1].item1 = 7; MyArray[125].item3 = "some string"; So where do I find what items are in each sage.MediaFile and how do I manipulate the data in Java? What I'm looking to do is loop through all the data elements in the array altering one item in each element. If it helps, the data I want to manipulate was created as a call to GetMediaFile(). Thanks, Tom
__________________
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. |
#2
|
||||
|
||||
Here's the link to javadoc for the sage api. Be sure to read the description section for the sage.api package, since it explains some very fundamental things about calling the sage api from java.
Even though the sage api is javadoc'd as being a java api, it is not a java in the true sense. The API docs are there for reference, but when you call the Sage api from studio, you can simply call the method names that exist in the javadoc. ie, To get all media files, the javadoc, includes a sage.api.MediaFile class with a static method of GetMediaFiles(). From the stv, you would simply call GetMediaFiles()., but from pure java, you'd actually call something like Code:
Object mediaFiles[] = sage.SageTV.api("GetMediaFiles") // or to get all TV files Object mediaFiles[] = sage.SageTV.api("GetMediaFiles", new Object[] {"T"}) Greg's wrappers, makes working with the Sage objects alot simpler. You basically get an object on which you can call methods, so something like, Code:
MediaFile mf = MediaFileAPI.GetMediaFileById(123343); System.out.println("Media Title: " + mf.getMediaTitle()); Code:
Object mf = MediaFileAPI.GetMediaFileById(12322); System.out.println("Title: " + MediaFileAPI.GetMediaTitle(mf)); BTW, a MediaFile is read only object (for the most part), and there are no simple ways to set mediafile metadata short of using the properties files, or by manually creating and importing new Show/Airing objects for a given media file. Check out the metadata editor part of nielm's webserver to see how much effort is involved in updating metadata for an existing media file. Good luck with your programming.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient Last edited by stuckless; 07-20-2009 at 06:29 PM. Reason: Added Links for Greg's API and the Remote APIs |
#3
|
||||
|
||||
Thanks for all of the info Sean, but you have burst my bubble. I didn't know the sage.MediaFile was read only. Back to the drawing board....
__________________
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. |
#4
|
||||
|
||||
The 6.5 beta has added a SetMediaFileMetadata API call to edit the metadata associated with a MediaFile.
I can't really think of anything else you'd want to change in it. |
#5
|
||||
|
||||
Just to clarify... SetMediaFileMetadata() is used to set the custom metadata fields (ie, user defined fields, such as those added by phoenix/fanart). But, If you call SetMediaFileMetadata("Title", "new title"), then it will not reset the sage title in the wiz.bin... but it may still write the "Title" to the .properties.
__________________
Batch Metadata Tools (User Guides) - SageTV App (Android) - SageTV Plex Channel - My Other Android Apps - sagex-api wrappers - Google+ - Phoenix Renamer Downloads SageTV V9 | Android MiniClient |
#6
|
||||
|
||||
Thanks Stanger, that's what I was looking for! Too many things to learn all at once so I missed that API.
So if I have an array of n MediaFile's how do I address an individual entry? Or is there a way to perform an operation on all n entries at the same time? Here is my train of thought, let me know if I'm headed for a trainwreck.... I want to fix the way Sage handles music artists that have different capitalizations and leading "The "'s. For example I want "A Flock of Seagulls" and "A Flock Of Seagulls" to be treated as one artist, not two. Same thing for "The Beatles" and "Beatles". I searched the default STV and there is a single variable called AllMusicFiles that is set by a single call to GetMediaFiles("ML"), like this: Code:
AllMusicFiles = GetMediaFiles("ML") So something like this logic: Code:
For n = 1 to sizeof(AllMusicFiles) do SetMediaFileMetadata(AllMusicFiles[n], Artist, FixedUpArtistName(AllMusicFiles[n])) I'm I on the right track? Is there an easier way to do what I am trying to do? stuckless - I'm not interested in changing the wiz.bin. I just want to change the data once it's read into the STV Thanks, Tom
__________________
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. Last edited by tmiranda; 07-20-2009 at 08:13 PM. Reason: Saw stuckless post |
#7
|
||||
|
||||
Quote:
And I obviously haven't followed the set metadata discussions |
#8
|
|||
|
|||
Quote:
I think what you really want to do is have Sage group those artists ("The Beatles", "the beatles", and "beatles") properly so that in the media browser when browsing by artist they are all grouped together... therefore you need to use a GroupByMethod(AllMusicFiles, GroupMethod) call after the AllMusicFiles = GetMediaFile("ML") call... this is all in studio. Code:
AllMusicFiles = GetMediaFile("ML") GroupByMethod(AllMusicFiles, GroupMethod) This is what the jar file that i sent you does (SMW also uses it). behind the scenes inside the call i do the following: psuedocode Code:
String musicartist = GetArtistName(MusicFile) musicartist = tolowercase(musicartist) filter out "the ", "the.", "a ", "a.", "an", and "an " then return musicartist unfortunately, im not at home right now so i cant post the source that i did this with... Sean, on a side note I love your api.. At first i started interfacing with the sage api all manually... then i figured i would try out sagex... wow.. so much simpler it makes calling sage calls from custom code trivial love them thanks
__________________
Server 2003 r2 32bit, SageTV9 (finally!) 2x Dual HDHR (OTA), 1x HD-PVR (Comcast), 1x HDHR-3CC via SageDCT (Comcast) 2x HD300, 1x SageClient (Win10 Test/Development) Check out TVExplorer Last edited by razrsharpe; 07-20-2009 at 09:06 PM. |
#9
|
||||
|
||||
Stanger - Yes, there are lots of ID3 editing tools but with 15,000 MP3 files to deal with it is next to impossible to get all the capitalization correct.
razrsharpe - Thanks for the info and also a big thanks for the code you already supplied me. I do not want to chaneg the wiz.bin so I will stay away from SetMediaFileMetadata(). The STV uses GroupByArrayMethod() to build the data that is eventually displayed but I do not fully understand how the function works. I do know however that AllMusicFiles is the foundation for all the data. I'm at work and can't see the STV but the logic seems to be to extract all of the artist names from AllMusicFiles and then use the artist list and AllMusicFiles in GroupByArrayMethod(). My thinking is that if I can get the Artist names "fixed" in AllMusicFiles as soon as Sage loads it into memory(which is essentially changing the ID3 info after it's read into memory) then the STV will have "clean" data to work with and all will be well! My main issue is that I do not understand what GroupByMethod() and GroupByArrayMethod() actually do. Remember, I'm a UNIX device driver guy, not a "high level language" guy and these functions are very "high level". I guess i have a lot more homework to do.
__________________
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. |
#10
|
|||
|
|||
Hey,
I am still learning studio/java but basically the two calls are described here GroupByArrayMethod GroupByMethod The difference is how the items are grouped. Array puts the group in a Array while GroupByMethod puts it into a Vector. So say you have this Code:
AllMusicFiles = GetMediaFiles("ML") Code:
AllMusicFiles = GroupByMethod(AllMusicFiles,false," GetAlbumArtist") Hopefully that helps On a Side note I would interested on where you are going with this fully and are you building on the defualt STV or SageMC? PM and we can talk. Last edited by PLUCKYHD; 07-21-2009 at 06:41 AM. |
#11
|
||||
|
||||
Quote:
If you look at the documentation, you'll see that they both return the same thing. The difference is the return value of the Method used for performing the grouping of the original Data list. You can see example usage in the default STV. GroupByMethod expects a Method that returns a single key at a time. Thus, you can use a call like: Code:
AlbumGrouping = GroupByMethod(AllMusicFiles, "GetAlbumForFile") GroupByArrayMethod expects a Method that returns an array of keys. Thus, this example call: Code:
ArtistGrouping = GroupByArrayMethod(AllMusicFiles, "GetPeopleListInShowInRoles", ArtistRoles)
__________________
SageTV Open Source v9 is available. - Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1. - Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus - HD Extenders: A) FAQs B) URC MX-700 remote setup Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request. |
#12
|
|||
|
|||
Andy,
Thanks now that makes more sense to me like I said I am still learning. So the results are the same it is just how it is expecting the group by call. |
#13
|
||||
|
||||
Quote:
Code:
AllMediaFiles=getMediaFile("ML")
__________________
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. |
#14
|
|||
|
|||
Quote:
For instance if you called Code:
AllMediaFiles = GroupByMethod(AllMediaFiles,false,"your java method") "Yourjavacode" = call setup in your code. I prefer to call it during sorting Code:
AllMediFiles = SortLexical(AllMediaFiles,false,"your java method") |
#15
|
||||
|
||||
Quote:
This is the whole point of object-oriented programming: the class decides what operations it allows on objects of that class. Clients of the class don't get to override those design choices and start fiddling with the raw data on their own. They have to work within the public interface defined by the class. You are of course free to define your own data structures that you populate with data copied from MediaFile objects and then edit that copied data as you see fit. But the MediaFile objects themselves are off-limits to third-party modification, except as explicitly allowed by the MediaFileAPI methods. That's a good thing.
__________________
-- Greg |
#16
|
||||
|
||||
Thanks Plucky and GKusnick. It's starting to make more sense now. This "object stuff" is just very different from what I am used to. The "grouping" stuff is also starting to make some sense.
Several people have all pointed me in the same direction and, lo and behold, it's starting to sink into my hard head.
__________________
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. |
#17
|
||||
|
||||
Eureka!
Hooray! My first STVi is working. I just need to do some more testing before I unleash it on the community.
Many, many, many thanks to all who helped me. I wrote an STVi that combines Music Artists that only differ because of: - Leading "The" - Leading "A" - Case sensitivity So now if you have The Beatles, Beatles, the Beatles and you look under the "Artists" view they will all show up under "The Beatles". Again, thank you all. If anybody wants to look at it and provide constructive criticism please let me know. Tom
__________________
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. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access Sage data using Windows Powershell | rickw | SageTV Customizations | 0 | 12-29-2006 02:10 PM |
Access to program guide data | GKenny | SageTV Customizations | 4 | 02-26-2005 04:22 AM |
Something I've always wondered about - how exactly does the STV Client access data? | TerryMathews | SageTV Software | 1 | 12-15-2004 10:30 PM |
Public Access EPG data | ToonGal | SageTV EPG Service | 1 | 12-15-2004 01:27 PM |
IRD Definitions for Blackbird? | tankd0g | SageTV Software | 5 | 10-14-2004 05:53 PM |