示例#1
0
    def libraries(self, library_id=None, update=False):
        ''' Map the syncing process and start the sync. Ensure only one sync is running.
        '''
        self.direct_path = settings('useDirectPaths') == "1"
        self.update_library = update
        self.sync = get_sync()

        if library_id:
            libraries = library_id.split(',')

            for selected in libraries:

                if selected not in [
                        x.replace('Mixed:', "") for x in self.sync['Libraries']
                ]:
                    library = self.get_libraries(selected)

                    if library:

                        self.sync['Libraries'].append("Mixed:%s" %
                                                      selected if library[1] ==
                                                      'mixed' else selected)

                        if library[1] in ('mixed', 'movies'):
                            self.sync['Libraries'].append('Boxsets:%s' %
                                                          selected)
                    else:
                        self.sync['Libraries'].append(selected)
        else:
            self.mapping()

        xmls.sources()

        if not xmls.advanced_settings() and self.sync['Libraries']:
            self.start()
示例#2
0
    def __init__(self, library, library_id=None, update=False):

        ''' Map the syncing process and start the sync. Ensure only one sync is running.
        '''
        self.__dict__ = self._shared_state
        window('emby_sync.bool', True)

        if not settings('dbSyncScreensaver.bool'):

            xbmc.executebuiltin('InhibitIdleShutdown(true)')
            self.screensaver = get_screensaver()
            set_screensaver(value="")

        if not self.running:

            self.running = True
            self.library = library
            self.direct_path = settings('useDirectPaths') == "1"
            self.update_library = update
            self.server = Emby()
            self.sync = get_sync()

            if library_id:
                libraries = library_id.split(',')

                for selected in libraries:

                    if selected not in [x.replace('Mixed:', "") for x in self.sync['Libraries']]:
                        library = self.get_libraries(selected)

                        if library:

                            self.sync['Libraries'].append("Mixed:%s" % selected if library[1] == 'mixed' else selected)

                            if library[1] in ('mixed', 'movies'):
                                self.sync['Libraries'].append('Boxsets:%s' % selected)
                        else:
                            self.sync['Libraries'].append(selected)
            else:
                self.mapping()

            xmls.sources()

            if not xmls.advanced_settings() and self.sync['Libraries']:
                self.start()
            else:
                self.running = False
        else:
            dialog("ok", heading="{emby}", line1=_(33197))

            raise Exception("Sync is already running.")
示例#3
0
    def libraries(self, library_id=None, update=False):
        ''' Map the syncing process and start the sync. Ensure only one sync is running.
        '''
        self.direct_path = settings('useDirectPaths') == "1"
        self.update_library = update
        self.sync = get_sync()

        if library_id:

            # Look up library in local Jellyfin database
            library = self.get_library(library_id)

            if library:
                if library.media_type == 'mixed':
                    self.sync['Libraries'].append("Mixed:%s" % library_id)
                    # Include boxsets library
                    libraries = self.get_libraries()
                    boxsets = [
                        row.view_id for row in libraries
                        if row.media_type == 'boxsets'
                    ]
                    if boxsets:
                        self.sync['Libraries'].append('Boxsets:%s' %
                                                      boxsets[0])
                elif library.media_type == 'movies':
                    self.sync['Libraries'].append(library_id)
                    # Include boxsets library
                    libraries = self.get_libraries()
                    boxsets = [
                        row.view_id for row in libraries
                        if row.media_type == 'boxsets'
                    ]
                    if boxsets:
                        self.sync['Libraries'].append('Boxsets:%s' %
                                                      boxsets[0])
                else:
                    # Only called if the library isn't already known about
                    self.sync['Libraries'].append(library_id)
            else:
                self.sync['Libraries'].append(library_id)
        else:
            self.mapping()

        if not xmls.advanced_settings() and self.sync['Libraries']:
            self.start()