<commit_before>import sys
import xbmc
import xbmcaddon
import xbmcgui

def main():
    if xbmc.getCondVisibility('Container.Content(tvshows)'):
        mediatype = 'tvshow'
    elif xbmc.getCondVisibility('Container.Content(movies)'):
        mediatype = 'movie'
    elif xbmc.getCondVisibility('Container.Content(episodes)'):
        mediatype = 'episode'
    elif xbmc.getCondVisibility('Container.Content(musicvideos)'):
        mediatype = 'musicvideo'
    else:
        mediatype = xbmc.getInfoLabel('Container.Content')
        if not mediatype:
            if xbmc.getCondVisibility('Container.Content(files)'):
                mediatype = 'files'
            elif xbmc.getCondVisibility('Container.Content(seasons)'):
                mediatype = 'seasons'
            elif xbmc.getCondVisibility('Container.Content(addons)'):
                mediatype = 'addons'
        log("Content type '%s' not supported, not looking up '%s'." % (mediatype, sys.listitem.getLabel()))
        return

    infolabel = xbmc.getInfoLabel('ListItem.Label')
    truelabel = sys.listitem.getLabel()
    mismatch = infolabel != truelabel
    if mismatch:
        log("InfoLabel does not match selected item: InfoLabel('ListItem.Label'): '%s', sys.listitem '%s'" % (infolabel, truelabel), xbmc.LOGWARNING)
        dbid = get_realdbid(sys.listitem)
    else:
        dbid = xbmc.getInfoLabel('ListItem.DBID')

    artworkaddon = xbmcaddon.Addon().getSetting('artwork_addon')
    if not xbmc.getCondVisibility('System.HasAddon({0})'.format(artworkaddon)):
        xbmcgui.Dialog().ok('Select Artwork to Download', "The add-on {0} is not installed. Please install it or configure this context item to use another add-on.".format(artworkaddon))
        return
    xbmc.executebuiltin('RunScript({0}, mode=gui, mediatype={1}, dbid={2})'.format(artworkaddon, mediatype, dbid))

    if mismatch:
        xbmc.sleep(1000)
        xbmc.executebuiltin('Notification(Corrected InfoLabel mismatch, "Real: %s, InfoLabel: %s", 6000, DefaultIconInfo.png)' % (truelabel, infolabel))

def get_realdbid(listitem):
    return listitem.getfilename().split('?')[0].rstrip('/').split('/')[-1]

def log(message, level=xbmc.LOGNOTICE):
    xbmc.log('[context.artwork.downloader.gui] %s' % message, level)

if __name__ == '__main__':
    main()
<commit_msg>Show a notification for the first rare InfoLabel mismatch<commit_after>import sys
import xbmc
import xbmcaddon
import xbmcgui

def main():
    if xbmc.getCondVisibility('Container.Content(tvshows)'):
        mediatype = 'tvshow'
    elif xbmc.getCondVisibility('Container.Content(movies)'):
        mediatype = 'movie'
    elif xbmc.getCondVisibility('Container.Content(episodes)'):
        mediatype = 'episode'
    elif xbmc.getCondVisibility('Container.Content(musicvideos)'):
        mediatype = 'musicvideo'
    else:
        xbmc.executebuiltin('Notification(Select Artwork to Download cannot proceed, "Got an unexpected content type. Try again, it will probably work.", 6000, DefaultIconWarning.png)')
        return

    infolabel = xbmc.getInfoLabel('ListItem.Label')
    truelabel = sys.listitem.getLabel()
    mismatch = infolabel != truelabel
    if mismatch:
        log("InfoLabel does not match selected item: InfoLabel('ListItem.Label'): '%s', sys.listitem '%s'" % (infolabel, truelabel), xbmc.LOGWARNING)
        dbid = get_realdbid(sys.listitem)
    else:
        dbid = xbmc.getInfoLabel('ListItem.DBID')

    artworkaddon = xbmcaddon.Addon().getSetting('artwork_addon')
    if not xbmc.getCondVisibility('System.HasAddon({0})'.format(artworkaddon)):
        xbmcgui.Dialog().ok('Select Artwork to Download', "The add-on {0} is not installed. Please install it or configure this context item to use another add-on.".format(artworkaddon))
        return
    xbmc.executebuiltin('RunScript({0}, mode=gui, mediatype={1}, dbid={2})'.format(artworkaddon, mediatype, dbid))

    if mismatch:
        xbmc.sleep(1000)
        xbmc.executebuiltin('Notification(Corrected InfoLabel mismatch, "Real: %s, InfoLabel: %s", 6000, DefaultIconInfo.png)' % (truelabel, infolabel))

def get_realdbid(listitem):
    return listitem.getfilename().split('?')[0].rstrip('/').split('/')[-1]

def log(message, level=xbmc.LOGNOTICE):
    xbmc.log('[context.artwork.downloader.gui] %s' % message, level)

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.13596692696371154, 'fraction_numerical': 0.0078089113458888375, 'mean_word_length': 3.8713646532438477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '554794', 'n_tokens_mistral': 1470, 'n_tokens_neox': 1410, 'n_words': 292}