added autoplay remaining episodes option

This commit is contained in:
im85288 2015-04-07 15:21:54 +01:00
parent 78883f2216
commit b88f467357
4 changed files with 53 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby" <addon id="plugin.video.emby"
name="Emby" name="Emby"
version="0.0.20" version="0.0.21"
provider-name="Emby.media"> provider-name="Emby.media">
<requires> <requires>
<import addon="xbmc.python" version="2.1.0"/> <import addon="xbmc.python" version="2.1.0"/>

View file

@ -36,7 +36,7 @@ class PlaybackUtils():
pass pass
def PLAY(self, id): def PLAY(self, id):
xbmc.log("PLAY Called")
port = addon.getSetting('port') port = addon.getSetting('port')
host = addon.getSetting('ipaddress') host = addon.getSetting('ipaddress')
server = host + ":" + port server = host + ":" + port
@ -273,6 +273,23 @@ class PlaybackUtils():
if seekTime > 0: if seekTime > 0:
self.seekToPosition(seekTime) 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): def AddToPlaylist(self, itemIds):
utils.logMsg("PlayBackUtils", "== ENTER: PLAYAllItems ==") utils.logMsg("PlayBackUtils", "== ENTER: PLAYAllItems ==")
userid = self.downloadUtils.getUserId() userid = self.downloadUtils.getUserId()

View file

@ -13,6 +13,8 @@ from PlayUtils import PlayUtils
from ClientInformation import ClientInformation from ClientInformation import ClientInformation
from LibrarySync import LibrarySync from LibrarySync import LibrarySync
from PlaybackUtils import PlaybackUtils from PlaybackUtils import PlaybackUtils
from ReadEmbyDB import ReadEmbyDB
from API import API
librarySync = LibrarySync() librarySync = LibrarySync()
# service class for playback monitoring # service class for playback monitoring
@ -90,6 +92,35 @@ class Player( xbmc.Player ):
#report updates playcount and resume status to Kodi and MB3 #report updates playcount and resume status to Kodi and MB3
librarySync.updatePlayCount(item_id,type) 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() self.played_information.clear()
# stop transcoding - todo check we are actually transcoding? # stop transcoding - todo check we are actually transcoding?

View file

@ -19,6 +19,7 @@
<category label="Playback"> <!-- Extra Sync options --> <category label="Playback"> <!-- Extra Sync options -->
<setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" /> <setting id="smbusername" type="text" label="30007" default="" visible="true" enable="true" />
<setting id="smbpassword" type="text" label="30008" default="" option="hidden" visible="true" enable="true" /> <setting id="smbpassword" type="text" label="30008" default="" option="hidden" visible="true" enable="true" />
<setting id="autoPlaySeason" type="bool" label="30216" default="false" visible="true" enable="true" />
</category> </category>
<category label="30022"> <category label="30022">
<setting id="logLevel" type="enum" label="30004" values="None|Info|Debug" default="1" /> <setting id="logLevel" type="enum" label="30004" values="None|Info|Debug" default="1" />