2015-07-22 04:53:59 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
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-07-22 04:53:59 +00:00
|
|
|
addon_ = xbmcaddon.Addon(id='plugin.video.emby')
|
|
|
|
addon_path = addon_.getAddonInfo('path').decode('utf-8')
|
2015-12-24 19:51:47 +00:00
|
|
|
base_resource = xbmc.translatePath(os.path.join(addon_path, 'resources', 'lib')).decode('utf-8')
|
|
|
|
sys.path.append(base_resource)
|
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
|
|
|
import entrypoint
|
|
|
|
import utils
|
|
|
|
|
|
|
|
#################################################################################################
|
2015-05-05 11:27:45 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
enableProfiling = False
|
|
|
|
|
|
|
|
class Main:
|
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
# MAIN ENTRY POINT
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
# Parse parameters
|
|
|
|
base_url = sys.argv[0]
|
|
|
|
addon_handle = int(sys.argv[1])
|
|
|
|
params = urlparse.parse_qs(sys.argv[2][1:])
|
|
|
|
xbmc.log("Parameter string: %s" % sys.argv[2])
|
|
|
|
|
|
|
|
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,
|
|
|
|
'nextup': entrypoint.getNextUpEpisodes,
|
|
|
|
'inprogressepisodes': entrypoint.getInProgressEpisodes,
|
2015-12-26 09:42:13 +00:00
|
|
|
'recentepisodes': entrypoint.getRecentEpisodes,
|
|
|
|
'refreshplaylist': entrypoint.refreshPlaylist
|
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
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
elif mode == "channels":
|
|
|
|
modes[mode](itemid)
|
|
|
|
|
|
|
|
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)')
|
|
|
|
elif mode in ("manualsync", "repair"):
|
|
|
|
import librarysync
|
2015-12-26 09:42:13 +00:00
|
|
|
lib = librarysync.LibrarySync()
|
2015-12-24 19:51:47 +00:00
|
|
|
if mode == "manualsync":
|
2015-12-26 09:42:13 +00:00
|
|
|
lib.fullSync(manualrun=True)
|
2015-12-24 19:51:47 +00:00
|
|
|
else:
|
2015-12-26 09:42:13 +00:00
|
|
|
lib.fullSync(repair=True)
|
|
|
|
|
2015-12-24 19:51:47 +00:00
|
|
|
elif mode == "texturecache":
|
|
|
|
import artwork
|
|
|
|
artwork.Artwork().FullTextureCacheSync()
|
|
|
|
elif "extrafanart" in sys.argv[0]:
|
|
|
|
entrypoint.getExtraFanArt()
|
|
|
|
else:
|
|
|
|
entrypoint.doMainListing()
|
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
|
|
|
|
if ( __name__ == "__main__" ):
|
|
|
|
xbmc.log('plugin.video.emby started')
|
|
|
|
|
|
|
|
if enableProfiling:
|
|
|
|
import cProfile
|
|
|
|
import pstats
|
|
|
|
import random
|
|
|
|
from time import gmtime, strftime
|
|
|
|
addonid = addon_.getAddonInfo('id').decode( 'utf-8' )
|
|
|
|
datapath = os.path.join( xbmc.translatePath( "special://profile/" ).decode( 'utf-8' ), "addon_data", addonid )
|
|
|
|
|
|
|
|
filename = os.path.join( datapath, strftime( "%Y%m%d%H%M%S",gmtime() ) + "-" + str( random.randrange(0,100000) ) + ".log" )
|
|
|
|
cProfile.run( 'Main()', filename )
|
|
|
|
|
|
|
|
stream = open( filename + ".txt", 'w')
|
|
|
|
p = pstats.Stats( filename, stream = stream )
|
|
|
|
p.sort_stats( "cumulative" )
|
|
|
|
p.print_stats()
|
2015-05-04 22:24:41 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
else:
|
|
|
|
Main()
|
2015-05-03 15:39:12 +00:00
|
|
|
|
2015-07-27 16:48:00 +00:00
|
|
|
xbmc.log('plugin.video.emby stopped')
|