Exemplo n.º 1
0
def remove_specific_arttypes():
    options = [
        (L(M.MOVIES), lambda: quickjson.get_item_list(mediatypes.MOVIE),
         mediatypes.MOVIE),
        (L(M.SERIES), quickjson.get_tvshows, mediatypes.TVSHOW),
        (L(M.SEASONS), quickjson.get_seasons, mediatypes.SEASON),
        (L(M.MOVIESETS), lambda: quickjson.get_item_list(mediatypes.MOVIESET),
         mediatypes.MOVIESET),
        (L(M.EPISODES), quickjson.get_episodes, mediatypes.EPISODE),
        (L(M.MUSICVIDEOS),
         lambda: quickjson.get_item_list(mediatypes.MUSICVIDEO),
         mediatypes.MUSICVIDEO)
    ]
    if get_kodi_version() >= 18:
        options.extend(
            ((L(M.ARTISTS), lambda: quickjson.get_item_list(mediatypes.ARTIST),
              mediatypes.ARTIST),
             (L(M.ALBUMS), lambda: quickjson.get_item_list(mediatypes.ALBUM),
              mediatypes.ALBUM),
             (L(M.SONGS), lambda: quickjson.get_item_list(mediatypes.SONG),
              mediatypes.SONG)))

    selected = xbmcgui.Dialog().select(L(
        M.REMOVE_SPECIFIC_TYPES), [option[0] + " ..." for option in options])
    if selected < 0 or selected >= len(options):
        return
    busy = pykodi.get_busydialog()
    busy.create()
    allitems = options[selected][1]()
    counter = {}
    types_to_remove = set()
    for arttype, url in chain.from_iterable(
            d.get('art', {}).iteritems() for d in allitems):
        if '.' in arttype: continue
        counter['* all'] = counter.get('* all', 0) + 1
        counter[arttype] = counter.get(arttype, 0) + 1
        if not info.keep_arttype(options[selected][2], arttype, url):
            types_to_remove.add(arttype)
            counter['* nowhitelist'] = counter.get('* nowhitelist', 0) + 1

    arttypes = sorted(counter.keys())
    busy.close()
    ftype = lambda intype: '* ' + ', '.join(sorted(
        types_to_remove)) if intype == '* nowhitelist' else intype
    selectedarttype = xbmcgui.Dialog().select(options[selected][0], [
        "{0}: {1}".format(ftype(arttype), counter[arttype])
        for arttype in arttypes
    ])
    if selectedarttype >= 0 and selectedarttype < len(arttypes):

        def removetypes(mediaitem):
            changedart = cleaner.remove_specific_arttype(
                mediaitem, arttypes[selectedarttype])
            info.remove_local_from_texturecache(
                (mediaitem.art[arttype] for arttype in changedart), True)
            return changedart

        fixcount = runon_medialist(removetypes, L(M.REMOVE_SPECIFIC_TYPES),
                                   allitems, options[selected][0])
        notify_count(L(M.REMOVED_ART_COUNT), fixcount)
Exemplo n.º 2
0
def identify_unmatched(mediatype):
    busy = pykodi.get_busydialog()
    busy.create()
    processed = ProcessedItems()
    ulist = quickjson.get_item_list(mediatype)
    if mediatype == mediatypes.MUSICVIDEO:
        for item in ulist:
            item['label'] = info.build_music_label(item)
    unmatched = [
        item for item in ulist
        if not processed.get_data(item[mediatype +
                                       'id'], mediatype, item['label'])
    ]
    busy.close()
    if unmatched:
        selected = xbmcgui.Dialog().select(L(
            M.UNMATCHED_ITEMS), [item['label'] for item in unmatched])
        if selected < 0:
            return  # Cancelled
        mediaitem = info.MediaItem(unmatched[selected])
        info.add_additional_iteminfo(mediaitem, processed, search)
        processor = ArtworkProcessor()
        if processor.manual_id(mediaitem):
            processor.process_item(mediatype, mediaitem.dbid, 'auto')
    else:
        xbmcgui.Dialog().notification("Artwork Beef", L(M.NO_UNMATCHED_ITEMS),
                                      xbmcgui.NOTIFICATION_INFO)
Exemplo n.º 3
0
def set_autoaddepisodes():
    busy = pykodi.get_busydialog()
    busy.create()
    serieslist = [
        series for series in quickjson.get_tvshows(True)
        if series.get('imdbnumber')
    ]
    busy.close()
    selected = SeriesSelector('DialogSelect.xml',
                              settings.addon_path,
                              serieslist=serieslist,
                              selected=settings.autoadd_episodes).prompt()
    if selected != settings.autoadd_episodes:
        settings.autoadd_episodes = selected
        if xbmcgui.Dialog().yesno(L(M.ADD_MISSING_HEADER),
                                  L(M.ADD_MISSING_MESSAGE)):
            pykodi.execute_builtin(
                'NotifyAll(script.artwork.beef:control, ProcessAfterSettings)')
Exemplo n.º 4
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)