2015-07-22 04:53:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-07-24 08:59:48 +00:00
|
|
|
import logging
|
2015-12-24 19:51:47 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2015-07-27 16:48:00 +00:00
|
|
|
import urlparse
|
2015-05-03 15:39:12 +00:00
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
import xbmc
|
|
|
|
import xbmcaddon
|
2015-12-26 18:53:24 +00:00
|
|
|
import xbmcgui
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2016-06-19 21:24:34 +00:00
|
|
|
_addon = xbmcaddon.Addon(id='plugin.video.emby')
|
|
|
|
_addon_path = _addon.getAddonInfo('path').decode('utf-8')
|
|
|
|
_base_resource = xbmc.translatePath(os.path.join(_addon_path, 'resources', 'lib')).decode('utf-8')
|
|
|
|
sys.path.append(_base_resource)
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
import entrypoint
|
|
|
|
import utils
|
2016-07-24 08:59:48 +00:00
|
|
|
from utils import window, language as lang
|
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
import loghandler
|
|
|
|
|
|
|
|
loghandler.config()
|
|
|
|
log = logging.getLogger("EMBY.default")
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
2015-05-05 11:27:45 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
|
2016-06-19 21:24:34 +00:00
|
|
|
class Main():
|
2015-07-27 16:48:00 +00:00
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
# MAIN ENTRY POINT
|
2016-06-19 21:24:34 +00:00
|
|
|
#@utils.profiling()
|
2015-07-27 16:48:00 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
# Parse parameters
|
|
|
|
base_url = sys.argv[0]
|
|
|
|
params = urlparse.parse_qs(sys.argv[2][1:])
|
2016-07-24 08:59:48 +00:00
|
|
|
log.warn("Parameter string: %s" % sys.argv[2])
|
2015-07-27 16:48:00 +00:00
|
|
|
try:
|
|
|
|
mode = params['mode'][0]
|
2015-12-24 19:51:47 +00:00
|
|
|
itemid = params.get('id')
|
|
|
|
if itemid:
|
|
|
|
itemid = itemid[0]
|
2015-07-27 16:48:00 +00:00
|
|
|
except:
|
|
|
|
params = {}
|
|
|
|
mode = ""
|
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
modes = {
|
|
|
|
|
|
|
|
'reset': utils.reset,
|
|
|
|
'resetauth': entrypoint.resetAuth,
|
|
|
|
'play': entrypoint.doPlayback,
|
|
|
|
'passwords': utils.passwordsXML,
|
|
|
|
'adduser': entrypoint.addUser,
|
|
|
|
'thememedia': entrypoint.getThemeMedia,
|
|
|
|
'channels': entrypoint.BrowseChannels,
|
|
|
|
'channelsfolder': entrypoint.BrowseChannels,
|
2016-01-11 21:20:34 +00:00
|
|
|
'browsecontent': entrypoint.BrowseContent,
|
2016-01-22 10:10:42 +00:00
|
|
|
'getsubfolders': entrypoint.GetSubFolders,
|
2015-12-24 19:51:47 +00:00
|
|
|
'nextup': entrypoint.getNextUpEpisodes,
|
|
|
|
'inprogressepisodes': entrypoint.getInProgressEpisodes,
|
2015-12-26 09:42:13 +00:00
|
|
|
'recentepisodes': entrypoint.getRecentEpisodes,
|
2016-02-29 05:20:59 +00:00
|
|
|
'refreshplaylist': entrypoint.refreshPlaylist,
|
2016-03-09 23:05:35 +00:00
|
|
|
'deviceid': entrypoint.resetDeviceId,
|
|
|
|
'delete': entrypoint.deleteItem
|
2015-12-24 19:51:47 +00:00
|
|
|
}
|
2016-01-06 22:22:10 +00:00
|
|
|
|
2016-03-04 21:00:24 +00:00
|
|
|
if "/extrafanart" in sys.argv[0]:
|
2016-03-04 13:03:15 +00:00
|
|
|
embypath = sys.argv[2][1:]
|
|
|
|
embyid = params.get('id',[""])[0]
|
|
|
|
entrypoint.getExtraFanArt(embyid,embypath)
|
2016-06-19 21:24:34 +00:00
|
|
|
return
|
2016-03-04 21:00:24 +00:00
|
|
|
|
|
|
|
if "/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]:
|
|
|
|
embypath = sys.argv[2][1:]
|
|
|
|
embyid = params.get('id',[""])[0]
|
2016-06-19 21:24:34 +00:00
|
|
|
entrypoint.getVideoFiles(embyid, embypath)
|
|
|
|
return
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
if modes.get(mode):
|
|
|
|
# Simple functions
|
|
|
|
if mode == "play":
|
|
|
|
dbid = params.get('dbid')
|
|
|
|
modes[mode](itemid, dbid)
|
|
|
|
|
|
|
|
elif mode in ("nextup", "inprogressepisodes", "recentepisodes"):
|
|
|
|
limit = int(params['limit'][0])
|
|
|
|
modes[mode](itemid, limit)
|
2015-07-27 16:48:00 +00:00
|
|
|
|
2016-06-19 21:24:34 +00:00
|
|
|
elif mode in ("channels","getsubfolders"):
|
2015-12-24 19:51:47 +00:00
|
|
|
modes[mode](itemid)
|
2016-01-11 21:20:34 +00:00
|
|
|
|
|
|
|
elif mode == "browsecontent":
|
2016-06-19 21:24:34 +00:00
|
|
|
modes[mode](itemid, params.get('type',[""])[0], params.get('folderid',[""])[0])
|
2015-12-24 19:51:47 +00:00
|
|
|
|
|
|
|
elif mode == "channelsfolder":
|
|
|
|
folderid = params['folderid'][0]
|
|
|
|
modes[mode](itemid, folderid)
|
2015-07-27 16:48:00 +00:00
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
else:
|
|
|
|
modes[mode]()
|
|
|
|
else:
|
|
|
|
# Other functions
|
|
|
|
if mode == "settings":
|
|
|
|
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
2016-06-19 21:24:34 +00:00
|
|
|
|
2016-04-28 09:05:33 +00:00
|
|
|
elif mode in ("manualsync", "fastsync", "repair"):
|
2016-06-19 21:24:34 +00:00
|
|
|
|
2016-06-18 23:39:13 +00:00
|
|
|
if window('emby_online') != "true":
|
2016-02-10 07:07:52 +00:00
|
|
|
# Server is not online, do not run the sync
|
2016-06-19 21:24:34 +00:00
|
|
|
xbmcgui.Dialog().ok(heading=lang(29999),
|
|
|
|
line1=lang(33034))
|
2016-07-24 08:59:48 +00:00
|
|
|
log.warn("Not connected to the emby server.")
|
2016-02-10 07:07:52 +00:00
|
|
|
return
|
|
|
|
|
2016-06-18 23:39:13 +00:00
|
|
|
if window('emby_dbScan') != "true":
|
2015-12-26 18:53:24 +00:00
|
|
|
import librarysync
|
|
|
|
lib = librarysync.LibrarySync()
|
|
|
|
if mode == "manualsync":
|
2016-07-03 03:26:11 +00:00
|
|
|
librarysync.ManualSync().sync()
|
2016-04-28 09:05:33 +00:00
|
|
|
elif mode == "fastsync":
|
|
|
|
lib.startSync()
|
2015-12-26 18:53:24 +00:00
|
|
|
else:
|
|
|
|
lib.fullSync(repair=True)
|
2015-12-24 19:51:47 +00:00
|
|
|
else:
|
2016-07-24 08:59:48 +00:00
|
|
|
log.warn("Database scan is already running.")
|
2015-12-26 09:42:13 +00:00
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
elif mode == "texturecache":
|
|
|
|
import artwork
|
2016-06-21 01:57:29 +00:00
|
|
|
artwork.Artwork().fullTextureCacheSync()
|
2016-06-19 21:24:34 +00:00
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
else:
|
|
|
|
entrypoint.doMainListing()
|
|
|
|
|
2016-06-19 21:24:34 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2016-07-24 08:59:48 +00:00
|
|
|
log.info('plugin.video.emby started')
|
2016-06-19 21:24:34 +00:00
|
|
|
Main()
|
2016-07-24 08:59:48 +00:00
|
|
|
log.info('plugin.video.emby stopped')
|