Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Closes #31, compleates ability to add and remove items from tvshow li…

…sts. Also compleated the missing parts to have 'local' and 'watchlist' tags on tvshows.
  • Loading branch information...
commit 5678ac8e457636cbbbcd4278203c2feadfa04b80 1 parent 6e2f148
@othrayte othrayte authored
View
3  recommend.py
@@ -61,6 +61,9 @@ def showRecommendedTVShows():
xbmcgui.Dialog().ok(__language__(1201).encode( "utf-8", "ignore" ), __language__(1159).encode( "utf-8", "ignore" )) # Trakt Utilities, there are no tv shows recommended for you
return
+ for tvshow in tvshows:
+ tvshow['watchlist'] = tvshow['in_watchlist']
+
# display recommended tv shows
import windows
ui = windows.TVShowsWindow("tvshows.xml", __settings__.getAddonInfo('path'), "Default")
View
34 resources/skins/Default/720p/tvshows.xml
@@ -117,6 +117,23 @@
<width>100</width>
<height>150</height>
<info>ListItem.Icon</info>
+ <aspectratio>scale</aspectratio>
+ </control>
+ <control type="image">
+ <posx>58</posx>
+ <posy>45</posy>
+ <width>42</width>
+ <height>42</height>
+ <texture scalediffuse="false">local.png</texture>
+ <visible>ListItem.Property(Available)</visible>
+ </control>
+ <control type="image">
+ <posx>58</posx>
+ <posy>45</posy>
+ <width>42</width>
+ <height>42</height>
+ <texture scalediffuse="false">watchlist.png</texture>
+ <visible>ListItem.Property(Watchlist)</visible>
</control>
</itemlayout>
<focusedlayout width="140" height="195">
@@ -126,6 +143,23 @@
<width>130</width>
<height>195</height>
<info>ListItem.Icon</info>
+ <aspectratio>scale</aspectratio>
+ </control>
+ <control type="image">
+ <posx>77</posx>
+ <posy>0</posy>
+ <width>53</width>
+ <height>53</height>
+ <texture scalediffuse="false">local.png</texture>
+ <visible>ListItem.Property(Available)</visible>
+ </control>
+ <control type="image">
+ <posx>77</posx>
+ <posy>0</posy>
+ <width>53</width>
+ <height>53</height>
+ <texture scalediffuse="false">watchlist.png</texture>
+ <visible>ListItem.Property(Watchlist)</visible>
</control>
</focusedlayout>
</control>
View
7 trending.py
@@ -68,6 +68,7 @@ def showTrendingMovies():
def showTrendingTVShows():
tvshows = getTrendingTVShowsFromTrakt()
+ watchlist = traktShowListByTvdbID(getWatchlistTVShowsFromTrakt())
if tvshows == None: # tvshows = None => there was an error
return # error already displayed in utilities.py
@@ -76,6 +77,12 @@ def showTrendingTVShows():
xbmcgui.Dialog().ok("Trakt Utilities", "there are no trending tv shows")
return
+ for tvshow in tvshows:
+ if tvshow['imdb_id'] in watchlist:
+ tvshow['watchlist'] = True
+ else:
+ tvshow['watchlist'] = False
+
# display trending tv shows
import windows
ui = windows.TVShowsWindow("tvshows.xml", __settings__.getAddonInfo('path'), "Default")
View
33 utilities.py
@@ -184,6 +184,15 @@ def traktMovieListByImdbID(data):
return trakt_movies
+# get easy access to tvshow by tvdb_id
+def traktShowListByTvdbID(data):
+ trakt_tvshows = {}
+
+ for i in range(0, len(data)):
+ trakt_tvshows[data[i]['tvdb_id']] = data[i]
+
+ return trakt_tvshows
+
# get seen tvshows from trakt server
def getWatchedTVShowsFromTrakt(daemon=False):
data = traktJsonRequest('POST', '/user/library/shows/watched.json/%%API_KEY%%/%%USERNAME%%')
@@ -464,7 +473,7 @@ def getCurrentPlaylistLengthFromXBMC():
return None
def getMovieIdFromXBMC(imdb_id, title):
- # httpapi till jsonrpc supports selecting a single movie
+ # httpapi till jsonrpc supports searching for a single movie
# Get id of movie by movies IMDB
Debug("Searching for movie: "+imdb_id+", "+title)
@@ -481,7 +490,27 @@ def getMovieIdFromXBMC(imdb_id, title):
return -1
return match[0]
-
+
+def getShowIdFromXBMC(tvdb_id, title):
+ # httpapi till jsonrpc supports searching for a single show
+ # Get id of show by shows tvdb id
+
+ Debug("Searching for show: "+str(tvdb_id)+", "+title)
+
+ match = xbmcHttpapiQuery(
+ " SELECT idShow FROM tvshow"+
+ " WHERE c12='%(tvdb_id)s'" % {'tvdb_id':xcp(tvdb_id)}+
+ " UNION"+
+ " SELECT idShow FROM tvshow"+
+ " WHERE upper(c00)='%(title)s'" % {'title':xcp(title.upper())}+
+ " LIMIT 1")
+
+ if match == None:
+ Debug("getShowIdFromXBMC: cannot find movie in database")
+ return -1
+
+ return match[0]
+
# returns list of movies from watchlist
def getWatchlistMoviesFromTrakt():
data = traktJsonRequest('POST', '/user/watchlist/movies.json/%%API_KEY%%/%%USERNAME%%')
View
11 windows.py
@@ -298,7 +298,16 @@ def initWindow(self, tvshows, type):
def onInit(self):
if self.tvshows != None:
for tvshow in self.tvshows:
- self.getControl(TVSHOW_LIST).addItem(xbmcgui.ListItem(tvshow['title'], '', tvshow['images']['poster']))
+ li = xbmcgui.ListItem(tvshow['title'], '', tvshow['images']['poster'])
+ if not ('idShow' in tvshow):
+ tvshow['idShow'] = getShowIdFromXBMC(tvshow['tvdb_id'], tvshow['title'])
+ if tvshow['idShow'] != -1:
+ li.setProperty('Available','true')
+ if self.type <> 'watchlist':
+ if 'watchlist' in tvshow:
+ if tvshow['watchlist']:
+ li.setProperty('Watchlist','true')
+ self.getControl(TVSHOW_LIST).addItem(li)
self.setFocus(self.getControl(TVSHOW_LIST))
self.listUpdate()
else:
Please sign in to comment.
Something went wrong with that request. Please try again.