Skip to content

Commit

Permalink
+ add an option to generate a new device ID (closes #39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Feb 12, 2021
1 parent e6e9f43 commit 442d542
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[B]Version 0.0.10[/B]
- fix exception when showing PIN for Emby Connect
- don't require a password for logging in (closes #40)
- add an option to generate a new device ID (closes #39)

[B]Version 0.0.10[/B]
- add Portuguese (Brazil) translation
Expand Down
2 changes: 2 additions & 0 deletions emby/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@

SETTING_PROVIDER_INTERFACE_SHOW_SERVER_MESSAGES = 'emby.showservermessages'

SETTING_PROVIDER_ADVANCED_RESET_DEVICE_ID = 'emby.resetdeviceid'

# media import setting identifiers and values
SETTING_IMPORT_FORCE_SYNC = 'emby.forcesync'
SETTING_IMPORT_VIEWS = 'emby.importviews'
Expand Down
22 changes: 22 additions & 0 deletions lib/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,26 @@ def forceSync(handle, _):
SynchronizationSettings.ResetHash(importSettings, save=False)


def resetDeviceId(handle, _):
# retrieve the media provider
mediaProvider = xbmcmediaimport.getProvider(handle)
if not mediaProvider:
log('cannot retrieve media provider', xbmc.LOGERROR)
return

# get the media provider settings
providerSettings = mediaProvider.prepareSettings()
if not providerSettings:
return

deviceId = Request.GenerateDeviceId()
log('created a new device identifier for {}: {}'.format(mediaProvider2str(mediaProvider), deviceId))

providerSettings.setString(emby.constants.SETTING_PROVIDER_DEVICEID, deviceId)

xbmcgui.Dialog().ok(mediaProvider.getFriendlyName(), localise(32063))


def settingOptionsFillerUsers(handle, _):
# retrieve the media provider
mediaProvider = xbmcmediaimport.getProvider(handle)
Expand Down Expand Up @@ -603,6 +623,7 @@ def loadProviderSettings(handle, _):

settings.registerActionCallback(emby.constants.SETTING_PROVIDER_LINK_EMBY_CONNECT, 'linkembyconnect')
settings.registerActionCallback(emby.constants.SETTING_PROVIDER_TEST_AUTHENTICATION, 'testauthentication')
settings.registerActionCallback(emby.constants.SETTING_PROVIDER_ADVANCED_RESET_DEVICE_ID, 'resetdeviceid')

# register a setting options filler for the list of users
settings.registerOptionsFillerCallback(emby.constants.SETTING_PROVIDER_USER, 'settingoptionsfillerusers')
Expand Down Expand Up @@ -970,6 +991,7 @@ def updateOnProvider(handle, _):
'linkembyconnect': linkEmbyConnect,
'testauthentication': testAuthentication,
'forcesync': forceSync,
'resetdeviceid': resetDeviceId,

# custom setting options fillers
'settingoptionsfillerusers': settingOptionsFillerUsers,
Expand Down
12 changes: 12 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ msgctxt "#32042"
msgid "Force full synchronisation"
msgstr ""

msgctxt "#32043"
msgid "Advanced"
msgstr ""

msgctxt "#32044"
msgid "Generate a new device ID"
msgstr ""

#. Titel of the dialog to enter the base URI of the Emby server to lookup
msgctxt "#32050"
msgid "Emby server base URI"
Expand Down Expand Up @@ -212,6 +220,10 @@ msgctxt "#32062"
msgid "Successfully linked to Emby Connect."
msgstr ""

msgctxt "#32063"
msgid "A new device ID has been successfully generated.\n\nPlease save the settings and restart Kodi."
msgstr ""

#. Label of the play context menu item
msgctxt "#32100"
msgid "Play ..."
Expand Down
6 changes: 6 additions & 0 deletions resources/providersettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@
</constraints>
</setting>
</group>
<group id="2" label="32043">
<setting id="emby.resetdeviceid" type="action" label="32044">
<level>0</level>
<control type="button" format="action" />
</setting>
</group>
</category>
<category id="synchronization" label="32040">
<group id="1">
Expand Down

0 comments on commit 442d542

Please sign in to comment.