diff --git a/addon.xml b/addon.xml index 0c6e6213..9cb3c0ea 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/PlaybackUtils.py b/resources/lib/PlaybackUtils.py index a96b3959..3695458e 100644 --- a/resources/lib/PlaybackUtils.py +++ b/resources/lib/PlaybackUtils.py @@ -36,7 +36,7 @@ class PlaybackUtils(): pass def PLAY(self, id): - + xbmc.log("PLAY Called") port = addon.getSetting('port') host = addon.getSetting('ipaddress') server = host + ":" + port @@ -59,7 +59,7 @@ class PlaybackUtils(): if episodeItem != None and str(episodeItem["Type"]) == "Episode": kodiItem = ReadKodiDB().getKodiEpisodeByMbItem(id,episodeItem["SeriesId"]) if kodiItem != None: - seekTime = int(round(kodiItem['resume'].get("position"))) + seekTime = int(round(kodiItem['resume'].get("position"))) playurl = PlayUtils().getPlayUrl(server, id, result) @@ -272,6 +272,23 @@ class PlaybackUtils(): if seekTime > 0: self.seekToPosition(seekTime) + + def PLAYAllEpisodes(self, items): + userid = self.downloadUtils.getUserId() + server = self.downloadUtils.getServer() + + playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) + playlist.clear() + + for item in items: + + item_url = server + "/mediabrowser/Users/" + userid + "/Items/" + item["Id"] + "?format=json&ImageTypeLimit=1" + jsonData = self.downloadUtils.downloadUrl(item_url, suppress=False, popup=1 ) + + item_data = json.loads(jsonData) + self.addPlaylistItem(playlist, item_data, server, userid) + + xbmc.Player().play(playlist) def AddToPlaylist(self, itemIds): utils.logMsg("PlayBackUtils", "== ENTER: PLAYAllItems ==") diff --git a/resources/lib/Player.py b/resources/lib/Player.py index 5945345a..8f5a9bea 100644 --- a/resources/lib/Player.py +++ b/resources/lib/Player.py @@ -13,6 +13,8 @@ from PlayUtils import PlayUtils from ClientInformation import ClientInformation from LibrarySync import LibrarySync from PlaybackUtils import PlaybackUtils +from ReadEmbyDB import ReadEmbyDB +from API import API librarySync = LibrarySync() # service class for playback monitoring @@ -89,7 +91,36 @@ class Player( xbmc.Player ): if(refresh_id != None): #report updates playcount and resume status to Kodi and MB3 librarySync.updatePlayCount(item_id,type) - + + # if its an episode see if autoplay is enabled + if addonSettings.getSetting("autoPlaySeason")=="true" and type=="Episode": + port = addonSettings.getSetting('port') + host = addonSettings.getSetting('ipaddress') + server = host + ":" + port + userid = self.downloadUtils.getUserId() + # add remaining unplayed episodes if applicable + MB3Episode = ReadEmbyDB().getItem(item_id) + userData = MB3Episode["UserData"] + if userData!=None and userData["Played"]==True: + + pDialog = xbmcgui.DialogProgress() + pDialog.create("Auto Play","Further Episode(s) in "+MB3Episode["SeasonName"]+" for "+MB3Episode["SeriesName"]+ " found","Cancel to stop automatic play of remaining episodes") + count = 0 + while(pDialog.iscanceled==False or count < 10): + xbmc.sleep(1000) + count += 1 + progress = count * 10 + remainingsecs = 10 - count + pDialog.update(progress,"Further Episode(s) in "+MB3Episode["SeasonName"]+" for "+MB3Episode["SeriesName"]+ " found","Cancel to stop automatic play of remaining episodes", str(remainingsecs) + " seconds(s) until auto dismiss") + + if pDialog.iscanceled()==False: + seasonId = MB3Episode["SeasonId"] + jsonData = self.downloadUtils.downloadUrl("http://" + server + "/mediabrowser/Users/" + userid + "/Items?ParentId=" + seasonId + "&ImageTypeLimit=1&SortBy=SortName&SortOrder=Ascending&Filters=IsUnPlayed&IncludeItemTypes=Episode&IsVirtualUnaired=false&Recursive=true&IsMissing=False&format=json", suppress=False, popup=1 ) + if(jsonData != ""): + seasonData = json.loads(jsonData) + if seasonData.get("Items") != None: + PlaybackUtils().PLAYAllEpisodes(seasonData.get("Items")) + self.played_information.clear() # stop transcoding - todo check we are actually transcoding? diff --git a/resources/settings.xml b/resources/settings.xml index 10a47f6f..1e9deee2 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -19,6 +19,7 @@ +