Grouping recent episodes from same tvshow

I’ve been trying to make this patch by texaco here works :

http://forum.kodi.tv/showthread.php?tid=172362

[Image: uNPDdT6.png]

patch

I was going to use it for my custom skin.. but i wanted to understand how it works so i tried it on confluence first…

Replaced both IncludesHomeRecentlyAdded.xml and default.py from service skin widgets (Conluence 14.2)
But all i got is blank recent episodes…

[Image: 6hrqr1h.png]

As far as i can tell.. these are the relevant changes in both files :

Code:
</focusedlayout>
                                        <content>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.1.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.1.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.1.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.1.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.1.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.1.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.1.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.2.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.2.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.2.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.2.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.2.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.2.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.2.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.3.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.3.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.3.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.3.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.3.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.3.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.3.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.4.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.4.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.4.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.4.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.4.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.4.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.4.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.5.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.5.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.5.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.5.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.5.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.5.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.5.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.6.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.6.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.6.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.6.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.6.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.6.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.6.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.7.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.7.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.7.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.7.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.7.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.7.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.7.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.8.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.8.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.8.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.8.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.8.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.8.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.8.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.9.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.9.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.9.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.9.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.9.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.9.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.9.Title))</visible>
                                                </item>
                                                <item>
                                                        <label>$INFO[Window.Property(RecentEpisodeGrouped.10.Title)]</label>
                                                        <label2>$INFO[Window.Property(RecentEpisodeGrouped.10.TVshowTitle)] - $INFO[Window.Property(RecentEpisodeGrouped.10.EpisodeNo)]</label2>
                                                        <property name="addeddate">$INFO[Window.Property(RecentEpisodeGrouped.10.Premiered)]</property>
                                                        <onclick>$INFO[Window.Property(RecentEpisodeGrouped.10.Play)]</onclick>
                                                        <icon>-</icon>
                                                        <thumb>$INFO[Window.Property(RecentEpisodeGrouped.10.Art(thumb))]</thumb>
                                                        <visible>!IsEmpty(Window.Property(RecentEpisodeGrouped.10.Title))</visible>
                                                </item>
                                        </content>
                                </control>

default.py for service.skin.widgets

Code:
def _fetch_tvshows(self, request):
        if not xbmc.abortRequested:
            season_folders = __addon__.getSetting("randomitems_seasonfolders")
            json_string = '{"jsonrpc": "2.0", "id": 1, "method": "VideoLibrary.GetEpisodes", "params": { "properties": ["title", "playcount", "season", "episode", "showtitle", "plot", "file", "rating", "resume", "tvshowid", "art", "streamdetails", "firstaired", "runtime"], "limits": {"end": %d},' %self.LIMIT
            if request == 'RecentEpisode' and self.RECENTITEMS_UNPLAYED:
                json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
            elif request == 'RecentEpisode':
                json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}}}' %json_string)
            elif request == 'RandomEpisode' and self.RANDOMITEMS_UNPLAYED:
                json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
            else:
                json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }}}' %json_string)
            json_query = unicode(json_query, 'utf-8', errors='ignore')
            json_query = simplejson.loads(json_query)
            if json_query.has_key('result') and json_query['result'].has_key('episodes'):
                self._clear_properties(request)
                count = 0
                for item in json_query['result']['episodes']:
                    count += 1
                    '''
                    # This part is commented out because it takes 1.5second extra on my system to request these which doubles the total time.
                    # Hence the ugly path hack that will require users to have season folders.
                    json_query2 = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShowDetails", "params": {"properties": ["file", "studio"], "tvshowid":%s}, "id": 1}' %item['tvshowid'])
                    json_query2 = unicode(json_query2, 'utf-8', errors='ignore')
                    json_query2 = simplejson.loads(json_query2)
                    path = json_query2['result']['tvshowdetails']['file']
                    studio = json_query2['result']['tvshowdetails']['studio'][0]
                    '''
                    if season_folders == 'true':
                        path = os.path.split(media_path(item['file']))[0]
                    else:
                        path = media_path(item['file'])
                    episode = ("%.2d" % float(item['episode']))
                    season = "%.2d" % float(item['season'])
                    episodeno = "s%se%s" %(season,episode)
                    #seasonthumb = ''
                    rating = str(round(float(item['rating']),1))
                    if (item['resume']['position'] and item['resume']['total']) > 0:
                        resume = "true"
                        played = '%s%%'%int((float(item['resume']['position']) / float(item['resume']['total'])) * 100)
                    else:
                        resume = "false"
                        played = '0%'
                    if item['playcount'] >= 1:
                        watched = "true"
                    else:
                        watched = "false"
                    if not self.PLOT_ENABLE and watched == "false":
                        plot = __localize__(32014)
                    else:
                        plot = item['plot']
                    art = item['art']
                    path = media_path(item['file'])
                    play = 'XBMC.RunScript(' + __addonid__ + ',episodeid=' + str(item.get('episodeid')) + ')'
                    streaminfo = media_streamdetails(item['file'].encode('utf-8').lower(),
                                                     item['streamdetails'])
                    self.WINDOW.setProperty("%s.%d.DBID"                % (request, count), str(item.get('episodeid')))
                    self.WINDOW.setProperty("%s.%d.Title"               % (request, count), item['title'])
                    self.WINDOW.setProperty("%s.%d.Episode"             % (request, count), episode)
                    self.WINDOW.setProperty("%s.%d.EpisodeNo"           % (request, count), episodeno)
                    self.WINDOW.setProperty("%s.%d.Season"              % (request, count), season)
                    self.WINDOW.setProperty("%s.%d.Plot"                % (request, count), plot)
                    self.WINDOW.setProperty("%s.%d.TVshowTitle"         % (request, count), item['showtitle'])
                    self.WINDOW.setProperty("%s.%d.Rating"              % (request, count), rating)
                    self.WINDOW.setProperty("%s.%d.Runtime"             % (request, count), str(int((item['runtime'] / 60) + 0.5)))
                    self.WINDOW.setProperty("%s.%d.Premiered"           % (request, count), item['firstaired'])
                    self.WINDOW.setProperty("%s.%d.Art(thumb)"          % (request, count), art.get('thumb',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.fanart)"  % (request, count), art.get('tvshow.fanart',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.poster)"  % (request, count), art.get('tvshow.poster',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.banner)"  % (request, count), art.get('tvshow.banner',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.clearlogo)"% (request, count), art.get('tvshow.clearlogo',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.clearart)" % (request, count), art.get('tvshow.clearart',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.landscape)"% (request, count), art.get('tvshow.landscape',''))
                    self.WINDOW.setProperty("%s.%d.Art(tvshow.characterart)"% (request, count), art.get('tvshow.characterart',''))
                    self.WINDOW.setProperty("%s.%d.Resume"              % (request, count), resume)
                    self.WINDOW.setProperty("%s.%d.PercentPlayed"       % (request, count), played)
                    self.WINDOW.setProperty("%s.%d.Watched"             % (request, count), watched)
                    self.WINDOW.setProperty("%s.%d.File"                % (request, count), item['file'])
                    self.WINDOW.setProperty("%s.%d.Path"                % (request, count), path)
                    self.WINDOW.setProperty("%s.%d.Play"                % (request, count), play)
                    self.WINDOW.setProperty("%s.%d.VideoCodec"          % (request, count), streaminfo['videocodec'])
                    self.WINDOW.setProperty("%s.%d.VideoResolution"     % (request, count), streaminfo['videoresolution'])
                    self.WINDOW.setProperty("%s.%d.VideoAspect"         % (request, count), streaminfo['videoaspect'])
                    self.WINDOW.setProperty("%s.%d.AudioCodec"          % (request, count), streaminfo['audiocodec'])
                    self.WINDOW.setProperty("%s.%d.AudioChannels"       % (request, count), str(streaminfo['audiochannels']))
            del json_query

What am i missing here?
Is the property “RecentEpisodeGrouped” supposed to be declared first?

Thanks