mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
changed autoplay to popup in last 20 seconds rather than at play stopped
This commit is contained in:
parent
f084608e84
commit
31656e4684
3 changed files with 59 additions and 29 deletions
|
@ -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.22"
|
version="0.0.23"
|
||||||
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"/>
|
||||||
|
|
|
@ -92,34 +92,6 @@ 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) + " second(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()
|
||||||
|
|
||||||
|
@ -341,3 +313,54 @@ class Player( xbmc.Player ):
|
||||||
self.printDebug("emby Service -> onPlayBackStopped")
|
self.printDebug("emby Service -> onPlayBackStopped")
|
||||||
self.stopAll()
|
self.stopAll()
|
||||||
|
|
||||||
|
|
||||||
|
def autoPlayPlayback(self):
|
||||||
|
currentFile = xbmc.Player().getPlayingFile()
|
||||||
|
data = self.played_information.get(currentFile)
|
||||||
|
|
||||||
|
# only report playback if emby has initiated the playback (item_id has value)
|
||||||
|
if(data != None and data.get("item_id") != None):
|
||||||
|
addonSettings = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
|
||||||
|
item_id = data.get("item_id")
|
||||||
|
type = data.get("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()
|
||||||
|
seasonId = MB3Episode["SeasonId"]
|
||||||
|
jsonData = self.downloadUtils.downloadUrl("http://" + server + "/mediabrowser/Users/" + userid + "/Items?ParentId=" + seasonId + "&ImageTypeLimit=1&Limit=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:
|
||||||
|
item = seasonData.get("Items")[0]
|
||||||
|
pDialog.create("Auto Play next episode", str(item.get("ParentIndexNumber")) + "x" + str(item.get("IndexNumber")) + ". " + item["Name"] + " found","Cancel to stop automatic play")
|
||||||
|
count = 0
|
||||||
|
while(pDialog.iscanceled()==False and count < 10):
|
||||||
|
xbmc.sleep(1000)
|
||||||
|
count += 1
|
||||||
|
progress = count * 10
|
||||||
|
remainingsecs = 10 - count
|
||||||
|
pDialog.update(progress, str(item.get("ParentIndexNumber")) + "x" + str(item.get("IndexNumber")) + ". " + item["Name"] + " found","Cancel to stop automatic play", str(remainingsecs) + " second(s) until auto dismiss")
|
||||||
|
|
||||||
|
pDialog.close()
|
||||||
|
|
||||||
|
if pDialog.iscanceled()==False:
|
||||||
|
playTime = xbmc.Player().getTime()
|
||||||
|
totalTime = xbmc.Player().getTotalTime()
|
||||||
|
while xbmc.Player().isPlaying() and (totalTime-playTime > 2):
|
||||||
|
xbmc.sleep(500)
|
||||||
|
playTime = xbmc.Player().getTime()
|
||||||
|
totalTime = xbmc.Player().getTotalTime()
|
||||||
|
|
||||||
|
PlaybackUtils().PLAYAllEpisodes(seasonData.get("Items"))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ class Service():
|
||||||
player = Player()
|
player = Player()
|
||||||
ws = WebSocketThread()
|
ws = WebSocketThread()
|
||||||
|
|
||||||
|
lastFile = None
|
||||||
|
|
||||||
while not self.KodiMonitor.abortRequested():
|
while not self.KodiMonitor.abortRequested():
|
||||||
|
|
||||||
xbmc.sleep(1000)
|
xbmc.sleep(1000)
|
||||||
|
@ -70,6 +72,7 @@ class Service():
|
||||||
if xbmc.Player().isPlaying():
|
if xbmc.Player().isPlaying():
|
||||||
try:
|
try:
|
||||||
playTime = xbmc.Player().getTime()
|
playTime = xbmc.Player().getTime()
|
||||||
|
totalTime = xbmc.Player().getTotalTime()
|
||||||
currentFile = xbmc.Player().getPlayingFile()
|
currentFile = xbmc.Player().getPlayingFile()
|
||||||
|
|
||||||
if(player.played_information.get(currentFile) != None):
|
if(player.played_information.get(currentFile) != None):
|
||||||
|
@ -85,6 +88,10 @@ class Service():
|
||||||
xbmc.log("MB3 Sync Service -> Exception reporting progress : " + msg)
|
xbmc.log("MB3 Sync Service -> Exception reporting progress : " + msg)
|
||||||
pass
|
pass
|
||||||
lastProgressUpdate = datetime.today()
|
lastProgressUpdate = datetime.today()
|
||||||
|
# only try autoplay when there's 20 seconds or less remaining and only once!
|
||||||
|
if (totalTime - playTime <= 20 and (lastFile==None or lastFile!=currentFile)):
|
||||||
|
lastFile = currentFile
|
||||||
|
player.autoPlayPlayback()
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
xbmc.log("MB3 Sync Service -> Exception in Playback Monitor Service : " + str(e))
|
xbmc.log("MB3 Sync Service -> Exception in Playback Monitor Service : " + str(e))
|
||||||
|
|
Loading…
Reference in a new issue