Ejemplo n.º 1
0
    def movies(self, library, dialog):
        ''' Process movies from a single library.
        '''
        processed_ids = []

        for items in server.get_items(library['Id'], "Movie", False,
                                      self.sync['RestorePoint'].get('params')):

            with self.video_database_locks() as (videodb, jellyfindb):
                obj = Movies(self.server, jellyfindb, videodb,
                             self.direct_path)

                self.sync['RestorePoint'] = items['RestorePoint']
                start_index = items['RestorePoint']['params']['StartIndex']

                for index, movie in enumerate(items['Items']):

                    dialog.update(int(
                        (float(start_index + index) /
                         float(items['TotalRecordCount'])) * 100),
                                  heading="%s: %s" %
                                  (translate('addon_name'), library['Name']),
                                  message=movie['Name'])
                    obj.movie(movie, library=library)
                    processed_ids.append(movie['Id'])

        with self.video_database_locks() as (videodb, jellyfindb):
            obj = Movies(self.server, jellyfindb, videodb, self.direct_path)
            obj.item_ids = processed_ids

            if self.update_library:
                self.movies_compare(library, obj, jellyfindb)
Ejemplo n.º 2
0
    def movies(self, library, dialog):

        ''' Process movies from a single library.
        '''
        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:

                    obj = Movies(self.server, embydb, videodb, self.direct_path)

                    for items in server.get_items(library['Id'], "Movie", False, self.sync['RestorePoint'].get('params')):
                        
                        self.sync['RestorePoint'] = items['RestorePoint']
                        start_index = items['RestorePoint']['params']['StartIndex']

                        for index, movie in enumerate(items['Items']):

                            dialog.update(int((float(start_index + index) / float(items['TotalRecordCount']))*100),
                                          heading="%s: %s" % (_('addon_name'), library['Name']),
                                          message=movie['Name'])
                            obj.movie(movie, library=library)

                    if self.update_library:
                        self.movies_compare(library, obj, embydb)
Ejemplo n.º 3
0
    def run(self):
        with self.lock, self.database as kodidb, Database(
                'jellyfin') as jellyfindb:
            default_args = (self.server, jellyfindb, kodidb, self.direct_path)
            if kodidb.db_file == "video":
                movies = Movies(*default_args)
                tvshows = TVShows(*default_args)
                musicvideos = MusicVideos(*default_args)
            elif kodidb.db_file == "music":
                music = Music(*default_args)
            else:
                # this should not happen
                LOG.error('"{}" is not a valid Kodi library type.'.format(
                    kodidb.db_file))
                return

            while True:

                try:
                    item = self.queue.get(timeout=1)
                except Queue.Empty:
                    break

                try:
                    LOG.debug('{} - {}'.format(item['Type'], item['Name']))
                    if item['Type'] == 'Movie':
                        movies.movie(item)
                    elif item['Type'] == 'BoxSet':
                        movies.boxset(item)
                    elif item['Type'] == 'Series':
                        tvshows.tvshow(item)
                    elif item['Type'] == 'Season':
                        tvshows.season(item)
                    elif item['Type'] == 'Episode':
                        tvshows.episode(item)
                    elif item['Type'] == 'MusicVideo':
                        musicvideos.musicvideo(item)
                    elif item['Type'] == 'MusicAlbum':
                        music.album(item)
                    elif item['Type'] == 'MusicArtist':
                        music.artist(item)
                    elif item['Type'] == 'AlbumArtist':
                        music.albumartist(item)
                    elif item['Type'] == 'Audio':
                        music.song(item)

                    if self.notify:
                        self.notify_output.put(
                            (item['Type'], api.API(item).get_naming()))
                except LibraryException as error:
                    if error.status == 'StopCalled':
                        break
                except Exception as error:
                    LOG.exception(error)

                self.queue.task_done()

                if window('jellyfin_should_stop.bool'):
                    break

        LOG.info("--<[ q:updated/%s ]", id(self))
        self.is_done = True