Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option for recently AIRED items #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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 @@ -74,15 +75,23 @@ def _init_vars(self):
self.Monitor = Widgets_Monitor(update_listitems = self._update, update_settings = self._on_change)

def _on_change(self):
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:
clear = item_group + item_type
self._clear_properties(clear)
self._init_property()
self._fetch_info_randomitems()
self._fetch_info_recommended()
self._fetch_info_recentitems()
self._fetch_info_recentaireditems()

def _init_property(self):
WINDOW.setProperty('SkinWidgets_Recommended', '%s' % __addon__.getSetting("recommended_enable"))
WINDOW.setProperty('SkinWidgets_RandomItems', '%s' % __addon__.getSetting("randomitems_enable"))
WINDOW.setProperty('SkinWidgets_RecentItems', '%s' % __addon__.getSetting("recentitems_enable"))
WINDOW.setProperty('SkinWidgets_RecentAiredItems', '%s' % __addon__.getSetting("recentaireditems_enable"))
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 @@ -141,7 +150,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._fetch_movies('RecentAiredMovie')
self._fetch_tvshows('RecentAiredEpisode')
self._fetch_musicvideos('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:
data = REQ.movies(request)
Expand Down Expand Up @@ -209,19 +229,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_episodes_recommended('RecommendedEpisode')
self._fetch_tvshows('RecentEpisode')
self._fetch_tvshows('RecentAiredEpisode')
elif type == 'video':
#only on db update
self._fetch_movies('RecommendedMovie')
self._fetch_episodes_recommended('RecommendedEpisode')
self._fetch_movies('RecentMovie')
self._fetch_movies('RecentAiredMovie')
self._fetch_tvshows('RecentEpisode')
self._fetch_tvshows('RecentAiredEpisode')
self._fetch_musicvideos('RecentMusicVideo')
self._fetch_musicvideos('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 All @@ -242,7 +268,7 @@ def __init__(self, *args, **kwargs):

def onDatabaseUpdated(self, database):
self.update_listitems(database)

def onSettingsChanged(self):
self.update_settings()

Expand All @@ -257,7 +283,7 @@ def onPlayBackStarted(self):
xbmc.sleep(1000)
# Set values based on the file content
if (self.isPlayingAudio()):
self.type = "music"
self.type = "music"
else:
if xbmc.getCondVisibility('VideoPlayer.Content(movies)'):
filename = ''
Expand Down
16 changes: 8 additions & 8 deletions lib/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def movies(self, request, data):
WINDOW.setProperty("%s.%d.OriginalTitle" % (request, count), item['originaltitle'])
WINDOW.setProperty("%s.%d.Year" % (request, count), str(item['year']))
WINDOW.setProperty("%s.%d.Genre" % (request, count), " / ".join(item['genre']))
WINDOW.setProperty("%s.%d.Studio" % (request, count), item['studio'][0])
WINDOW.setProperty("%s.%d.Country" % (request, count), item['country'][0])
WINDOW.setProperty("%s.%d.Studio" % (request, count), " / ".join(item['studio']))
WINDOW.setProperty("%s.%d.Country" % (request, count), " / ".join(item['country']))
WINDOW.setProperty("%s.%d.Plot" % (request, count), plot)
WINDOW.setProperty("%s.%d.PlotOutline" % (request, count), item['plotoutline'])
WINDOW.setProperty("%s.%d.Tagline" % (request, count), item['tagline'])
Expand All @@ -86,7 +86,7 @@ def movies(self, request, data):
WINDOW.setProperty("%s.%d.Art(clearart)" % (request, count), art.get('clearart',''))
WINDOW.setProperty("%s.%d.Art(landscape)" % (request, count), art.get('landscape',''))
WINDOW.setProperty("%s.%d.Art(banner)" % (request, count), art.get('banner',''))
WINDOW.setProperty("%s.%d.Art(discart)" % (request, count), art.get('discart',''))
WINDOW.setProperty("%s.%d.Art(discart)" % (request, count), art.get('discart',''))
WINDOW.setProperty("%s.%d.Resume" % (request, count), resume)
WINDOW.setProperty("%s.%d.PercentPlayed" % (request, count), played)
WINDOW.setProperty("%s.%d.Watched" % (request, count), watched)
Expand Down Expand Up @@ -249,7 +249,7 @@ def episodes(self, request, data):

def musicvideos(self, request, data):
if data:
clear_properties(request)
clear_properties(request)
count = 0
for item in data['result']['musicvideos']:
count += 1
Expand Down Expand Up @@ -319,7 +319,7 @@ def albums(self, request, data):
WINDOW.setProperty("%s.%d.Art(fanart)" % (request, count), item['fanart'])
WINDOW.setProperty("%s.%d.Play" % (request, count), play)
del data

def artists(self, request, data):
if data:
clear_properties(request)
Expand All @@ -343,7 +343,7 @@ def artists(self, request, data):
WINDOW.setProperty("%s.%d.Mood" % (request, count), " / ".join(item['mood']))
WINDOW.setProperty("%s.%d.Instrument" % (request, count), " / ".join(item['instrument']))
WINDOW.setProperty("%s.%d.LibraryPath" % (request, count), path)

def songs(self, request, data):
if data:
clear_properties(request)
Expand All @@ -364,7 +364,7 @@ def songs(self, request, data):
WINDOW.setProperty("%s.%d.File" % (request, count), item['file'])
WINDOW.setProperty("%s.%d.Path" % (request, count), path)
WINDOW.setProperty("%s.%d.Play" % (request, count), play)
del data
del data

def addons(self, request, data):
if data:
Expand Down Expand Up @@ -399,4 +399,4 @@ def clear_properties(request):
count = 0
for count in range(int(LIMIT)):
count += 1
WINDOW.clearProperty("%s.%d.Title" % (request, count))
WINDOW.clearProperty("%s.%d.Title" % (request, count))
15 changes: 14 additions & 1 deletion lib/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
LIMIT = 20
RANDOMITEMS_UNPLAYED = __addon__.getSetting("randomitems_unplayed") == 'true'
RECENTITEMS_UNPLAYED = __addon__.getSetting("recentitems_unplayed") == 'true'
RECENTAIREDITEMS_UNPLAYED = __addon__.getSetting("recentaireditems_unplayed") == 'true'

class req:
def movies(self, request):
Expand All @@ -39,6 +40,10 @@ def 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 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 RANDOMITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
else:
Expand All @@ -56,6 +61,10 @@ def episodes(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 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 RANDOMITEMS_UNPLAYED:
json_query = xbmc.executeJSONRPC('%s "sort": {"method": "random" }, "filter": {"field": "playcount", "operator": "lessthan", "value": "1"}}}' %json_string)
else:
Expand Down Expand Up @@ -95,6 +104,8 @@ def musicvideos(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 All @@ -110,6 +121,8 @@ def 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 @@ -149,4 +162,4 @@ def addons(self, request):
if json_query.has_key('result') and json_query['result'].has_key('addons'):
return json_query
else:
return False
return False
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>