help needed for small modification of service.library.data.provider
#1
Question 
Hi, I would like to add a "resume watching" of movies/episodes functionality to the home screen of my skin.
The service.library.data.provider script provides great functionality for this, with one small exception:

The recommendedmovies tag retrieves only the resumable movies, which is the desired result.
But the recommendedepisodes tag retrieves what xbmc calls "tv shows in progress"...these are not only episodes you have started watching
and haven't finished, but all tv shows with remaining unwatched episodes (this is great for general recommendation purposes but not resume purposes).

So in order to accomplish what I want, I tried editing the library.py file and changing the _fetch_recommended_episodes function to this
(basically a copy of the recommendedmovies function with changed details):

PHP Code:
def _fetch_recommended_episodesselfuseCache False ):
        
data self._get_data"recommendedepisodes"useCache )
        if 
data is not None:
            return 
data
            
        
# Set that we're getting updated data
        
self.WINDOW.setProperty"recommendedepisodes-data""LOADING" )
        
        
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", "writer", "cast", "dateadded", "lastplayed"], "limits": {"end": %d},' self.LIMIT
        json_query 
xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "lastplayed"}, "filter": {"field": "inprogress", "operator": "true", "value": ""}}}' %json_string)
        
json_query unicode(json_query'utf-8'errors='ignore')
        
        
self.WINDOW.setProperty"recommendedepisodes-data"json_query )
        
self.WINDOW.setProperty"recommendedepisodes",strftime"%Y%m%d%H%M%S",gmtime() ) )
        
        return 
json_query 

Needless to say, this didn't work. I am not at all experienced in python development, I just tried changing what appeared logical to me Angel
Any assistance would be appreciated..
Reply
#2
For recommended episodes, it's not enough to just change the library.py (the functions that actually gets the data), you'll ned to change how that data is processed in default.py (the functions that generate a list from the data.)

The current function parse_tvshows_recommended expects two sets of data - a list of TV shows that are in progress, and an episode for each in progress TV show. Your updated function (which looks correct, btw, though I haven't tested it, and you haven't provided any debug logs which might give a hint if your code is working correctly or not) is only returning one set of data - a list of all in progress episodes.

You may be able to simply redirect the recommended episodes to be processed by parse_tvshows within defauly.py, which does only expect the set of data.

Also, make sure you enable debug logging so you can actually see where your code is failing, and its probably worth enabling verbose debug logging for JSON-RPC, too Smile
Reply
#3
Genius Blush
It worked....a simple redirect to parse_tvshows gives the desired result.

Thanks again mate!

Big Grin
Reply
#4
I made a unified resume list, combining recommendedmovies and my modified recommendedepisodes, similarly to "recentvideos". It works well, and is sorted by lastplayed:

PHP Code:
elif self.TYPE == "resumevideos" :
            
listA = []
            
listB = []
            
dateListA = []
            
dateListB = []
            
self.parse_movies'recommendedmovies'32006listAdateListA"lastplayed" )
            
self.parse_tvshows'recommendedepisodes'32010listBdateListB"lastplayed" )
            
full_liz self._combine_by_datelistAdateListAlistBdateListB 

I call this by using:
<content target="video">plugin://service.library.data.provider?type=resumevideos&amp;reload=$INFO[Window.Property(resumevideos)]</content>

The only issue is that it doesn't automatically update like it does with the other tags....if I push F5 and refresh the skin, I can see the updated list with no problem.

Any ideas?

(I don't see any errors in the log, but I can post it if you need it.)
Reply
#5
Are you setting the window property resumevideos

Code:
self.WINDOW.setProperty( "resumevideos",strftime( "%Y%m%d%H%M%S",gmtime() ) )

whenever the underlying data is updated in library.py? (so at the same time as both recommendedmovies and recommendedepisodes - the same way the window property for recentvideos is set at the same time as both recentmovies and recentepisodes)

The lists are reloaded by tricking XBMC into thinking that we want it to display a different list. We do this by saving the date/time the data was updated to a window property, and including that window property in the URI as the reload parameter. Then, when the data is updated, the URI changes as it now includes a different date/time and XBMC reloads the list.

(A unified resumevideos could be a nice addition to the official plugin. Have you considered using the original recommendepisodes library.py function, but adding an option to parse_tvshows_recommended that only returns episodes in progress. Then the plugin could have recommendepisodes as-is, and the new resumeepisodes and resumevideos. As it wouldn't require any additional data to be grabbed in library.py, I suspect BigNoid (whose plugin this is, and who is the gatekeeper for pull requests) would at least consider including it.)
Reply
#6
Ah that's where the issue is... yes, once I added that line it's refreshing properly.

That's a good idea with regard to the option in parse_tvshows_recommended, though a little above my skill level (first day with python). I would be more than happy to share my additions to the script with BigNoid, provided they are efficient enough compared to your suggestion.. I haven't tried before, but I presume you are referring to the "Pull Requests" section on github? I will look into it.

Thank you for taking the time to help me out!
Reply
#7
There's a nice guide to github - including doing pull requests - here -> http://forum.xbmc.org/showthread.php?tid=160103
Reply

Logout Mark Read Team Forum Stats Members Help
help needed for small modification of service.library.data.provider0