This commit is contained in:
angelblue05 2016-06-19 16:24:34 -05:00
parent aa3a6fa17f
commit a8fd73740c
5 changed files with 76 additions and 82 deletions

View file

@ -12,32 +12,32 @@ import xbmcgui
#################################################################################################
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)
_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)
#################################################################################################
import entrypoint
import utils
from utils import Logging, window
from utils import Logging, window, language as lang
log = Logging('Default').log
#################################################################################################
log = Logging('Default').log
enableProfiling = False
class Main:
class Main():
# MAIN ENTRY POINT
#@utils.profiling()
def __init__(self):
# Parse parameters
base_url = sys.argv[0]
params = urlparse.parse_qs(sys.argv[2][1:])
xbmc.log("Parameter string: %s" % sys.argv[2])
log("Parameter string: %s" % sys.argv[2], 0)
try:
mode = params['mode'][0]
itemid = params.get('id')
@ -72,11 +72,13 @@ class Main:
embypath = sys.argv[2][1:]
embyid = params.get('id',[""])[0]
entrypoint.getExtraFanArt(embyid,embypath)
return
if "/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]:
embypath = sys.argv[2][1:]
embyid = params.get('id',[""])[0]
entrypoint.getVideoFiles(embyid, embypath)
return
if modes.get(mode):
# Simple functions
@ -88,7 +90,7 @@ class Main:
limit = int(params['limit'][0])
modes[mode](itemid, limit)
elif mode in ["channels","getsubfolders"]:
elif mode in ("channels","getsubfolders"):
modes[mode](itemid)
elif mode == "browsecontent":
@ -104,12 +106,13 @@ class Main:
# Other functions
if mode == "settings":
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
elif mode in ("manualsync", "fastsync", "repair"):
if window('emby_online') != "true":
# Server is not online, do not run the sync
xbmcgui.Dialog().ok(heading="Emby for Kodi",
line1=("Unable to run the sync, the add-on is not "
"connected to the Emby server."))
xbmcgui.Dialog().ok(heading=lang(29999),
line1=lang(33034))
log("Not connected to the emby server.", 1)
return
@ -128,30 +131,12 @@ class Main:
elif mode == "texturecache":
import artwork
artwork.Artwork().FullTextureCacheSync()
else:
entrypoint.doMainListing()
if ( __name__ == "__main__" ):
if __name__ == "__main__":
log('plugin.video.emby started', 1)
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()
else:
Main()
log('plugin.video.emby stopped', 1)

View file

@ -1,25 +1,30 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<!-- Add-on settings -->
<string id="29999">Emby for Kodi</string>
<string id="30000">Primary Server Address</string><!-- Verified -->
<string id="30002">Play from HTTP instead of SMB</string><!-- Verified -->
<string id="30004">Log level</string><!-- Verified -->
<string id="30005">Username: </string>
<string id="30006">Password: </string>
<string id="30024">Username</string><!-- Verified -->
<string id="30030">Port Number</string><!-- Verified -->
<!-- Add-on settings -->
<string id="30007">Network Username: </string>
<string id="30008">Network Password: </string>
<string id="30009">Transcode: </string>
<string id="30010">Enable Performance Profiling</string>
<string id="30011">Local caching system</string>
<string id="30014">Emby</string>
<string id="30015">Network</string>
<string id="30016">Device Name</string>
<string id="30022">Advanced</string>
<string id="30024">Username</string><!-- Verified -->
<string id="30030">Port Number</string><!-- Verified -->
<string id="30036">Number of recent Movies to show:</string>
<string id="30037">Number of recent TV episodes to show:</string>
<string id="30035">Number of recent Music Albums to show:</string>
@ -175,7 +180,8 @@
<string id="30198">Search</string>
<string id="30199">Set Views</string>
<string id="30200">Select User</string>
<string id="30200">Select User</string><!-- Verified -->
<string id="30201">Profiling enabled.</string>
<string id="30202">Please remember to turn off when finished testing.</string>
<string id="30203">Error in ArtworkRotationThread</string>
@ -262,6 +268,12 @@
<string id="30409">Delete item from the server</string>
<!-- add-on settings -->
<string id="30000">Primary Server Address</string><!-- Verified -->
<string id="30002">Play from HTTP instead of SMB</string><!-- Verified -->
<string id="30004">Log level</string><!-- Verified -->
<string id="30024">Username</string><!-- Verified -->
<string id="30030">Port Number</string><!-- Verified -->
<string id="30500">Verify Host SSL Certificate</string>
<string id="30501">Client SSL certificate</string>
<string id="30502">Use alternate address</string>
@ -300,6 +312,7 @@
<string id="30535">Generate a new device Id</string>
<string id="30536">Sync when screensaver is deactivated</string>
<string id="30537">Force Transcode Hi10P</string>
<string id="30538">Disabled</string>
<!-- service add-on -->
<string id="33000">Welcome</string>
@ -337,4 +350,12 @@
<string id="33032">Failed to generate a new device Id. See your logs for more information.</string>
<string id="33033">A new device Id has been generated. Kodi will now restart.</string>
<string id="33034">Proceed with the following server?</string>
<string id="33035">Caution! If you choose Native mode, certain Emby features will be missing, such as: Emby cinema mode, direct stream/transcode options and parental access schedule.</string>
<string id="33036">Addon (Default)</string>
<string id="33037">Native (Direct Paths)</string>
<string id="33038">"Add network credentials to allow Kodi access to your content? Important: Kodi will need to be restarted to see the credentials. They can also be added at a later time.</string>
<string id="33039">Disable Emby music library?</string>
<string id="33040">Direct stream the music library? Select this option if the music library will be remotely accessed.</string>
</strings>

View file

@ -25,15 +25,15 @@ class InitialSetup():
global log
log = Logging(self.__class__.__name__).log
self.clientInfo = clientinfo.ClientInfo()
self.addonId = self.clientInfo.getAddonId()
self.doUtils = downloadutils.DownloadUtils()
self.addonId = clientinfo.ClientInfo().getAddonId()
self.doUtils = downloadutils.DownloadUtils().downloadUrl
self.userClient = userclient.UserClient()
def setup(self):
# Check server, user, direct paths, music, direct stream if not direct path.
addonId = self.addonId
dialog = xbmcgui.Dialog()
##### SERVER INFO #####
@ -54,9 +54,9 @@ class InitialSetup():
xbmc.executebuiltin('Addon.OpenSettings(%s)' % addonId)
return
else:
server_confirm = xbmcgui.Dialog().yesno(
heading="Emby for Kodi",
line1="Proceed with the following server?",
server_confirm = dialog.yesno(
heading=lang(29999),
line1=lang(33034),
line2="%s %s" % (lang(30169), server))
if server_confirm:
# Correct server found
@ -76,8 +76,7 @@ class InitialSetup():
log("Getting user list.", 1)
url = "%s/emby/Users/Public?format=json" % server
result = self.doUtils.downloadUrl(url, authenticate=False)
result = self.doUtils("%s/emby/Users/Public?format=json" % server, authenticate=False)
if result == "":
log("Unable to connect to %s" % server, 1)
return
@ -97,7 +96,7 @@ class InitialSetup():
users_hasPassword.append(name)
log("Presenting user list: %s" % users_hasPassword, 1)
user_select = xbmcgui.Dialog().select(lang(30200), users_hasPassword)
user_select = dialog.select(lang(30200), users_hasPassword)
if user_select > -1:
selected_user = usernames[user_select]
log("Selected user: %s" % selected_user, 1)
@ -105,38 +104,30 @@ class InitialSetup():
else:
log("No user selected.", 1)
xbmc.executebuiltin('Addon.OpenSettings(%s)' % addonId)
return
##### ADDITIONAL PROMPTS #####
dialog = xbmcgui.Dialog()
directPaths = dialog.yesno(
heading="Playback Mode",
line1=(
"Caution! If you choose Native mode, you "
"will lose access to certain Emby features such as: "
"Emby cinema mode, direct stream/transcode options, "
"parental access schedule."),
nolabel="Addon (Default)",
yeslabel="Native (Direct Paths)")
heading=lang(30511),
line1=lang(33035),
nolabel=lang(33036),
yeslabel=lang(33037))
if directPaths:
log("User opted to use direct paths.", 1)
settings('useDirectPaths', value="1")
# ask for credentials
credentials = dialog.yesno(
heading="Network credentials",
line1= (
"Add network credentials to allow Kodi access to your "
"content? Note: Skipping this step may generate a message "
"during the initial scan of your content if Kodi can't "
"locate your content."))
heading=lang(30517),
line1= lang(33038))
if credentials:
log("Presenting network credentials dialog.", 1)
passwordsXML()
musicDisabled = dialog.yesno(
heading="Music Library",
line1="Disable Emby music library?")
heading=lang(29999),
line1=lang(33039))
if musicDisabled:
log("User opted to disable Emby music library.", 1)
settings('enableMusic', value="false")
@ -144,11 +135,8 @@ class InitialSetup():
# Only prompt if the user didn't select direct paths for videos
if not directPaths:
musicAccess = dialog.yesno(
heading="Music Library",
line1=(
"Direct stream the music library? Select "
"this option only if you plan on listening "
"to music outside of your network."))
heading=lang(29999),
line1=lang(33040))
if musicAccess:
log("User opted to direct stream music.", 1)
settings('streamMusic', value="true")

View file

@ -33,7 +33,7 @@
<setting id="imageCacheLimit" type="enum" label="30513" values="Disabled|5|10|15|20|25" default="0" visible="eq(-1,true)" subsetting="true" />
<setting id="syncEmptyShows" type="bool" label="30508" default="false" />
<setting id="dbSyncScreensaver" label="30536" type="bool" default="false" />
<setting id="useDirectPaths" type="enum" label="30511" values="Addon(Default)|Native(Direct paths)" default="0" />
<setting id="useDirectPaths" type="enum" label="30511" lvalues="33036|33037" default="0" />
<setting id="enableMusic" type="bool" label="30509" default="true" />
<setting id="streamMusic" type="bool" label="30510" default="false" visible="eq(-1,true)" subsetting="true" />
<setting type="lsep" label="30523" />

View file

@ -167,7 +167,7 @@ class Service():
else:
add = ""
xbmcgui.Dialog().notification(
heading="Emby for Kodi",
heading=lang(29999),
message=("%s %s%s!"
% (lang(33000), user.currUser.decode('utf-8'),
add.decode('utf-8'))),
@ -242,7 +242,7 @@ class Service():
break
# Alert the user that server is online.
xbmcgui.Dialog().notification(
heading="Emby for Kodi",
heading=lang(29999),
message=lang(33003),
icon="special://home/addons/plugin.video.emby/icon.png",
time=2000,