mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
added nextup videonode to tvshow collections
This commit is contained in:
commit
93f2d4cd91
7 changed files with 68 additions and 49 deletions
50
default.py
50
default.py
|
@ -25,43 +25,32 @@ from API import API
|
||||||
from PluginFunctions import PluginFunctions
|
from PluginFunctions import PluginFunctions
|
||||||
|
|
||||||
|
|
||||||
def json_query( method, unplayed=False, properties=None, sort=False, query_filter=False, limit=False, params=False):
|
|
||||||
json_query = { "jsonrpc": "2.0", "id": 1, "method": method, "params": {} }
|
|
||||||
if properties is not None:
|
|
||||||
json_query["params"]["properties"] = properties
|
|
||||||
if limit is not None:
|
|
||||||
json_query["params"]["limits"] = {"end":limit if limit else 25}
|
|
||||||
if sort is not None:
|
|
||||||
json_query["params"]["sort"] = sort
|
|
||||||
if query_filter:
|
|
||||||
json_query["params"]["filter"] = query_filter
|
|
||||||
if params:
|
|
||||||
json_query["params"].update(params)
|
|
||||||
|
|
||||||
json_string = json.dumps(json_query)
|
|
||||||
rv = xbmc.executeJSONRPC(json_string)
|
|
||||||
|
|
||||||
return unicode(rv, 'utf-8', errors='ignore')
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params = utils.get_params(sys.argv[2])
|
params = utils.get_params(sys.argv[2])
|
||||||
mode = params['mode']
|
mode = params['mode']
|
||||||
id = params['id']
|
id = params.get('id', None)
|
||||||
except:
|
except:
|
||||||
params = {}
|
params = {}
|
||||||
mode = None
|
mode = None
|
||||||
|
|
||||||
if mode == "play":
|
if mode == "play" or mode == "playfromaddon":
|
||||||
# Play items via plugin://plugin.video.emby/
|
# Play items via plugin://plugin.video.emby/
|
||||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||||
result = DownloadUtils().downloadUrl(url)
|
result = DownloadUtils().downloadUrl(url)
|
||||||
|
#from from addon needed if the palyback is launched from the addon itself
|
||||||
|
if mode == "playfromaddon":
|
||||||
|
item = PlaybackUtils().PLAY(result, setup="service")
|
||||||
|
else:
|
||||||
item = PlaybackUtils().PLAY(result, setup="default")
|
item = PlaybackUtils().PLAY(result, setup="default")
|
||||||
|
|
||||||
|
elif mode == "reset":
|
||||||
|
utils.reset()
|
||||||
|
|
||||||
elif "getnextup" in sys.argv[0]:
|
|
||||||
params = utils.get_params(sys.argv[2])
|
elif mode == "nextup":
|
||||||
tagname = params['tagname']
|
#if the addon is called with nextup parameter, we return the nextepisodes list of the given tagname
|
||||||
|
tagname = params['id']
|
||||||
|
limit = int(params['limit'])
|
||||||
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
|
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
|
||||||
# First we get a list of all the in-progress TV shows - filtered by tag
|
# First we get a list of all the in-progress TV shows - filtered by tag
|
||||||
json_query_string = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "sort": { "order": "descending", "method": "lastplayed" }, "filter": {"and": [{"operator":"true", "field":"inprogress", "value":""}, {"operator": "contains", "field": "tag", "value": "%s"}]}, "properties": [ "title", "studio", "mpaa", "file", "art" ] }, "id": "libTvShows"}' %tagname)
|
json_query_string = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": { "sort": { "order": "descending", "method": "lastplayed" }, "filter": {"and": [{"operator":"true", "field":"inprogress", "value":""}, {"operator": "contains", "field": "tag", "value": "%s"}]}, "properties": [ "title", "studio", "mpaa", "file", "art" ] }, "id": "libTvShows"}' %tagname)
|
||||||
|
@ -87,6 +76,7 @@ elif "getnextup" in sys.argv[0]:
|
||||||
plot = item['plot']
|
plot = item['plot']
|
||||||
liz = xbmcgui.ListItem(item['title'])
|
liz = xbmcgui.ListItem(item['title'])
|
||||||
liz.setInfo( type="Video", infoLabels={ "Title": item['title'] })
|
liz.setInfo( type="Video", infoLabels={ "Title": item['title'] })
|
||||||
|
liz.setInfo( type="Video", infoLabels={ "duration": str(item['runtime']/60) })
|
||||||
liz.setInfo( type="Video", infoLabels={ "Episode": item['episode'] })
|
liz.setInfo( type="Video", infoLabels={ "Episode": item['episode'] })
|
||||||
liz.setInfo( type="Video", infoLabels={ "Season": item['season'] })
|
liz.setInfo( type="Video", infoLabels={ "Season": item['season'] })
|
||||||
liz.setInfo( type="Video", infoLabels={ "Premiered": item['firstaired'] })
|
liz.setInfo( type="Video", infoLabels={ "Premiered": item['firstaired'] })
|
||||||
|
@ -112,9 +102,12 @@ elif "getnextup" in sys.argv[0]:
|
||||||
for key, value in item['streamdetails'].iteritems():
|
for key, value in item['streamdetails'].iteritems():
|
||||||
for stream in value:
|
for stream in value:
|
||||||
liz.addStreamInfo( key, stream )
|
liz.addStreamInfo( key, stream )
|
||||||
|
file = item['file'].replace("mode=play","mode=playfromaddon")
|
||||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=file, listitem=liz)
|
||||||
xbmcplugin.endOfDirectory(handle= int(sys.argv[1]))
|
count +=1
|
||||||
|
if count == limit:
|
||||||
|
break
|
||||||
|
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
#get extrafanart for listitem - this will only be used for skins that actually call the listitem's path + fanart dir...
|
#get extrafanart for listitem - this will only be used for skins that actually call the listitem's path + fanart dir...
|
||||||
|
@ -164,9 +157,6 @@ elif "extrafanart" in sys.argv[0]:
|
||||||
#always do endofdirectory to prevent errors in the logs
|
#always do endofdirectory to prevent errors in the logs
|
||||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
elif sys.argv[1] == "reset":
|
|
||||||
utils.reset()
|
|
||||||
else:
|
else:
|
||||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,9 @@ class DownloadUtils():
|
||||||
self.logMsg("====== 200 Success ======", 2)
|
self.logMsg("====== 200 Success ======", 2)
|
||||||
return r
|
return r
|
||||||
except:
|
except:
|
||||||
|
if r.headers['content-type'] == "text/html":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
self.logMsg("Unable to convert the response for: %s" % url, 1)
|
self.logMsg("Unable to convert the response for: %s" % url, 1)
|
||||||
else:
|
else:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
|
|
|
@ -17,6 +17,9 @@ from DownloadUtils import DownloadUtils
|
||||||
from PlaybackUtils import PlaybackUtils
|
from PlaybackUtils import PlaybackUtils
|
||||||
|
|
||||||
class Kodi_Monitor(xbmc.Monitor):
|
class Kodi_Monitor(xbmc.Monitor):
|
||||||
|
|
||||||
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
xbmc.Monitor.__init__(self)
|
xbmc.Monitor.__init__(self)
|
||||||
|
|
||||||
|
@ -26,7 +29,8 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
#this library monitor is used to detect a watchedstate change by the user through the library
|
#this library monitor is used to detect a watchedstate change by the user through the library
|
||||||
#as well as detect when a library item has been deleted to pass the delete to the Emby server
|
#as well as detect when a library item has been deleted to pass the delete to the Emby server
|
||||||
def onNotification (self,sender,method,data):
|
def onNotification (self,sender,method,data):
|
||||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
||||||
|
WINDOW = self.WINDOW
|
||||||
downloadUtils = DownloadUtils()
|
downloadUtils = DownloadUtils()
|
||||||
|
|
||||||
if method == "VideoLibrary.OnUpdate":
|
if method == "VideoLibrary.OnUpdate":
|
||||||
|
@ -37,16 +41,27 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||||
playcount = jsondata.get("playcount")
|
playcount = jsondata.get("playcount")
|
||||||
item = jsondata.get("item").get("id")
|
item = jsondata.get("item").get("id")
|
||||||
type = jsondata.get("item").get("type")
|
type = jsondata.get("item").get("type")
|
||||||
if playcount != None:
|
prop = WINDOW.getProperty('Played%s%s' % (type,item))
|
||||||
|
|
||||||
|
if (playcount != None) and (prop != "true"):
|
||||||
|
WINDOW.setProperty("Played%s%s" % (type,item), "true")
|
||||||
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
|
utils.logMsg("MB# Sync","Kodi_Monitor--> VideoLibrary.OnUpdate : " + str(data),2)
|
||||||
WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
|
WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
|
||||||
|
|
||||||
|
self.clearProperty(type,item)
|
||||||
|
|
||||||
if method == "System.OnWake":
|
if method == "System.OnWake":
|
||||||
xbmc.sleep(10000) #Allow network to wake up
|
xbmc.sleep(10000) #Allow network to wake up
|
||||||
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Started)",1)
|
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Started)",1)
|
||||||
libSync = LibrarySync().FullLibrarySync()
|
libSync = LibrarySync().FullLibrarySync()
|
||||||
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync),1)
|
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Finished) " + str(libSync),1)
|
||||||
|
|
||||||
|
def clearProperty(self,type,id):
|
||||||
|
# The sleep is necessary since VideoLibrary.OnUpdate
|
||||||
|
# triggers 3 times in a row.
|
||||||
|
xbmc.sleep(100)
|
||||||
|
self.WINDOW.clearProperty("Played%s%s" % (type,id))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -144,16 +144,6 @@ def CleanName(filename):
|
||||||
return ''.join(c for c in cleanedFilename if c in validFilenameChars)
|
return ''.join(c for c in cleanedFilename if c in validFilenameChars)
|
||||||
|
|
||||||
|
|
||||||
def removeDirectory(path):
|
|
||||||
if xbmcvfs.exists(path):
|
|
||||||
allDirs, allFiles = xbmcvfs.listdir(path)
|
|
||||||
for dir in allDirs:
|
|
||||||
xbmcvfs.rmdir(os.path.join(path,dir))
|
|
||||||
for file in allFiles:
|
|
||||||
xbmcvfs.delete(os.path.join(path,file))
|
|
||||||
|
|
||||||
xbmcvfs.rmdir(path)
|
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
|
|
||||||
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local Kodi database?")
|
return_value = xbmcgui.Dialog().yesno("Warning", "Are you sure you want to reset your local Kodi database?")
|
||||||
|
@ -161,6 +151,16 @@ def reset():
|
||||||
if return_value == 0:
|
if return_value == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#cleanup video nodes
|
||||||
|
import shutil
|
||||||
|
path = "special://userdata/library/video/"
|
||||||
|
if xbmcvfs.exists(path):
|
||||||
|
allDirs, allFiles = xbmcvfs.listdir(path)
|
||||||
|
for dir in allDirs:
|
||||||
|
if dir.startswith("Emby "):
|
||||||
|
shutil.rmtree(xbmc.translatePath("special://userdata/library/video/" + dir))
|
||||||
|
|
||||||
|
|
||||||
# Ask if user information should be deleted too.
|
# Ask if user information should be deleted too.
|
||||||
return_user = xbmcgui.Dialog().yesno("Warning", "Reset all Emby Addon settings?")
|
return_user = xbmcgui.Dialog().yesno("Warning", "Reset all Emby Addon settings?")
|
||||||
|
|
||||||
|
|
|
@ -1160,6 +1160,17 @@ class WriteKodiDB():
|
||||||
except:
|
except:
|
||||||
ET.ElementTree(root).write(nodefile)
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
|
#create tag node - nextup items
|
||||||
|
nodefile = os.path.join(libraryPath, tagname + "_nextup_episodes.xml")
|
||||||
|
root = Element("node", {"order":"4", "type":"folder"})
|
||||||
|
SubElement(root, "label").text = tagname + " - Nextup episodes"
|
||||||
|
SubElement(root, "path").text = "plugin://plugin.video.emby/?id=%s&mode=nextup&limit=25" %tagname
|
||||||
|
SubElement(root, "icon").text = "DefaultMovies.png"
|
||||||
|
try:
|
||||||
|
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||||
|
except:
|
||||||
|
ET.ElementTree(root).write(nodefile)
|
||||||
|
|
||||||
def updateBoxsetToKodiLibrary(self, boxsetmovie, boxset, connection, cursor):
|
def updateBoxsetToKodiLibrary(self, boxsetmovie, boxset, connection, cursor):
|
||||||
strSet = boxset["Name"]
|
strSet = boxset["Name"]
|
||||||
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(boxsetmovie["Id"],))
|
cursor.execute("SELECT kodi_id FROM emby WHERE emby_id = ?",(boxsetmovie["Id"],))
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<setting id="sslcert" type="file" label="Client SSL certificate" visible="eq(-2,true)" enable="true" default="None" />
|
<setting id="sslcert" type="file" label="Client SSL certificate" visible="eq(-2,true)" enable="true" default="None" />
|
||||||
<setting type="sep" />
|
<setting type="sep" />
|
||||||
<setting id="deviceName" type="text" label="30016" default="Kodi" />
|
<setting id="deviceName" type="text" label="30016" default="Kodi" />
|
||||||
<setting id="playFromStream" type="bool" label="30002" visible="true" enable="true" default="false" />
|
|
||||||
</category>
|
</category>
|
||||||
<category label="Sync Options">
|
<category label="Sync Options">
|
||||||
<!-- <setting id="syncMovieBoxSets" type="bool" label="30238" default="true" visible="true" enable="true" /> -->
|
<!-- <setting id="syncMovieBoxSets" type="bool" label="30238" default="true" visible="true" enable="true" /> -->
|
||||||
|
@ -21,6 +20,7 @@
|
||||||
<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" />
|
<setting id="autoPlaySeason" type="bool" label="30216" default="false" visible="true" enable="true" />
|
||||||
<setting type="sep" />
|
<setting type="sep" />
|
||||||
|
<setting id="playFromStream" type="bool" label="30002" visible="true" enable="true" default="false" />
|
||||||
<setting id="videoBitRate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" default="17" />
|
<setting id="videoBitRate" type="enum" label="30160" values="664 Kbps SD|996 Kbps HD|1.3 Mbps HD|2.0 Mbps HD|3.2 Mbps HD|4.7 Mbps HD|6.2 Mbps HD|7.7 Mbps HD|9.2 Mbps HD|10.7 Mbps HD|12.2 Mbps HD|13.7 Mbps HD|15.2 Mbps HD|16.7 Mbps HD|18.2 Mbps HD|20.0 Mbps HD|40.0 Mbps HD|100.0 Mbps HD [default]|1000.0 Mbps HD" default="17" />
|
||||||
<setting id="forceTranscodingCodecs" type="text" label="30245" />
|
<setting id="forceTranscodingCodecs" type="text" label="30245" />
|
||||||
</category>
|
</category>
|
||||||
|
@ -29,6 +29,6 @@
|
||||||
</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" />
|
||||||
<setting label="30239" type="action" action="RunScript(plugin.video.emby, reset)" />
|
<setting label="30239" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=reset)" />
|
||||||
</category>
|
</category>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
Loading…
Reference in a new issue