org.jmythapi.protocol.response
Interface IProgramInfoList

All Superinterfaces:
Cloneable, IPropertyAware<IProgramInfoList.Props>, Iterable<IProgramInfo>, IVersionable
All Known Implementing Classes:
ProgramInfoList

public interface IProgramInfoList
extends Iterable<IProgramInfo>, IVersionable, IPropertyAware<IProgramInfoList.Props>

An interface to get a list of MythTV recordings.

This object represents a list of finished, pending or scheduled MythTV recording.

Request example:


    // query all available recordings
    IProgramInfoList allRecordings = backend.queryRecordings();
    
    // print the channel, length, file-size and title of all recordings
    System.out.println("Channel | Length  | Size     | Title");
    for(IProgramInfo program : allRecordings) {
       // print out the found recodings
       System.out.println(String.format(
          "%-5s | %3d min | %8s | %s",
          program.getChannelSign(),
          program.getDuration(),
          EncodingUtils.getFormattedFileSize(Locale.ENGLISH,program.getFileSize()),
          program.getFullTitle()
       ));			
    }
 

The above example will output, e.g.

 Channel | Length  | Size     | Title
 PULS 4  | 137 min |  4,06 GB | Das Schweigen der Lämmer
 PULS 4  | 137 min |  3,71 GB | Ein Vogel auf dem Drahtseil
 

Response example:


<00>TITLE: Das Schweigen der Lämmer | <01>SUBTITLE: Thriller / USA / 1991 | <02>DESCRIPTION: Ein Serienkiller zieht seine blutige Spur durch den mittleren Westen der USA.. | <03>CATEGORY: | <04>CHANNEL_ID: 11123 | <05>CHANNEL_NUMBER: 10123 | <06>CHANNEL_SIGN: PULS 4 | <07>CHANNEL_NAME: PULS 4 | <08>PATH_NAME: myth://192.168.10.201:6543/11123_20110326225800.mpg | <09>FILESIZE_HIGH: 1 | <10>FILESIZE_LOW: 65078508 | <11>START_DATE_TIME: Sat Mar 26 23:03:10 CET 2011 | <12>END_DATE_TIME: Sun Mar 27 01:20:30 CET 2011 | <13>DUPLICATE: false | <14>SHAREABLE: false | <15>FIND_ID: 734589 | <16>HOSTNAME: brain | <17>SOURCE_ID: 0 | <18>CARD_ID: 0 | <19>INPUT_ID: 0 | <20>REC_PRIORITY: 0 | <21>REC_STATUS: -3=> {RECORDED} | <22>REC_ID: 323 | <23>REC_TYPE: 0=> {NOT_RECORDING} | <24>DUP_IN: 0=> {} | <25>DUP_METHOD: 0=> {} | <26>REC_START_TIME: Sat Mar 26 22:58:00 CET 2011 | <27>REC_END_TIME: Sun Mar 27 01:36:00 CET 2011 | <28>REPEAT: false | <29>PROGRAM_FLAGS: 1=> {FL_COMMFLAG} | <30>REC_GROUP: Default | <31>CHAN_COMM_FREE: false | <32>CHANNEL_OUTPUT_FILTERS: | <33>SERIES_ID: | <34>PROGRAM_ID: | <35>LAST_MODIFIED: Sat Apr 02 00:21:57 CEST 2011 | <36>STARS: 0.0 | <37>ORIGINAL_AIRDATE: | <38>HAS_AIRDATE: false | <39>PLAY_GROUP: Default | <40>REC_PRIORITY2: 0 | <41>PARENT_ID: 0 | <42>STORAGE_GROUP: Default | <43>AUDIO_PROPERTIES: 1=> {AUD_STEREO} | <44>VIDEO_PROPERTIES: 0=> {} | <45>SUBTITLE_TYPE: 0=> {} | <46>YEAR: 0
<00>TITLE: Ein Vogel auf dem Drahtseil | <01>SUBTITLE: Komödie / USA / 1989 | <02>DESCRIPTION: Rick Jarmin hat es weiß Gott nicht leicht... | <03>CATEGORY: | <04>CHANNEL_ID: 11123 | <05>CHANNEL_NUMBER: 10123 | <06>CHANNEL_SIGN: PULS 4 | <07>CHANNEL_NAME: PULS 4 | <08>PATH_NAME: myth://192.168.10.201:6543/11123_20110328200900.mpg | <09>FILESIZE_HIGH: 0 | <10>FILESIZE_LOW: -313977244 | <11>START_DATE_TIME: Mon Mar 28 20:14:25 CEST 2011 | <12>END_DATE_TIME: Mon Mar 28 22:31:20 CEST 2011 | <13>DUPLICATE: false | <14>SHAREABLE: false | <15>FIND_ID: 734590 | <16>HOSTNAME: brain | <17>SOURCE_ID: 0 | <18>CARD_ID: 0 | <19>INPUT_ID: 0 | <20>REC_PRIORITY: 0 | <21>REC_STATUS: -3=> {RECORDED} | <22>REC_ID: 324 | <23>REC_TYPE: 0=> {NOT_RECORDING} | <24>DUP_IN: 0=> {} | <25>DUP_METHOD: 0=> {} | <26>REC_START_TIME: Mon Mar 28 20:09:00 CEST 2011 | <27>REC_END_TIME: Mon Mar 28 22:46:00 CEST 2011 | <28>REPEAT: false | <29>PROGRAM_FLAGS: 0=> {} | <30>REC_GROUP: Default | <31>CHAN_COMM_FREE: false | <32>CHANNEL_OUTPUT_FILTERS: | <33>SERIES_ID: | <34>PROGRAM_ID: | <35>LAST_MODIFIED: Sat Apr 02 00:21:55 CEST 2011 | <36>STARS: 0.0 | <37>ORIGINAL_AIRDATE: | <38>HAS_AIRDATE: false | <39>PLAY_GROUP: Default | <40>REC_PRIORITY2: 0 | <41>PARENT_ID: 0 | <42>STORAGE_GROUP: Default | <43>AUDIO_PROPERTIES: 1=> {AUD_STEREO} | <44>VIDEO_PROPERTIES: 0=> {} | <45>SUBTITLE_TYPE: 0=> {} | <46>YEAR: 0

Usage examples

Examples how to get a list of recordings from the backend:

See Also:
IBackend.queryRecordings(), QUERY_RECORDINGS

Nested Class Summary
static class IProgramInfoList.MapKey
          Specifies which key should be used for asMap(MapKey)
static class IProgramInfoList.Props
          The properties of an IProgramInfoList response.
 
Method Summary
 List<IProgramInfo> asList()
          Returns a list of programs.
 List<IProgramInfo> asList(IProgramInfoFilter filter)
          Returns a list of programs.
 Map<String,IProgramInfo> asMap(IProgramInfoList.MapKey mapKey)
          Returns a map containing the unique-id of each program as key and the program as value.
 Object clone()
          Clones this program info list.
 IProgramInfoList filter(IProgramInfoFilter filter)
          Returns a new program list containing only programs that are accepted by the given filter.
 IProgramInfo get(int idx)
          Gets the program-info object at the given index.
 Map<String,Integer> getIndexMap(IProgramInfoList.MapKey mapKey)
          Returns a map containing the unique-id of each program as key and the program-index as value.
 long getTotalDuration()
          Gets the sum of all recording durations.
 long getTotalFilesSize()
          Gets the sum of all file sizes.
 Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop)
          Groups the list of program-infos by the specified program-info property.
 Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop, IProgramInfoFilter filter)
          Groups the list of program-infos by the specified program-info property.
 boolean isEmpty()
          Checks if the program list is empty.
 IProgramInfoList[] multiFilter(IProgramInfoFilter... filters)
          Allows to filter the program list, using multiple filters.
 int size()
          Returns the number of programs contained in this list
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.jmythapi.IVersionable
getVersionNr
 
Methods inherited from interface org.jmythapi.IPropertyAware
getProperties, getProperty, getPropertyClass, getPropertyCount, getPropertyIndex, getPropertyMap, getPropertyValue, getPropertyValue, getPropertyValueObject, getPropertyValues, setPropertyValue, setPropertyValue, setPropertyValueObject
 

Method Detail

size

int size()
Returns the number of programs contained in this list

Returns:
the list size

isEmpty

boolean isEmpty()
Checks if the program list is empty.

Returns:
true if the list is empty.

asList

List<IProgramInfo> asList()
Returns a list of programs.

Use asList(IProgramInfoFilter) if you want to filter out unwanted programs.

Returns:
a list of program-info objects

asList

List<IProgramInfo> asList(IProgramInfoFilter filter)
Returns a list of programs. Only programs accepted by the given filter are returned.

Parameters:
filter - the filter to apply to the list of programs
Returns:
a list of program-info objects

asMap

Map<String,IProgramInfo> asMap(IProgramInfoList.MapKey mapKey)
Returns a map containing the unique-id of each program as key and the program as value.

The input parameter specifies if the unique program-id or recording-id should be used as key.
Please note that multiple different recordings may have the same program-id but different recording-ids.

Returns:
a mapping between the program-ids and programs

getIndexMap

Map<String,Integer> getIndexMap(IProgramInfoList.MapKey mapKey)
Returns a map containing the unique-id of each program as key and the program-index as value.

The result of this function can be used to determine the index of a program within the program-list.

The input parameter specifies if the unique program-id or recording-id should be used as key.
Please note that multiple different recordings may have the same program-id but different recording-ids.

Returns:
an index list

filter

IProgramInfoList filter(IProgramInfoFilter filter)
Returns a new program list containing only programs that are accepted by the given filter.

Usage example:


The following example shows how to filter a list of programs by the programs recording-status.

    // our list of programs
    IProgramInfoList programs = ...; 
 
    // creating the program filter
    IProgramInfoFilter filter = ProgramInfoFilters.recordingStatus(IProgramRecordingStatus.Status.WILL_RECORD);
 
    // filter programs
    IProgramInfoList filteredPrograms = programs.filter(filter);
 
    // loop through the filtered list 
    for (IProgramInfo program : filteredPrograms) {
       System.out.println(String.format(
          "%1$tF %1$tT- %2$s (%3$s)",
          program.getStartTime(),
          program.getFullTitle(),
          program.getChannelSign()
       ));
    }
 

See ProgramInfoFilters for a list of predefined filters.

Parameters:
filter - the program filter to use or null if no filtering should be done
Returns:
a list of filtered program-info objects

multiFilter

IProgramInfoList[] multiFilter(IProgramInfoFilter... filters)
Allows to filter the program list, using multiple filters.

For each filter a list of matching program-info objects is returned.

Parameters:
filters - a list of filters
Returns:
an array with the same length as the amount of filters.

get

IProgramInfo get(int idx)
Gets the program-info object at the given index.

Parameters:
idx - the index
Returns:
the found program

groupBy

Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop)
Groups the list of program-infos by the specified program-info property.

Usage example:

The following example groups all recordings by their storage group.

    // get a list of all recordings
    IProgramInfoList allRecordings = backend.queryRecordings();
    
    // group recordings by storage group
    Map<Object,IProgramInfoList> recordingsByStorageGroup = allRecordings.groupBy(IProgramInfo.Props.STORAGE_GROUP);
    for(Entry<Object,IProgramInfoList> entry : recordingsByStorageGroup.entrySet()) {
       System.out.println(String.format(
          "\r\nSTORAGE-GROUP '%s': %02d recordings",
          entry.getKey(),
          entry.getValue().size()
       ));
       
       for(IProgramInfo program : entry.getValue()) {
          System.out.println(String.format(
             "- %s",
             program.getFullTitle()
          ));
       }
    }
 

Parameters:
prop - the program-info property that is used for grouping
Returns:
a map containing the found property values as keys and the grouped lists of programs as values

groupBy

Map<Object,IProgramInfoList> groupBy(IProgramInfo.Props prop,
                                     IProgramInfoFilter filter)
Groups the list of program-infos by the specified program-info property. Only programs matching the given program-filter are returned.

Usage example:

The following example groups all recordings by their categories.

    // get a list of all recordings
    IProgramInfoList allRecordings = backend.queryRecordings();
 
    // optionally define a filter
    IProgramInfoFilter filter = null;
    
    // group recordings by category
    Map<Object,IProgramInfoList> recordingsByCategory = allRecordings.groupBy(IProgramInfo.Props.CATEGORY, filter);
    for(Entry<Object,IProgramInfoList> entry : recordingsByCategory.entrySet()) {
       System.out.println(String.format(
          "\r\nCATEGORY '%s': ",
          entry.getKey()
       ));
       			
       for(IProgramInfo program : entry.getValue()) {
          System.out.println(String.format(
             "- %s",
             program.getFullTitle()
          ));
       }
    }
 

Parameters:
prop - the program-info property that is used for grouping
filter - the program filter to use or null if no filtering should be done
Returns:
a map containing the found property values as keys and the grouped lists of programs as values

getTotalFilesSize

long getTotalFilesSize()
Gets the sum of all file sizes.

Returns:
the total size of all recording files
See Also:
IProgramInfo.getFileSize()

getTotalDuration

long getTotalDuration()
Gets the sum of all recording durations.

Returns:
the total duration of all recordings
See Also:
IBasicProgramInfo.getDuration()

clone

Object clone()
             throws CloneNotSupportedException
Clones this program info list.

Returns:
a copy of this list
Throws:
CloneNotSupportedException


Copyright © 2008-2013. All Rights Reserved.