示例#1
0
    def musicvideos(self, embycursor, kodicursor, pdialog):

        # Get musicvideos from emby
        emby_db = embydb.Embydb_Functions(embycursor)
        mvideos = MusicVideos(embycursor, kodicursor, pdialog)

        views = emby_db.getView_byType('musicvideos')
        log.info("Media folders: %s" % views)

        for view in views:
            log.info("Processing: %s", view)

            # Get items per view
            viewId = view['id']
            viewName = view['name']

            if pdialog:
                pdialog.update(
                        heading=lang(29999),
                        message="%s %s..." % (lang(33019), viewName))

            # Initial or repair sync
            all_mvideos = self.emby.getMusicVideos(viewId, dialog=pdialog)
            mvideos.add_all("MusicVideo", all_mvideos, view)

        else:
            log.debug("MusicVideos finished.")

        return True
示例#2
0
    def musicvideos(self, embycursor, kodicursor, pdialog):

        # Get musicvideos from emby
        emby_db = embydb.Embydb_Functions(embycursor)
        mvideos = MusicVideos(embycursor, kodicursor, pdialog)

        views = emby_db.getView_byType('musicvideos')
        log.info("Media folders: %s" % views)

        for view in views:
            log.info("Processing: %s", view)

            # Get items per view
            viewId = view['id']
            viewName = view['name']

            if pdialog:
                pdialog.update(
                        heading=lang(29999),
                        message="%s %s..." % (lang(33019), viewName))

            # Initial or repair sync
            all_mvideos = self.emby.getMusicVideos(viewId, dialog=pdialog)
            mvideos.add_all("MusicVideo", all_mvideos, view)

        else:
            log.debug("MusicVideos finished.")

        return True
示例#3
0
    def run(self):

        with self.lock, self.database as kodidb, Database('jellyfin') as jellyfindb:
            while True:

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

                if item['Type'] == 'Movie':
                    obj = Movies(self.args[0], jellyfindb, kodidb, self.args[1]).remove
                elif item['Type'] in ['Series', 'Season', 'Episode']:
                    obj = TVShows(self.args[0], jellyfindb, kodidb, self.args[1]).remove
                elif item['Type'] in ['MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio']:
                    obj = Music(self.args[0], jellyfindb, kodidb, self.args[1]).remove
                elif item['Type'] == 'MusicVideo':
                    obj = MusicVideos(self.args[0], jellyfindb, kodidb, self.args[1]).remove

                try:
                    obj(item['Id'])
                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:removed/%s ]", id(self))
        self.is_done = True
示例#4
0
    def run(self):
        with self.lock, self.database as kodidb, Database(
                'jellyfin') as jellyfindb:
            while True:

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

                if item['Type'] == 'Movie':
                    obj = Movies(self.args[0], jellyfindb, kodidb,
                                 self.args[1]).movie
                elif item['Type'] == 'Boxset':
                    obj = Movies(self.args[0], jellyfindb, kodidb,
                                 self.args[1]).boxset
                elif item['Type'] == 'Series':
                    obj = TVShows(self.args[0], jellyfindb, kodidb,
                                  self.args[1]).tvshow
                elif item['Type'] == 'Season':
                    obj = TVShows(self.args[0], jellyfindb, kodidb,
                                  self.args[1]).season
                elif item['Type'] == 'Episode':
                    obj = TVShows(self.args[0], jellyfindb, kodidb,
                                  self.args[1]).episode
                elif item['Type'] == 'MusicVideo':
                    obj = MusicVideos(self.args[0], jellyfindb, kodidb,
                                      self.args[1]).musicvideo
                elif item['Type'] == 'MusicAlbum':
                    obj = Music(self.args[0], jellyfindb, kodidb,
                                self.args[1]).album
                elif item['Type'] == 'MusicArtist':
                    obj = Music(self.args[0], jellyfindb, kodidb,
                                self.args[1]).artist
                elif item['Type'] == 'AlbumArtist':
                    obj = Music(self.args[0], jellyfindb, kodidb,
                                self.args[1]).albumartist
                elif item['Type'] == 'Audio':
                    obj = Music(self.args[0], jellyfindb, kodidb,
                                self.args[1]).song

                try:
                    if obj(item) and 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
示例#5
0
    def musicvideos(self, library, dialog):
        ''' Process musicvideos from a single library.
        '''
        processed_ids = []

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

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

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

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

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

        with self.video_database_locks() as (videodb, jellyfindb):
            obj = MusicVideos(self.server, jellyfindb, videodb,
                              self.direct_path)
            obj.item_ids = processed_ids
            if self.update_library:
                self.musicvideos_compare(library, obj, jellyfindb)
示例#6
0
    def run(self):
        with self.lock, self.database as kodidb, Database(
                'jellyfin') as jellyfindb:
            while True:

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

                default_args = (self.server, jellyfindb, kodidb,
                                self.direct_path)
                try:
                    LOG.debug('{} - {}'.format(item['Type'], item['Name']))
                    if item['Type'] == 'Movie':
                        Movies(*default_args).movie(item)
                    elif item['Type'] == 'BoxSet':
                        Movies(*default_args).boxset(item)
                    elif item['Type'] == 'Series':
                        TVShows(*default_args).tvshow(item)
                    elif item['Type'] == 'Season':
                        TVShows(*default_args).season(item)
                    elif item['Type'] == 'Episode':
                        TVShows(*default_args).episode(item)
                    elif item['Type'] == 'MusicVideo':
                        MusicVideos(*default_args).musicvideo(item)
                    elif item['Type'] == 'MusicAlbum':
                        Music(*default_args).album(item)
                    elif item['Type'] == 'MusicArtist':
                        Music(*default_args).artist(item)
                    elif item['Type'] == 'AlbumArtist':
                        Music(*default_args).albumartist(item)
                    elif item['Type'] == 'Audio':
                        Music(*default_args).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
示例#7
0
    def musicvideos(self, library, dialog):

        ''' Process musicvideos from a single library.
        '''
        with self.library.database_lock:
            with Database() as videodb:
                with Database('emby') as embydb:
                    obj = MusicVideos(self.server, embydb, videodb, self.direct_path)

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

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

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

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

                    if self.update_library:
                        self.musicvideos_compare(library, obj, embydb)
示例#8
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

                if item['Type'] == 'Movie':
                    obj = movies.remove
                elif item['Type'] in ['Series', 'Season', 'Episode']:
                    obj = tvshows.remove
                elif item['Type'] in [
                        'MusicAlbum', 'MusicArtist', 'AlbumArtist', 'Audio'
                ]:
                    obj = music.remove
                elif item['Type'] == 'MusicVideo':
                    obj = musicvideos.remove

                try:
                    obj(item['Id'])
                except LibraryException as error:
                    if error.status == 'StopCalled':
                        break
                except Exception as error:
                    LOG.exception(error)
                finally:
                    self.queue.task_done()

                if window('jellyfin_should_stop.bool'):
                    break

        LOG.info("--<[ q:removed/%s ]", id(self))
        self.is_done = True
示例#9
0
    def remove_library(self, library_id, dialog):
        ''' Remove library by their id from the Kodi database.
        '''
        direct_path = self.library.direct_path

        with Database('jellyfin') as jellyfindb:

            db = jellyfin_db.JellyfinDatabase(jellyfindb.cursor)
            library = db.get_view(library_id.replace('Mixed:', ""))
            items = db.get_item_by_media_folder(
                library_id.replace('Mixed:', ""))
            media = 'music' if library[1] == 'music' else 'video'

            if media == 'music':
                settings('MusicRescan.bool', False)

            if items:
                count = 0

                with self.library.music_database_lock if media == 'music' else self.library.database_lock:
                    with Database(media) as kodidb:

                        if library[1] == 'mixed':

                            movies = [x for x in items if x[1] == 'Movie']
                            tvshows = [x for x in items if x[1] == 'Series']

                            obj = Movies(self.server, jellyfindb, kodidb,
                                         direct_path).remove

                            for item in movies:

                                obj(item[0])
                                dialog.update(
                                    int((float(count) / float(len(items)) *
                                         100)),
                                    heading="%s: %s" %
                                    (translate('addon_name'), library[0]))
                                count += 1

                            obj = TVShows(self.server, jellyfindb, kodidb,
                                          direct_path).remove

                            for item in tvshows:

                                obj(item[0])
                                dialog.update(
                                    int((float(count) / float(len(items)) *
                                         100)),
                                    heading="%s: %s" %
                                    (translate('addon_name'), library[0]))
                                count += 1
                        else:
                            default_args = (self.server, jellyfindb, kodidb,
                                            direct_path)
                            for item in items:
                                if item[1] in ('Series', 'Season', 'Episode'):
                                    TVShows(*default_args).remove(item[0])
                                elif item[1] in ('Movie', 'BoxSet'):
                                    Movies(*default_args).remove(item[0])
                                elif item[1] in ('MusicAlbum', 'MusicArtist',
                                                 'AlbumArtist', 'Audio'):
                                    Music(*default_args).remove(item[0])
                                elif item[1] == 'MusicVideo':
                                    MusicVideos(*default_args).remove(item[0])

                                dialog.update(
                                    int((float(count) / float(len(items)) *
                                         100)),
                                    heading="%s: %s" %
                                    (translate('addon_name'), library[0]))
                                count += 1

        self.sync = get_sync()

        if library_id in self.sync['Whitelist']:
            self.sync['Whitelist'].remove(library_id)

        elif 'Mixed:%s' % library_id in self.sync['Whitelist']:
            self.sync['Whitelist'].remove('Mixed:%s' % library_id)

        save_sync(self.sync)
示例#10
0
 def musicvideos(self, embycursor, kodicursor, pdialog):
     return MusicVideos(embycursor, kodicursor, pdialog).compare_all()
示例#11
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