# Path: lib/libs/mediatypes.py
# TVSHOW = 'tvshow'
# MOVIE = 'movie'
# EPISODE = 'episode'
# SEASON = 'season'
# MOVIESET = 'set'
# MUSICVIDEO = 'musicvideo'
# ARTIST = 'artist'
# ALBUM = 'album'
# SONG = 'song'
# PREFERRED_SOURCE_SHARED = {'0': None, '1': 'fanart.tv'}
# PREFERRED_SOURCE_MEDIA = {'tvshows': ('thetvdb.com', (TVSHOW, SEASON, EPISODE)),
#     'movies': ('themoviedb.org', (MOVIE, MOVIESET)),
#     'music': ('theaudiodb.com', audiotypes),
#     'musicvideos': ('theaudiodb.com', (MUSICVIDEO,))}
# def get_artinfo(mediatype, arttype):
# def hack_mediaarttype(mediatype, arttype):
# def disabled(mediatype):
# def iter_every_arttype(mediatype):
# def downloadartwork(mediatype, arttype):
# def downloadanyartwork(mediatype):
# def _split_arttype(arttype):
# def generatethumb(mediatype):
# def haspreferred_source(mediatype):
# def ispreferred_source(mediatype, provider):
# def only_filesystem(mediatype):
# def update_settings():
# def _get_autolimit_from_setting(settingid):
# def _set_allmulti(always_multi):
# 
# Path: lib/libs/pykodi.py
# ADDONID = 'script.artwork.beef'
# def get_main_addon():
# def is_addon_watched():
# def get_kodi_version():
# def localize(messageid):
# def get_conditional(conditional):
# def get_infolabel(infolabel):
# def execute_builtin(builtin_command):
# def datetime_now():
# def datetime_strptime(date_string, format_string):
# def execute_jsonrpc(jsonrpc_command):
# def log(message, level=xbmc.LOGDEBUG, tag=None):
# def scrub_message(message):
# def set_log_scrubstring(key, string):
# def get_language(language_format=xbmc.ENGLISH_NAME, region=False):
# def unquoteimage(imagestring):
# def quoteimage(imagestring):
# def unquotearchive(filepath):
# def get_command(*first_arg_keys):
# def get_busydialog():
#     def __init__(self, *args, **kwargs):
#     def get_setting(self, settingid):
#     def set_setting(self, settingid, value):
#     def __init__(self, *args, **kwargs):
#     def default(self, obj):
#     def __init__(self, *args, **kwargs):
#     def iterencode(self, obj, _one_shot=False):
#     def raw_decode(self, s, idx=0):
#     def _json_unicode_to_str(self, jsoninput):
#     def __init__(self):
#     def create(self):
#     def close(self):
#     def __del__(self):
# class Addon(xbmcaddon.Addon):
# class ObjectJSONEncoder(json.JSONEncoder):
# class UTF8PrettyJSONEncoder(ObjectJSONEncoder):
# class UTF8JSONDecoder(json.JSONDecoder):
# class DialogBusy(object):
# 
# Path: lib/libs/pykodi.py
# ADDONID = 'script.artwork.beef'
# def get_main_addon():
# def is_addon_watched():
# def get_kodi_version():
# def localize(messageid):
# def get_conditional(conditional):
# def get_infolabel(infolabel):
# def execute_builtin(builtin_command):
# def datetime_now():
# def datetime_strptime(date_string, format_string):
# def execute_jsonrpc(jsonrpc_command):
# def log(message, level=xbmc.LOGDEBUG, tag=None):
# def scrub_message(message):
# def set_log_scrubstring(key, string):
# def get_language(language_format=xbmc.ENGLISH_NAME, region=False):
# def unquoteimage(imagestring):
# def quoteimage(imagestring):
# def unquotearchive(filepath):
# def get_command(*first_arg_keys):
# def get_busydialog():
#     def __init__(self, *args, **kwargs):
#     def get_setting(self, settingid):
#     def set_setting(self, settingid, value):
#     def __init__(self, *args, **kwargs):
#     def default(self, obj):
#     def __init__(self, *args, **kwargs):
#     def iterencode(self, obj, _one_shot=False):
#     def raw_decode(self, s, idx=0):
#     def _json_unicode_to_str(self, jsoninput):
#     def __init__(self):
#     def create(self):
#     def close(self):
#     def __del__(self):
# class Addon(xbmcaddon.Addon):
# class ObjectJSONEncoder(json.JSONEncoder):
# class UTF8PrettyJSONEncoder(ObjectJSONEncoder):
# class UTF8JSONDecoder(json.JSONDecoder):
# class DialogBusy(object):


from itertools import chain
from lib.libs import mediatypes, pykodi
from lib.libs.pykodi import get_kodi_version, json, log
    assert mediatype in typemap

    mapped = typemap[mediatype]
    basestr = 'VideoLibrary.Set{0}Details' if mediatype not in mediatypes.audiotypes else 'AudioLibrary.Set{0}Details'
    json_request = get_base_json_request(basestr.format(mapped[0]))
    json_request['params'] = details
    json_request['params'][mediatype + 'id'] = dbid

    json_result = pykodi.execute_jsonrpc(json_request)
    if not check_json_result(json_result, 'OK', json_request):
        log(json_result)

def get_textures(url=None):
    json_request = get_base_json_request('Textures.GetTextures')
    json_request['params']['properties'] = ['url']
    if url is not None:
        json_request['params']['filter'] = {'field': 'url', 'operator': 'is', 'value': url}

    json_result = pykodi.execute_jsonrpc(json_request)
    if check_json_result(json_result, 'textures', json_request):
        return json_result['result']['textures']
    else:
        return []

def remove_texture(textureid):
    json_request = get_base_json_request('Textures.RemoveTexture')
    json_request['params']['textureid'] = textureid

    json_result = pykodi.execute_jsonrpc(json_request)
    if not check_json_result(json_result, 'OK', json_request):

# Path: lib/libs/mediatypes.py
# TVSHOW = 'tvshow'
# MOVIE = 'movie'
# EPISODE = 'episode'
# SEASON = 'season'
# MOVIESET = 'set'
# MUSICVIDEO = 'musicvideo'
# ARTIST = 'artist'
# ALBUM = 'album'
# SONG = 'song'
# PREFERRED_SOURCE_SHARED = {'0': None, '1': 'fanart.tv'}
# PREFERRED_SOURCE_MEDIA = {'tvshows': ('thetvdb.com', (TVSHOW, SEASON, EPISODE)),
#     'movies': ('themoviedb.org', (MOVIE, MOVIESET)),
#     'music': ('theaudiodb.com', audiotypes),
#     'musicvideos': ('theaudiodb.com', (MUSICVIDEO,))}
# def get_artinfo(mediatype, arttype):
# def hack_mediaarttype(mediatype, arttype):
# def disabled(mediatype):
# def iter_every_arttype(mediatype):
# def downloadartwork(mediatype, arttype):
# def downloadanyartwork(mediatype):
# def _split_arttype(arttype):
# def generatethumb(mediatype):
# def haspreferred_source(mediatype):
# def ispreferred_source(mediatype, provider):
# def only_filesystem(mediatype):
# def update_settings():
# def _get_autolimit_from_setting(settingid):
# def _set_allmulti(always_multi):
# 
# Path: lib/libs/pykodi.py
# ADDONID = 'script.artwork.beef'
# def get_main_addon():
# def is_addon_watched():
# def get_kodi_version():
# def localize(messageid):
# def get_conditional(conditional):
# def get_infolabel(infolabel):
# def execute_builtin(builtin_command):
# def datetime_now():
# def datetime_strptime(date_string, format_string):
# def execute_jsonrpc(jsonrpc_command):
# def log(message, level=xbmc.LOGDEBUG, tag=None):
# def scrub_message(message):
# def set_log_scrubstring(key, string):
# def get_language(language_format=xbmc.ENGLISH_NAME, region=False):
# def unquoteimage(imagestring):
# def quoteimage(imagestring):
# def unquotearchive(filepath):
# def get_command(*first_arg_keys):
# def get_busydialog():
#     def __init__(self, *args, **kwargs):
#     def get_setting(self, settingid):
#     def set_setting(self, settingid, value):
#     def __init__(self, *args, **kwargs):
#     def default(self, obj):
#     def __init__(self, *args, **kwargs):
#     def iterencode(self, obj, _one_shot=False):
#     def raw_decode(self, s, idx=0):
#     def _json_unicode_to_str(self, jsoninput):
#     def __init__(self):
#     def create(self):
#     def close(self):
#     def __del__(self):
# class Addon(xbmcaddon.Addon):
# class ObjectJSONEncoder(json.JSONEncoder):
# class UTF8PrettyJSONEncoder(ObjectJSONEncoder):
# class UTF8JSONDecoder(json.JSONDecoder):
# class DialogBusy(object):
# 
# Path: lib/libs/pykodi.py
# ADDONID = 'script.artwork.beef'
# def get_main_addon():
# def is_addon_watched():
# def get_kodi_version():
# def localize(messageid):
# def get_conditional(conditional):
# def get_infolabel(infolabel):
# def execute_builtin(builtin_command):
# def datetime_now():
# def datetime_strptime(date_string, format_string):
# def execute_jsonrpc(jsonrpc_command):
# def log(message, level=xbmc.LOGDEBUG, tag=None):
# def scrub_message(message):
# def set_log_scrubstring(key, string):
# def get_language(language_format=xbmc.ENGLISH_NAME, region=False):
# def unquoteimage(imagestring):
# def quoteimage(imagestring):
# def unquotearchive(filepath):
# def get_command(*first_arg_keys):
# def get_busydialog():
#     def __init__(self, *args, **kwargs):
#     def get_setting(self, settingid):
#     def set_setting(self, settingid, value):
#     def __init__(self, *args, **kwargs):
#     def default(self, obj):
#     def __init__(self, *args, **kwargs):
#     def iterencode(self, obj, _one_shot=False):
#     def raw_decode(self, s, idx=0):
#     def _json_unicode_to_str(self, jsoninput):
#     def __init__(self):
#     def create(self):
#     def close(self):
#     def __del__(self):
# class Addon(xbmcaddon.Addon):
# class ObjectJSONEncoder(json.JSONEncoder):
# class UTF8PrettyJSONEncoder(ObjectJSONEncoder):
# class UTF8JSONDecoder(json.JSONDecoder):
# class DialogBusy(object):


# Path: lib/libs/quickjson.py
from itertools import chain
from lib.libs import mediatypes, pykodi
from lib.libs.pykodi import get_kodi_version, json, log

    assert mediatype in typemap

    mapped = typemap[mediatype]
    basestr = 'VideoLibrary.Set{0}Details' if mediatype not in mediatypes.audiotypes else 'AudioLibrary.Set{0}Details'
    json_request = get_base_json_request(basestr.format(mapped[0]))
    json_request['params'] = details
    json_request['params'][mediatype + 'id'] = dbid

    json_result = pykodi.execute_jsonrpc(json_request)
    if not check_json_result(json_result, 'OK', json_request):
        log(json_result)

def get_textures(url=None):
    json_request = get_base_json_request('Textures.GetTextures')
    json_request['params']['properties'] = ['url']
    if url is not None:
        json_request['params']['filter'] = {'field': 'url', 'operator': 'is', 'value': url}

    json_result = pykodi.execute_jsonrpc(json_request)
    if check_json_result(json_result, 'textures', json_request):
        return json_result['result']['textures']
    else:
        return []

def remove_texture(textureid):
    json_request = get_base_json_request('Textures.RemoveTexture')
    json_request['params']['textureid'] = textureid

    json_result = pykodi.execute_jsonrpc(json_request)
    if not check_json_result(json_result, 'OK', json_request):

        log(json_result)