Skip to content

Commit

Permalink
+ add an import-specific setting to force a full synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Mar 24, 2020
1 parent 6612515 commit 13cf892
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- fix exceptions / crashes when playing non-imported videos
- support authentication with Emby Connect
- support fast synchronization after a successful initial full synchronization
- add an import-specific setting to force a full synchronization

[B]Version 0.0.6[/B]
- fix playback stopped / ended callback handling
Expand Down
1 change: 1 addition & 0 deletions emby/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
SETTING_PROVIDER_INTERFACE_SHOW_SERVER_MESSAGES = 'emby.showservermessages'

# media import setting identifiers and values
SETTING_IMPORT_FORCE_SYNC = 'emby.forcesync'
SETTING_IMPORT_VIEWS = 'emby.importviews'
SETTING_IMPORT_VIEWS_OPTION_ALL = 'all'
SETTING_IMPORT_VIEWS_OPTION_SPECIFIC = 'specific'
Expand Down
24 changes: 24 additions & 0 deletions lib/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,27 @@ def testAuthentication(handle, options):
line = 32017
xbmcgui.Dialog().ok(title, localise(line))

def forceSync(handle, options):
# ask the user whether he is sure
force = xbmcgui.Dialog().yesno(localise(32042), localise(32053))
if not force:
return

# retrieve the media import
mediaImport = xbmcmediaimport.getImport(handle)
if not mediaImport:
log('cannot retrieve media import', xbmc.LOGERROR)
return

# prepare the media provider settings
importSettings = mediaImport.prepareSettings()
if not importSettings:
log('cannot prepare media import settings', xbmc.LOGERROR)
return

# reset the synchronization hash setting to force a full synchronization
SynchronizationSettings.ResetHash(importSettings, save=False)

def settingOptionsFillerUsers(handle, options):
# retrieve the media provider
mediaProvider = xbmcmediaimport.getProvider(handle)
Expand Down Expand Up @@ -550,6 +571,8 @@ def loadImportSettings(handle, options):
log('cannot retrieve media import settings', xbmc.LOGERROR)
return

settings.registerActionCallback(emby.constants.SETTING_IMPORT_FORCE_SYNC, 'forcesync')

# register a setting options filler for the list of views
settings.registerOptionsFillerCallback(emby.constants.SETTING_IMPORT_VIEWS_SPECIFIC, 'settingoptionsfillerviews')

Expand Down Expand Up @@ -871,6 +894,7 @@ def updateOnProvider(handle, options):
# custom setting callbacks
'linkembyconnect': linkEmbyConnect,
'testauthentication': testAuthentication,
'forcesync': forceSync,

# custom setting options fillers
'settingoptionsfillerusers': settingOptionsFillerUsers,
Expand Down
9 changes: 9 additions & 0 deletions lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ def HaveChanged(mediaTypes, providerSettings, importSettings, save=True):
SynchronizationSettings.SaveHash(importSettings, newHash)

return True

@staticmethod
def ResetHash(importSettings, save=True):
if not importSettings:
raise ValueError('invalid importSettings')

importSettings.setString(SETTING_IMPORT_SYNC_SETTINGS_HASH, '')
if save:
importSettings.save()
8 changes: 8 additions & 0 deletions resources/importsettings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<settings version="1">
<section id="import" label="32010">
<category id="sync" label="39530">
<group id="1">
<setting id="emby.forcesync" type="action" label="32042">
<level>0</level>
<control type="button" format="action" />
</setting>
</group>
</category>
<category id="library" label="32024">
<group id="1">
<setting id="emby.importviews" type="string" label="32020">
Expand Down
8 changes: 8 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ msgctxt "#32041"
msgid "Use Kodi Companion server plugin"
msgstr ""

msgctxt "#32042"
msgid "Force full synchronization"
msgstr ""

#. Titel of the dialog to enter the base URI of the Emby server to lookup
msgctxt "#32050"
msgid "Emby server base URI"
Expand All @@ -161,6 +165,10 @@ msgstr ""
#. Text of the notification when an Emby server is restarting
msgctxt "#32052"
msgid "{} is restarting."

#. Text of the dialog asking the user if he really wants to force sync
msgctxt "#32053"
msgid "Do you really want to force a full synchronization?"
msgstr ""

#. Titel of the dialog to select the authentication method
Expand Down

0 comments on commit 13cf892

Please sign in to comment.