|
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
|
||||
|
||||
Help with Java Maps
The Sage API contains a method called GetMediaFilesWithImportPrefix(). It returns a map if the last parameter passed to it (GroupFolders) is TRUE, otherwise it returns a vector.
I want to iterate through this map or vector and remove any media files that reside in a specific path. I have no problem dealing with the vector, but not sure how to iterate through a map and remove the unwanted items. If it matters, I want to do this in studio (though I think I will need to call some java methods to accomplish this). Can anyone point me in the right direction?
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#2
|
||||
|
||||
Maps are basically collections of Map.Entry objects where the Entry has a getKey() and a getValue()
if you don't care about the key, then you can simply iterate the map values by calling Map.values() (ie, java_util_Map_values(Map) ) which returns a collection of the values in the map without the keys. If you need the keys... then you can use Map.entrySet() (ie, java_util_Map_entrySet(Map) ) which gives you a collection of Entry objects. You can't remove from the map while you are iterating over it (at least not easily), so I'd build a second Map to hold the values that you want. As you interate over the Map.Entry objects, just add to the new map... java_util_Map_put(NewMap, java_util_Map_Entry_getKey(MapEntry), java_util_Map_Entry_getValue(MapEntry)) Hope this helps you get started.
__________________
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 |
#3
|
||||
|
||||
Is it valid to iterate through the entry set as if it were an array?
Code:
Map = GetMediaFilesWithImportPrefix(a,b,c,d,e) EntrySet = java_util_Map_entrySet(Map) i=0 if i < Size(EntrySet) 'Start of Loop value = java_util_Map_Entry_getValue(EntrySet(i)) key= java_util_Map_Entry_getKey(EntrySet(i)) do something with value and key ... i=i+1 if i< Size(EntrySet) 'End of Loop
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#4
|
|||
|
|||
Quote:
|
#5
|
||||
|
||||
You may need to use GetElement(EntrySet, i) or java_util_Set_get(EntrySet, i).
__________________
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
|
||||
|
||||
Quote:
Thanks for the help.
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#7
|
||||
|
||||
Java Sets don't have a defined element order and don't implement the get(i) method, so I'm not sure what GetElement() would do with them. Possibly something along the lines of copying the set into a temporary array and returning the ith element of the array.
Sets are however Iterable, so it may be more formally correct to call the set's iterator() method and use the returned Iterator's hasNext() and next() methods to access successive elements.
__________________
-- Greg |
#8
|
||||
|
||||
It's not immediately clear to me how this would be done in Studio code. I will have to think that one over a bit.
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#9
|
||||
|
||||
Quote:
Quote:
Iterator = java_util_Set_iterator(EntrySet) and then you can work on the objects until hasNext() is false while (java_util_Iterator_hasNext(Iterator)) { Item = java_util_Iterator_next(Iterator) }
__________________
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 |
#10
|
||||
|
||||
Quote:
So, I think what I need to do in Studio is: tempVids = new_java_util_HashMap() entrySet = java_util_Map_entrySet(tempVids) setIterator = java_util_Map_iterator(entrySet) IF java_util_Iterator_hasNext(Iterator) 'This is the start of the loop TRUE curElement = java_util_Map_next(setIterator) myValue = java_util_Map_Entry_getValue(curElement) myKey = java_util_Map_Entry_getKey(curElement) IF (some conditional code) TRUE java_util_Map_put(tempVids, myKey, MyValue) IF java_util_Iterator_hasNext(Iterator) 'This is the end of the loop --- Unfortunately, this doesn't work. Studio doesn't like the line "setIterator = java_util_Map_iterator(entrySet)"
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#11
|
||||
|
||||
You want java_util_Set_iterator(entrySet).
__________________
-- Greg |
#12
|
||||
|
||||
Quote:
- Andy
__________________
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. |
#13
|
||||
|
||||
That's actually a really good idea. I thought that 1st parameter had to be a media mask, but I see after re-reading the API doc, that it can alternatively be an array/collection of MediaFile objects.
__________________
Server: Ryzen 2400G with integrated graphics, ASRock X470 Taichi Motherboard, HDMI output to Vizio 1080p LCD, Win10-64Bit (Professional), 16GB RAM Capture Devices (7 tuners): Colossus (x1), HDHR Prime (x2),USBUIRT (multi-zone) Source: Comcast/Xfinity X1 Cable Primary Client: Server Other Clients: (1) HD200, (1) HD300 Retired Equipment: MediaMVP, PVR150 (x2), PVR150MCE, HDHR, HVR-2250, HD-PVR |
#14
|
||||
|
||||
Quote:
Iterator = java_util_Set_iterator(java_util_Map_entrySet(Map)) In java.. Iterator = Map.entrySet().iterator() But I don't think there is an easier way to do that in Studio.
__________________
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 |
#15
|
|||
|
|||
Quote:
Iterator =new_java_util_Set_iterator(java_util_Map_entrySet(Map)) I think you have to have the new but can't remember man I am glad I stopped doing that stuff in studio |
#16
|
||||
|
||||
No, you don't need new because you're not instantiating the Iterator class; you're calling the iterator() method, which returns an instance of that class. (Any necessary instantiation presumably happens inside the method implementation.)
__________________
-- Greg |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UK weather maps | motobarsteward | SageTV United Kingdom | 3 | 01-19-2009 03:17 PM |
Weather maps (extended maps) | Dean_H | SageMC Custom Interface | 0 | 11-09-2008 10:15 AM |
UK Weather Maps | simonk1969 | SageMC Custom Interface | 1 | 04-15-2008 01:13 AM |
How about Google Maps for Sage? | fizzylime | SageTV Customizations | 4 | 04-30-2005 08:08 AM |
Weather maps, anyone?? | RenHoek | SageTV Customizations | 60 | 10-24-2004 12:11 PM |