示例#1
0
    def process_allmusic(self, shouldinclude_fn=None):
        if mediatypes.disabled(mediatypes.ALBUM) and mediatypes.disabled(mediatypes.ARTIST):
            return True
        if not shouldinclude_fn:
            shouldinclude_fn = lambda id, type, label: True
        albums = []
        if not mediatypes.disabled(mediatypes.ALBUM):
            albums.extend(info.MediaItem(album) for album in quickjson.get_albums()
                if shouldinclude_fn(album['albumid'], mediatypes.ALBUM, info.build_music_label(album)))
        if self.abortRequested():
            return False
        artists = []
        if not mediatypes.disabled(mediatypes.ARTIST):
            artists.extend(info.MediaItem(artist) for artist in quickjson.get_item_list(mediatypes.ARTIST)
                if shouldinclude_fn(artist['artistid'], mediatypes.ARTIST, artist['label']))
        if self.abortRequested():
            return False
        if not albums and not artists:
            return True
        chunkedalbums = [albums[x:x+ALBUM_CHUNK_SIZE] for x in range(0, len(albums), ALBUM_CHUNK_SIZE)]
        def chunk_filler():
            for albumgroup in chunkedalbums:
                songs = _buildsongs(albumgroup)
                if self.abortRequested():
                    yield False
                itemgroup = []
                for album in albumgroup:
                    if not mediatypes.disabled(mediatypes.ARTIST):
                        artist = next((a for a in artists if a.dbid == album.artistid), None)
                        if artist:
                            itemgroup.append(artist)
                            artists.remove(artist)
                    if not mediatypes.disabled(mediatypes.ALBUM):
                        itemgroup.append(album)
                    if not mediatypes.disabled(mediatypes.SONG) and album.dbid in songs:
                        itemgroup.extend(info.MediaItem(song) for song in songs[album.dbid])
                    if self.abortRequested():
                        yield False

                yield itemgroup
            if artists: # New artists that didn't match an album
                yield artists
        return self.processor.process_chunkedlist(chunk_filler(), len(chunkedalbums))
示例#2
0
def get_cached_albums(artistname, dbid):
    return quickjson.get_albums(artistname, dbid)
示例#3
0
    def process_item(self, mediatype, dbid, mode):
        if self.processor_busy:
            return
        if mode == MODE_DEBUG:
            mode = MODE_AUTO
            self.set_debug(True)
        if mode == MODE_GUI:
            busy = pykodi.get_busydialog()
            busy.create()
        if mediatype in mediatypes.artinfo and (mediatype
                                                not in mediatypes.audiotypes
                                                or get_kodi_version() >= 18):
            mediaitem = info.MediaItem(
                quickjson.get_item_details(dbid, mediatype))
            log("Processing {0} '{1}' {2}.".format(
                mediatype, mediaitem.label,
                'automatically' if mode == MODE_AUTO else 'manually'))
        else:
            if mode == MODE_GUI:
                busy.close()
            xbmcgui.Dialog().notification(
                "Artwork Beef",
                L(NOT_SUPPORTED_MESSAGE).format(mediatype), '-', 6500)
            return

        self.init_run()
        if mediatype == mediatypes.EPISODE:
            series = quickjson.get_item_details(mediaitem.tvshowid,
                                                mediatypes.TVSHOW)
            if not any(uniqueid in settings.autoadd_episodes
                       for uniqueid in series['uniqueid'].itervalues()):
                mediaitem.skip_artwork = ['fanart']

        info.add_additional_iteminfo(mediaitem, self.processed, search)
        if not mediaitem.uniqueids and not mediatypes.only_filesystem(
                mediaitem.mediatype):
            if mediatype in mediatypes.require_manualid:
                self.manual_id(mediaitem)
        if mode == MODE_GUI:
            self._manual_item_process(mediaitem, busy)
        else:
            medialist = [mediaitem]
            if mediatype == mediatypes.TVSHOW and not mediatypes.disabled(
                    mediatypes.EPISODE):
                gen_epthumb = mediatypes.generatethumb(mediatypes.EPISODE)
                download_ep = mediatypes.downloadanyartwork(mediatypes.EPISODE)
                if mediaitem.uniqueids and any(
                        x in mediaitem.uniqueids.values()
                        for x in settings.autoadd_episodes):
                    medialist.extend(
                        info.MediaItem(ep)
                        for ep in quickjson.get_episodes(dbid))
                elif gen_epthumb or download_ep:
                    for episode in quickjson.get_episodes(dbid):
                        if gen_epthumb and not info.has_generated_thumbnail(episode) \
                        or download_ep and info.has_art_todownload(episode['art'], mediatypes.EPISODE):
                            episode = info.MediaItem(episode)
                            episode.skip_artwork = ['fanart']
                            medialist.append(episode)
            elif mediatype == mediatypes.ARTIST and not mediatypes.disabled(
                    mediatypes.ALBUM):
                medialist.extend(
                    info.MediaItem(album) for album in quickjson.get_albums(
                        mediaitem.label, mediaitem.dbid))
            if mediatype in (mediatypes.ALBUM, mediatypes.ARTIST) and not mediatypes.disabled(mediatypes.ALBUM) \
            and not mediatypes.disabled(mediatypes.SONG):
                medialist.extend(
                    info.MediaItem(song) for song in quickjson.get_songs(
                        mediaitem.mediatype, mediaitem.dbid))
            self.process_medialist(medialist, True)