EpisodeObject for Channel Listing - wmc2Plex (PlexWMC)

I am working on a plugin that pulls streaming info, metadata, channel and program info and images from ServerWMC backend.  I currently can populate a list of channels and stream those channels via DLNA as long as your Tuner card supports DLNA.  I currently use an HD Home Run Prime.  

 

My current problem is when I click on the Channel object I want it to show a listing of everything coming up along with what is playing.  I also want them to be functional objects so I can put code in to handle scheduling recordings if you click on a future program.  Right now when I click on the Channel it will only show me the initial program  in the array because it is not putting it all in one container to return.  Below is the code that handles that and I can't for the life of me figure out why it is not working as intended.  the problem seems to be in the function CreateEO.  It is not including_container even though in the internal callback I have it doing so.  Any help on this is greatly appreciated.

####################################################################################################
@route(PREFIX +'/submenu/{title}')
def SubMenu(menu):
    oc = ObjectContainer(title2=menu, no_cache=True)

    #Connect and Get Channel List
    resultsArray = socketClient('GetChannels', '')

    if DEBUG=='Verbose':
            Log.Debug(resultsArray)

    #Loop through resultsArray to build Channel objects
    for result in resultsArray:
            channelArray = result.split('|')
            channelID = channelArray[0]
            try:
                    channelImageFile = channelArray[5].split('/')[-1] #'file://' + channelArray[5].split('@')[-1]
            except:
                    channelImageFile = ''
            channelNumber = channelArray[2]
            channelName = channelArray[8]
            channelTitle = channelName + '(' + channelNumber + ')'
            channelURL = channelArray[9]
            Thumb = channelImageFile
            summaryData = getChannelInfo(chID=channelID, progItem='programName', infoType='nowPlaying')
            summaryData = summaryData + ' : ' + getChannelInfo(chID=channelID, progItem='programOverview', infoType='nowPlaying')
            Summary='Now Playing : ' + summaryData

            if DEBUG=='Normal' or DEBUG=='Verbose':
                    Log.Debug(channelImageFile + ' - ' + channelArray[5])
                    Log.Debug(channelTitle + ', ' + channelURL + ', ' + channelImageFile + ', '
                              + channelNumber + ', ' + channelName)

            if menu=='Channels':
                    oc.add(CreateCO(url=channelURL, chID=channelID, title=channelTitle, summary=Summary, thumb=R(Thumb)))
                                                  
    return oc

####################################################################################################
@route(PREFIX + ‘/CreateCO’)
def CreateCO(url, chID, title, summary, thumb):

    #check preferences for DLNA playback - *put in for future use currently uses DLNA no matter what*
    co = TVShowObject(
            rating_key = url,
            key = Callback(CreateChannel, url=url, chID=chID, title=title, summary=summary, thumb=thumb),
            title = title,
            summary = summary,
            thumb = thumb
            )

    if DEBUG=='Verbose':
            Log.Debug(title + ', ' + url + ', ' + str(thumb))

    return co

####################################################################################################
@route(PREFIX + ‘/CreateChannel’)
def CreateChannel(url, chID, title, summary, thumb, include_container=False):
Log.Debug(title)

    oc = ObjectContainer(title2=title, no_cache=True)

    #Get Start and end datetime and convert to seconds
    startDt = getTime(datetime.datetime.utcnow())
    endDt = int(startDt + (timedelta(days=(EPGDAYS))).total_seconds())

    #build request string
    sendCommand = 'GetEntries|{0}|{1}|{2}'.format(chID, startDt, endDt)

    #Connect and get channel/program info
    resultsArray = socketClient(sendCommand, '')

    if DEBUG=='Normal' or DEBUG=='Verbose':
            Log.Debug('Request sent: ' + sendCommand)
    if DEBUG=='Verbose':
            Log.Debug(resultsArray)

    #Loop through resultsArray to build Channel objects
    for result in resultsArray:             
            infoArray = result.split('|')
            programID = infoArray[0] + '-' + infoArray[16]
            programName = infoArray[1]
            programStartDt = infoArray[3]
            programEndDt = infoArray[4]
            programOverview = infoArray[5]
            programImage = infoArray[14]
            programEpisodeTitle = infoArray[15]
            try:
                    programRating = getRating(infoArray[8])
            except:
                    programRating = 'NR'

            if DEBUG=='Verbose':
                    Log.Debug(programID + ',' + programName + ',' + programStartDt + ',' + programEndDt +
                            ',' + programOverview + ',' + programRating)
            oc.add(
                    CreateEO(
                            url=url,
                            title=programName,
                            summary=programOverview,
                            thumb=programImage
                            ))               
                                                  
    return oc

####################################################################################################
@route(PREFIX + ‘/CreateEO/{title}’)
def CreateEO(url, title, summary, thumb, include_container=False):

    #check preferences for DLNA playback - *put in for future use, currently uses DLNA no matter what*
    if Prefs['serverwmc_playback']=='DLNA':
            eo = EpisodeObject(
                    rating_key = url,
                    key = Callback(CreateEO, url=url, title=title, summary=summary, thumb=thumb, include_container=True),
                    title = title,
                    summary = summary,
                    duration = DURATION,
                    thumb=thumb,
                    items = [
                            MediaObject(
                                    parts = [PartObject(key=(url))],
                                    container = 'mpegts',
                                    video_resolution = 1080,
                                    bitrate = 20000,
                                    video_codec = 'mpeg2video',
                                    audio_codec = 'AC3',
                                    optimized_for_streaming = True
                                    )
                            ]
                    )
    else:
            eo = EpisodeObject(
                    rating_key = url,
                    key = Callback(CreateEO, url=url, title=title, summary=summary, thumb=thumb, include_container=True),
                    title = title,
                    summary = summary,
                    duration = DURATION,
                    thumb=thumb,
                    items = [
                            MediaObject(
                                    parts = [PartObject(key=(url))],
                                    container = 'mpegts',
                                    video_resolution = 1080,
                                    bitrate = 20000,
                                    video_codec = 'mpeg2video',
                                    audio_codec = 'AC3',
                                    optimized_for_streaming = True
                                    )
                            ]
                    )

    if DEBUG=='Verbose':
            Log.Debug(title + ', ' + url + ', ' + str(thumb))

    if include_container:
            return ObjectContainer(objects=[eo])
            Log.Debug('ADDED CONTAINER - ' + title)
    else:
            Log.Debug('ADDED OBJECT - ' + title)
            return eo

Declare include_container as a boolean in the route:


@route(PREFIX + ‘/CreateEO/{title}’, include_container=bool)

Thank Sander.  I tried what you suggested.

After some testing I get the same result but the interesting part is it does list all the program coming up next on the Roku, Android, and PHT.  It is just not doing it on the browser version.

Its not listing it exactly how I would like but it is pulling the list.  

This is what it looks like via Web:

![post-79069-0-03953100-1419347248.png|690x377](upload://67WjretLNUC0C8FcIZQa05aDoM7.png)

![post-79069-0-85504500-1419347280.png|690x405](upload://uS5HOvm3o25U52uyGw9BRZGQfz1.png)

This is on PHT:

![post-79069-0-60371300-1419347316.png|690x387](upload://pOfCM1hq9vroH3JaRTMEHYOLILV.png)

![post-79069-0-32950700-1419347334.png|690x388](upload://l0Viumkmq80k5SGzgR9YPxoscfi.png)

Not sure why on the web it only shows the first listing.

This is lower on the ToDo list but I would like to make it where the channel list and program list are always in a detail view not tile view.  I know on some clients that will not be possible like Roku(I think).

Just learned something new about PHT.  I never knew if you move all the way to the right you get a list view.  That actually shows the listing exactly how I want so, this functions how I like in the PHT client.  Just need to figure out whats the deal with the Web client not showing all listings.

I figured it out.  I was using the url as the rating key but since the url is always the same for that channel it thought it was the same item because it had the same index.  I changed the rating_key to the title which will always be different since it is the time + program name and it list them properly now in the Web as well.  Not sure why this did not act the same on other clients.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.