# Path: lib/libs/pykodi.py
# def log(message, level=xbmc.LOGDEBUG, tag=None):
#     if is_addon_watched() and level < xbmc.LOGNOTICE:
#         # Messages from this add-on are being watched, elevate to NOTICE so Kodi logs it
#         level_tag = _log_level_tag_lookup[level] + ': ' if level in _log_level_tag_lookup else ''
#         level = xbmc.LOGNOTICE
#     else:
#         level_tag = ''
# 
#     if isinstance(message, (dict, list)) and len(message) > 300:
#         message = str(message)
#     elif isinstance(message, unicode):
#         message = message.encode('utf-8')
#     elif not isinstance(message, str):
#         message = json.dumps(message, cls=UTF8PrettyJSONEncoder)
# 
#     addontag = ADDONID if not tag else ADDONID + ':' + tag
#     file_message = '%s[%s] %s' % (level_tag, addontag, scrub_message(message))
#     xbmc.log(file_message, level)


import re
import xbmc
from collections import namedtuple
from os.path import split, basename, dirname
from lib.libs.pykodi import log
    return string.replace('/', '|').replace('\\', '|')

replace_chars = ':?"/\\<>*|'
replace_with = ('', '_', '+', '-')
replace_colon_with = (' -',)
def iter_possible_cleannames(originalname, uniqueslug=None):
    if uniqueslug:
        firstname = originalname + '_' + uniqueslug
        yield firstname
        filenames = [firstname]
    else:
        yield originalname
        filenames = [originalname]
    cleaned = originalname.rstrip(' .')
    if cleaned != originalname:
        if uniqueslug:
            cleaned += '_' + uniqueslug
        yield cleaned
        filenames.append(cleaned)
    if originalname.endswith((' ', '.')) and not uniqueslug:
        cleaned = originalname[:-1] + '_'
        if cleaned not in filenames:
            yield cleaned
            filenames.append(cleaned)

    for char in replace_chars:
        if char in originalname:
            for filename in list(filenames):
                replacements = replace_with
                if char == ':':

# Path: lib/libs/pykodi.py
# def log(message, level=xbmc.LOGDEBUG, tag=None):
#     if is_addon_watched() and level < xbmc.LOGNOTICE:
#         # Messages from this add-on are being watched, elevate to NOTICE so Kodi logs it
#         level_tag = _log_level_tag_lookup[level] + ': ' if level in _log_level_tag_lookup else ''
#         level = xbmc.LOGNOTICE
#     else:
#         level_tag = ''
# 
#     if isinstance(message, (dict, list)) and len(message) > 300:
#         message = str(message)
#     elif isinstance(message, unicode):
#         message = message.encode('utf-8')
#     elif not isinstance(message, str):
#         message = json.dumps(message, cls=UTF8PrettyJSONEncoder)
# 
#     addontag = ADDONID if not tag else ADDONID + ':' + tag
#     file_message = '%s[%s] %s' % (level_tag, addontag, scrub_message(message))
#     xbmc.log(file_message, level)


# Path: lib/libs/utils.py
import re
import xbmc
from collections import namedtuple
from os.path import split, basename, dirname
from lib.libs.pykodi import log

    return string.replace('/', '|').replace('\\', '|')

replace_chars = ':?"/\\<>*|'
replace_with = ('', '_', '+', '-')
replace_colon_with = (' -',)
def iter_possible_cleannames(originalname, uniqueslug=None):
    if uniqueslug:
        firstname = originalname + '_' + uniqueslug
        yield firstname
        filenames = [firstname]
    else:
        yield originalname
        filenames = [originalname]
    cleaned = originalname.rstrip(' .')
    if cleaned != originalname:
        if uniqueslug:
            cleaned += '_' + uniqueslug
        yield cleaned
        filenames.append(cleaned)
    if originalname.endswith((' ', '.')) and not uniqueslug:
        cleaned = originalname[:-1] + '_'
        if cleaned not in filenames:
            yield cleaned
            filenames.append(cleaned)

    for char in replace_chars:
        if char in originalname:
            for filename in list(filenames):
                replacements = replace_with
                if char == ':':

                    replacements += replace_colon_with