mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
fixed playback
This commit is contained in:
parent
d489375ab2
commit
88b31ae5c4
6 changed files with 32 additions and 58 deletions
|
@ -27,8 +27,10 @@ except:
|
||||||
id=None
|
id=None
|
||||||
|
|
||||||
if mode != None and mode == "play":
|
if mode != None and mode == "play":
|
||||||
|
pass
|
||||||
#PlaybackUtils().PLAY(id)
|
#PlaybackUtils().PLAY(id)
|
||||||
WINDOW.setProperty('GUIPLAY', str(id)) # set window prop
|
#WINDOW.setProperty('GUIPLAY', str(id)) # set window prop
|
||||||
|
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, None)
|
||||||
elif sys.argv[1] == "reset":
|
elif sys.argv[1] == "reset":
|
||||||
utils.reset()
|
utils.reset()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -13,6 +13,7 @@ from WriteKodiDB import WriteKodiDB
|
||||||
from ReadKodiDB import ReadKodiDB
|
from ReadKodiDB import ReadKodiDB
|
||||||
from PlayUtils import PlayUtils
|
from PlayUtils import PlayUtils
|
||||||
from DownloadUtils import DownloadUtils
|
from DownloadUtils import DownloadUtils
|
||||||
|
from PlaybackUtils import PlaybackUtils
|
||||||
|
|
||||||
class Kodi_Monitor(xbmc.Monitor):
|
class Kodi_Monitor(xbmc.Monitor):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -28,7 +29,7 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
print "onNotification:" + method + ":" + sender + ":" + str(data)
|
print "onNotification:" + method + ":" + sender + ":" + str(data)
|
||||||
#player started playing an item -
|
#player started playing an item -
|
||||||
if method == "Player.OnPlay":
|
if method == "Playlist.OnAdd":
|
||||||
print "playlist onadd is called"
|
print "playlist onadd is called"
|
||||||
jsondata = json.loads(data)
|
jsondata = json.loads(data)
|
||||||
if jsondata != None:
|
if jsondata != None:
|
||||||
|
@ -37,7 +38,10 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
id = jsondata.get("item").get("id")
|
id = jsondata.get("item").get("id")
|
||||||
type = jsondata.get("item").get("type")
|
type = jsondata.get("item").get("type")
|
||||||
embyid = ReadKodiDB().getEmbyIdByKodiId(id,type)
|
embyid = ReadKodiDB().getEmbyIdByKodiId(id,type)
|
||||||
|
|
||||||
|
print "id --> " + str(id)
|
||||||
|
print "type --> " + type
|
||||||
|
print "emby_id --> " + embyid
|
||||||
if embyid != None:
|
if embyid != None:
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window( 10000 )
|
WINDOW = xbmcgui.Window( 10000 )
|
||||||
|
@ -49,41 +53,8 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % embyid
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % embyid
|
||||||
result = downloadUtils.downloadUrl(url)
|
result = downloadUtils.downloadUrl(url)
|
||||||
|
|
||||||
userData = result[u'UserData']
|
#launch playbackutils
|
||||||
|
PlaybackUtils().PLAY(result)
|
||||||
playurl = PlayUtils().getPlayUrl(server, embyid, result)
|
|
||||||
|
|
||||||
watchedurl = "%s/mediabrowser/Users/%s/PlayedItems/%s" % (server, userid, embyid)
|
|
||||||
positionurl = "%s/mediabrowser/Users/%s/PlayingItems/%s" % (server, userid, embyid)
|
|
||||||
deleteurl = "%s/mediabrowser/Items/%s" % (server, embyid)
|
|
||||||
|
|
||||||
# set the current playing info
|
|
||||||
WINDOW.setProperty(playurl+"watchedurl", watchedurl)
|
|
||||||
WINDOW.setProperty(playurl+"positionurl", positionurl)
|
|
||||||
WINDOW.setProperty(playurl+"deleteurl", "")
|
|
||||||
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
|
||||||
if result[u'Type']=="Episode":
|
|
||||||
WINDOW.setProperty(playurl+"refresh_id", result[u'SeriesId'])
|
|
||||||
else:
|
|
||||||
WINDOW.setProperty(playurl+"refresh_id", embyid)
|
|
||||||
|
|
||||||
WINDOW.setProperty(playurl+"runtimeticks", str(result[u'RunTimeTicks']))
|
|
||||||
WINDOW.setProperty(playurl+"type", result[u'Type'])
|
|
||||||
WINDOW.setProperty(playurl+"item_id", embyid)
|
|
||||||
|
|
||||||
if PlayUtils().isDirectPlay(result) == True:
|
|
||||||
playMethod = "DirectPlay"
|
|
||||||
else:
|
|
||||||
playMethod = "Transcode"
|
|
||||||
|
|
||||||
WINDOW.setProperty(playurl+"playmethod", playMethod)
|
|
||||||
|
|
||||||
mediaSources = result[u'MediaSources']
|
|
||||||
if(mediaSources != None):
|
|
||||||
if mediaSources[0].get('DefaultAudioStreamIndex') != None:
|
|
||||||
WINDOW.setProperty(playurl+"AudioStreamIndex", str(mediaSources[0][u'DefaultAudioStreamIndex']))
|
|
||||||
if mediaSources[0].get('DefaultSubtitleStreamIndex') != None:
|
|
||||||
WINDOW.setProperty(playurl+"SubtitleStreamIndex", str(mediaSources[0][u'DefaultSubtitleStreamIndex']))
|
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
jsondata = json.loads(data)
|
jsondata = json.loads(data)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class PlaybackUtils():
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def PLAY(self, id):
|
def PLAY(self, result):
|
||||||
xbmc.log("PLAY Called")
|
xbmc.log("PLAY Called")
|
||||||
WINDOW = xbmcgui.Window(10000)
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
|
@ -43,11 +43,9 @@ class PlaybackUtils():
|
||||||
userid = WINDOW.getProperty('userId%s' % username)
|
userid = WINDOW.getProperty('userId%s' % username)
|
||||||
server = WINDOW.getProperty('server%s' % username)
|
server = WINDOW.getProperty('server%s' % username)
|
||||||
|
|
||||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
id = result["Id"]
|
||||||
result = self.downloadUtils.downloadUrl(url)
|
|
||||||
|
|
||||||
|
|
||||||
userData = result[u'UserData']
|
userData = result['UserData']
|
||||||
resume_result = 0
|
resume_result = 0
|
||||||
seekTime = 0
|
seekTime = 0
|
||||||
|
|
||||||
|
@ -134,13 +132,8 @@ class PlaybackUtils():
|
||||||
|
|
||||||
#this launches the playback
|
#this launches the playback
|
||||||
#artwork only works with both resolvedurl and player command
|
#artwork only works with both resolvedurl and player command
|
||||||
if isStrmFile:
|
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
xbmc.Player().play(playurl,listItem)
|
||||||
else:
|
|
||||||
#xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
|
||||||
if(addon.getSetting("addExtraPlaybackArt") == "true"):
|
|
||||||
utils.logMsg("PLAY", "Doing second xbmc.Player().play to add extra art")
|
|
||||||
xbmc.Player().play(playurl,listItem)
|
|
||||||
|
|
||||||
def setArt(self, list,name,path):
|
def setArt(self, list,name,path):
|
||||||
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
||||||
|
|
|
@ -90,9 +90,9 @@ class Player( xbmc.Player ):
|
||||||
self.logMsg("emby Service -> Percent Complete:" + str(percentComplete) + " Mark Played At:" + str(markPlayedAt))
|
self.logMsg("emby Service -> Percent Complete:" + str(percentComplete) + " Mark Played At:" + str(markPlayedAt))
|
||||||
self.stopPlayback(data)
|
self.stopPlayback(data)
|
||||||
|
|
||||||
if(refresh_id != None):
|
#if(refresh_id != None):
|
||||||
#report updates playcount and resume status to Kodi and MB3
|
#report updates playcount and resume status to Kodi and MB3
|
||||||
librarySync.updatePlayCount(item_id)
|
#librarySync.updatePlayCount(item_id)
|
||||||
|
|
||||||
|
|
||||||
self.played_information.clear()
|
self.played_information.clear()
|
||||||
|
|
|
@ -42,3 +42,15 @@ class ReadKodiDB():
|
||||||
#this will return a list with tuples of all items returned from the database
|
#this will return a list with tuples of all items returned from the database
|
||||||
return allepisodes
|
return allepisodes
|
||||||
|
|
||||||
|
def getEmbyIdByKodiId(self, id, type, connection=None, cursor=None):
|
||||||
|
if not connection:
|
||||||
|
connection = utils.KodiSQL()
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute("SELECT emby_id FROM emby WHERE media_type=? AND kodi_id=?",(type,id))
|
||||||
|
result = cursor.fetchone()
|
||||||
|
if result:
|
||||||
|
return result[0]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ sleepVal = 20
|
||||||
class WriteKodiDB():
|
class WriteKodiDB():
|
||||||
|
|
||||||
def updatePlayCountFromKodi(self, id, type, playcount=0):
|
def updatePlayCountFromKodi(self, id, type, playcount=0):
|
||||||
#when user marks item watched from kodi interface update this in MB3
|
#when user marks item watched from kodi interface update this in Emby
|
||||||
|
|
||||||
utils.logMsg("Emby", "updatePlayCountFromKodi Called")
|
utils.logMsg("Emby", "updatePlayCountFromKodi Called")
|
||||||
connection = utils.KodiSQL()
|
connection = utils.KodiSQL()
|
||||||
|
@ -37,11 +37,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
if(emby_id != None):
|
if(emby_id != None):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||||
|
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
|
|
||||||
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % emby_id
|
watchedurl = "{server}/mediabrowser/Users/{UserId}/PlayedItems/%s" % emby_id
|
||||||
utils.logMsg("Emby","watchedurl -->" + watchedurl)
|
|
||||||
if playcount != 0:
|
if playcount != 0:
|
||||||
downloadUtils.downloadUrl(watchedurl, type="POST")
|
downloadUtils.downloadUrl(watchedurl, type="POST")
|
||||||
else:
|
else:
|
||||||
|
@ -882,8 +879,7 @@ class WriteKodiDB():
|
||||||
#audio details
|
#audio details
|
||||||
sql="insert into streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels) values(?, ?, ?, ?)"
|
sql="insert into streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels) values(?, ?, ?, ?)"
|
||||||
cursor.execute(sql, (fileid,1,streamdetails.get("audiocodec"),streamdetails.get("channels")))
|
cursor.execute(sql, (fileid,1,streamdetails.get("audiocodec"),streamdetails.get("channels")))
|
||||||
|
|
||||||
|
|
||||||
def addBoxsetToKodiLibrary(self, boxset, connection, cursor):
|
def addBoxsetToKodiLibrary(self, boxset, connection, cursor):
|
||||||
|
|
||||||
strSet = boxset["Name"]
|
strSet = boxset["Name"]
|
||||||
|
|
Loading…
Reference in a new issue