Add option to generate a new device Id

This commit is contained in:
angelblue05 2016-02-28 23:20:59 -06:00
parent a0acdd6a7a
commit dfa5c7b313
5 changed files with 35 additions and 2 deletions

View file

@ -62,7 +62,8 @@ class Main:
'nextup': entrypoint.getNextUpEpisodes,
'inprogressepisodes': entrypoint.getInProgressEpisodes,
'recentepisodes': entrypoint.getRecentEpisodes,
'refreshplaylist': entrypoint.refreshPlaylist
'refreshplaylist': entrypoint.refreshPlaylist,
'deviceid': entrypoint.resetDeviceId
}
if "extrafanart" in sys.argv[0]:

View file

@ -297,6 +297,7 @@
<string id="30532">Duration of the video library pop up (in seconds)</string>
<string id="30533">Duration of the music library pop up (in seconds)</string>
<string id="30534">Server messages</string>
<string id="30535">Generate a new device Id</string>
<!-- service add-on -->
<string id="33000">Welcome</string>
@ -331,5 +332,7 @@
<string id="33029">Comparing tv shows from:</string>
<string id="33030">Comparing episodes from:</string>
<string id="33031">Comparing:</string>
<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>
</strings>

View file

@ -69,7 +69,7 @@ class ClientInfo():
else:
return "Unknown"
def getDeviceId(self):
def getDeviceId(self, reset=False):
clientId = utils.window('emby_deviceId')
if clientId:
@ -81,6 +81,10 @@ class ClientInfo():
else:
GUID_file = xbmc.translatePath(os.path.join(addon_path.encode("utf-8"), "machine_guid")).decode('utf-8')
if reset and xbmcvfs.exists(GUID_file):
# Reset the file
xbmcvfs.delete(GUID_file)
GUID = xbmcvfs.File(GUID_file)
clientId = GUID.read()
if not clientId:

View file

@ -94,6 +94,30 @@ def doMainListing():
xbmcplugin.endOfDirectory(int(sys.argv[1]))
##### Generate a new deviceId
def resetDeviceId():
dialog = xbmcgui.Dialog()
language = utils.language
deviceId_old = utils.window('emby_deviceId')
try:
utils.window('emby_deviceId', clear=True)
deviceId = clientinfo.ClientInfo().getDeviceId(reset=True)
except Exception as e:
utils.logMsg("EMBY", "Failed to generate a new device Id: %s" % e, 1)
dialog.ok(
heading="Emby for Kodi",
line1=language(33032))
else:
utils.logMsg("EMBY", "Successfully removed old deviceId: %s New deviceId: %s"
% (deviceId_old, deviceId), 1)
dialog.ok(
heading="Emby for Kodi",
line1=language(33033))
xbmc.executebuiltin('RestartApp')
##### ADD ADDITIONAL USERS #####
def addUser():

View file

@ -76,5 +76,6 @@
<setting id="logLevel" type="enum" label="30004" values="Disabled|Info|Debug" default="1" />
<setting id="startupDelay" type="number" label="30529" default="0" option="int" />
<setting label="30239" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=reset)" option="close" />
<setting label="30535" type="action" action="RunPlugin(plugin://plugin.video.emby?mode=deviceid)" />
</category>
</settings>