Skip to content

Commit

Permalink
New option for recently AIRED items
Browse files Browse the repository at this point in the history
  • Loading branch information
amitkeret committed Jan 26, 2014
1 parent af6339a commit 9b3349e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
35 changes: 34 additions & 1 deletion default.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(self):
self._fetch_info_randomitems()
self._fetch_info_recommended()
self._fetch_info_recentitems()
self._fetch_info_recentaireditems()
b_total = datetime.datetime.now()
c_total = b_total - a_total
log('Total time needed for all queries: %s' % c_total)
Expand All @@ -81,7 +82,7 @@ def _init_vars(self):
self.LIMIT = 20

def _on_change(self):
clearlist_groups = ['Recommended','Random','Recent']
clearlist_groups = ['Recommended','Random','Recent','RecentAired']
clearlist_types = ['Movie','Episode','MusicVideo','Album', 'Artist','Song','Addon']
for item_group in clearlist_groups:
for item_type in clearlist_types:
Expand All @@ -91,11 +92,13 @@ def _on_change(self):
self._fetch_info_randomitems()
self._fetch_info_recommended()
self._fetch_info_recentitems()
self._fetch_info_recentaireditems()

def _init_property(self):
self.WINDOW.setProperty('SkinWidgets_Recommended', '%s' % __addon__.getSetting("recommended_enable"))
self.WINDOW.setProperty('SkinWidgets_RandomItems', '%s' % __addon__.getSetting("randomitems_enable"))
self.WINDOW.setProperty('SkinWidgets_RecentItems', '%s' % __addon__.getSetting("recentitems_enable"))
self.WINDOW.setProperty('SkinWidgets_RecentAiredItems', '%s' % __addon__.getSetting("recentaireditems_enable"))
self.WINDOW.setProperty('SkinWidgets_RandomItems_Update', 'false')
self.RANDOMITEMS_UPDATE_METHOD = int(__addon__.getSetting("randomitems_method"))
self.RECENTITEMS_HOME_UPDATE = __addon__.getSetting("recentitems_homeupdate")
Expand Down Expand Up @@ -159,6 +162,18 @@ def _fetch_info_recentitems(self):
b = datetime.datetime.now()
c = b - a
log('Total time needed to request recent items queries: %s' % c)

def _fetch_info_recentaireditems(self):
a = datetime.datetime.now()
if __addon__.getSetting("recentaireditems_enable") == 'true':
self.RECENTAIREDITEMS_UNPLAYED = __addon__.getSetting("recentaireditems_unplayed") == 'true'
self._fetch_movies('RecentAiredMovie')
self._fetch_tvshows('RecentAiredEpisode')
self._fetch_musicvideo('RecentAiredMusicVideo')
self._fetch_albums('RecentAiredAlbum')
b = datetime.datetime.now()
c = b - a
log('Total time needed to request recent items queries: %s' % c)

def _fetch_movies(self, request):
if not xbmc.abortRequested:
Expand All @@ -169,6 +184,10 @@ def _fetch_movies(self, request):
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}, "filter": {"field": "playcount", "operator": "is", "value": "0"}}}' %json_string)
elif request == 'RecentMovie':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}}}' %json_string)
elif request == 'RecentAiredMovie' and self.RECENTAIREDITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year"}, "filter": {"field": "playcount", "operator": "is", "value": "0"}}}' %json_string)
elif request == 'RecentAiredMovie':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year"}}}' %json_string)
elif request == "RandomMovie" and self.RANDOMITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
else:
Expand Down Expand Up @@ -319,6 +338,10 @@ def _fetch_tvshows(self, request):
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 == 'RecentAiredEpisode' and self.RECENTAIREDITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year"}, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
elif request == 'RecentAiredEpisode':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year"}}}' %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:
Expand Down Expand Up @@ -416,6 +439,8 @@ def _fetch_musicvideo(self, request):
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "playcount" }}}' %json_string)
elif request == 'RecentMusicVideo':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded"}}}' %json_string)
elif request == 'RecentAiredMusicVideo':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year"}}}' %json_string)
else:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random"}}}' %json_string)
json_query = unicode(json_query, 'utf-8', errors='ignore')
Expand Down Expand Up @@ -470,6 +495,8 @@ def _fetch_albums(self, request):
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "playcount" }}}' %json_string)
elif request == 'RecentAlbum':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "dateadded" }}}' %json_string)
elif request == 'RecentAiredAlbum':
json_query = xbmc.executeJSONRPC('%s "sort": {"order": "descending", "method": "year" }}}' %json_string)
else:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random"}}}' %json_string)
json_query = unicode(json_query, 'utf-8', errors='ignore')
Expand Down Expand Up @@ -627,19 +654,25 @@ def _update(self, type):
if type == 'movie':
self._fetch_movies('RecommendedMovie')
self._fetch_movies('RecentMovie')
self._fetch_movies('RecentAiredMovie')
elif type == 'episode':
self._fetch_tvshows_recommended('RecommendedEpisode')
self._fetch_tvshows('RecentEpisode')
self._fetch_tvshows('RecentAiredEpisode')
elif type == 'video':
#only on db update
self._fetch_movies('RecommendedMovie')
self._fetch_tvshows_recommended('RecommendedEpisode')
self._fetch_movies('RecentMovie')
self._fetch_movies('RecentAiredMovie')
self._fetch_tvshows('RecentEpisode')
self._fetch_tvshows('RecentAiredEpisode')
self._fetch_musicvideo('RecentMusicVideo')
self._fetch_musicvideo('RecentAiredMusicVideo')
elif type == 'music':
self._fetch_albums('RecommendedAlbum')
self._fetch_albums('RecentAlbum')
self._fetch_albums('RecentAiredAlbum')
if self.RANDOMITEMS_UPDATE_METHOD == 1:
# update random if db update is selected instead of timer
if type == 'video':
Expand Down
4 changes: 4 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ msgstr ""
msgctxt "#32014"
msgid "* Hidden to prevent spoilers *"
msgstr ""

msgctxt "#32015"
msgid "Recently aired Items"
msgstr ""
4 changes: 4 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
<setting label="32011" type="bool" id="recentitems_unplayed" subsetting="true" default="true" enable="eq(-1,true)"/>
<setting label="32010" type="bool" id="recentitems_homeupdate" default="false"/>
</category>
<category label="32015">
<setting label="32015" type="bool" id="recentaireditems_enable" default="true"/>
<setting label="32011" type="bool" id="recentaireditems_unplayed" subsetting="true" default="true" enable="eq(-1,true)"/>
</category>
</settings>

0 comments on commit 9b3349e

Please sign in to comment.