mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-27 07:10:43 +00:00
added nextup videonode to tvshow collections
This commit is contained in:
commit
93f2d4cd91
56
default.py
56
default.py
@ -25,43 +25,32 @@ from API import API
|
||||
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:
|
||||
params = utils.get_params(sys.argv[2])
|
||||
mode = params['mode']
|
||||
id = params['id']
|
||||
id = params.get('id', None)
|
||||
except:
|
||||
params = {}
|
||||
mode = None
|
||||
|
||||
if mode == "play":
|
||||
if mode == "play" or mode == "playfromaddon":
|
||||
# Play items via plugin://plugin.video.emby/
|
||||
url = "{server}/mediabrowser/Users/{UserId}/Items/%s?format=json&ImageTypeLimit=1" % id
|
||||
result = DownloadUtils().downloadUrl(url)
|
||||
item = PlaybackUtils().PLAY(result, setup="default")
|
||||
#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")
|
||||
|
||||
|
||||
elif "getnextup" in sys.argv[0]:
|
||||
params = utils.get_params(sys.argv[2])
|
||||
tagname = params['tagname']
|
||||
elif mode == "reset":
|
||||
utils.reset()
|
||||
|
||||
|
||||
elif mode == "nextup":
|
||||
#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')
|
||||
# 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)
|
||||
@ -87,6 +76,7 @@ elif "getnextup" in sys.argv[0]:
|
||||
plot = item['plot']
|
||||
liz = xbmcgui.ListItem(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={ "Season": item['season'] })
|
||||
liz.setInfo( type="Video", infoLabels={ "Premiered": item['firstaired'] })
|
||||
@ -111,10 +101,13 @@ elif "getnextup" in sys.argv[0]:
|
||||
liz.setProperty("fanart_image", item['art'].get('tvshow.fanart',''))
|
||||
for key, value in item['streamdetails'].iteritems():
|
||||
for stream in value:
|
||||
liz.addStreamInfo( key, stream )
|
||||
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=item['file'], listitem=liz)
|
||||
xbmcplugin.endOfDirectory(handle= int(sys.argv[1]))
|
||||
liz.addStreamInfo( key, stream )
|
||||
file = item['file'].replace("mode=play","mode=playfromaddon")
|
||||
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=file, listitem=liz)
|
||||
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...
|
||||
@ -164,9 +157,6 @@ elif "extrafanart" in sys.argv[0]:
|
||||
#always do endofdirectory to prevent errors in the logs
|
||||
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||
|
||||
|
||||
elif sys.argv[1] == "reset":
|
||||
utils.reset()
|
||||
else:
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
||||
|
||||
|
@ -238,7 +238,10 @@ class DownloadUtils():
|
||||
self.logMsg("====== 200 Success ======", 2)
|
||||
return r
|
||||
except:
|
||||
self.logMsg("Unable to convert the response for: %s" % url, 1)
|
||||
if r.headers['content-type'] == "text/html":
|
||||
pass
|
||||
else:
|
||||
self.logMsg("Unable to convert the response for: %s" % url, 1)
|
||||
else:
|
||||
r.raise_for_status()
|
||||
|
||||
|
@ -17,6 +17,9 @@ from DownloadUtils import DownloadUtils
|
||||
from PlaybackUtils import PlaybackUtils
|
||||
|
||||
class Kodi_Monitor(xbmc.Monitor):
|
||||
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
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
|
||||
#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):
|
||||
addon = xbmcaddon.Addon(id='plugin.video.emby')
|
||||
|
||||
WINDOW = self.WINDOW
|
||||
downloadUtils = DownloadUtils()
|
||||
|
||||
if method == "VideoLibrary.OnUpdate":
|
||||
@ -37,15 +41,26 @@ class Kodi_Monitor(xbmc.Monitor):
|
||||
playcount = jsondata.get("playcount")
|
||||
item = jsondata.get("item").get("id")
|
||||
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)
|
||||
WriteKodiDB().updatePlayCountFromKodi(item, type, playcount)
|
||||
|
||||
self.clearProperty(type,item)
|
||||
|
||||
if method == "System.OnWake":
|
||||
xbmc.sleep(10000) #Allow network to wake up
|
||||
utils.logMsg("Doing_Db_Sync Post Resume: syncDatabase (Started)",1)
|
||||
libSync = LibrarySync().FullLibrarySync()
|
||||
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))
|
||||
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ class PlaybackUtils():
|
||||
if xbmc.getCondVisibility("Window.IsActive(home)"):
|
||||
xbmc.Player().play(playurl,listItem)
|
||||
else:
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||
|
||||
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':
|
||||
|
@ -143,16 +143,6 @@ def CleanName(filename):
|
||||
cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore')
|
||||
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():
|
||||
|
||||
@ -161,6 +151,16 @@ def reset():
|
||||
if return_value == 0:
|
||||
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.
|
||||
return_user = xbmcgui.Dialog().yesno("Warning", "Reset all Emby Addon settings?")
|
||||
|
||||
|
@ -1159,6 +1159,17 @@ class WriteKodiDB():
|
||||
ET.ElementTree(root).write(nodefile, xml_declaration=True)
|
||||
except:
|
||||
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):
|
||||
strSet = boxset["Name"]
|
||||
|
@ -10,7 +10,6 @@
|
||||
<setting id="sslcert" type="file" label="Client SSL certificate" visible="eq(-2,true)" enable="true" default="None" />
|
||||
<setting type="sep" />
|
||||
<setting id="deviceName" type="text" label="30016" default="Kodi" />
|
||||
<setting id="playFromStream" type="bool" label="30002" visible="true" enable="true" default="false" />
|
||||
</category>
|
||||
<category label="Sync Options">
|
||||
<!-- <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="autoPlaySeason" type="bool" label="30216" default="false" visible="true" enable="true" />
|
||||
<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="forceTranscodingCodecs" type="text" label="30245" />
|
||||
</category>
|
||||
@ -29,6 +29,6 @@
|
||||
</category>
|
||||
<category label="30022">
|
||||
<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>
|
||||
</settings>
|
||||
|
Loading…
Reference in New Issue
Block a user