# Path: resources/lib/modules/control.py
# SORT_METHOD_NONE = xbmcplugin.SORT_METHOD_NONE
# SORT_METHOD_UNSORTED = xbmcplugin.SORT_METHOD_UNSORTED
# SORT_METHOD_VIDEO_RATING = xbmcplugin.SORT_METHOD_VIDEO_RATING
# SORT_METHOD_TRACKNUM = xbmcplugin.SORT_METHOD_TRACKNUM
# SORT_METHOD_FILE = xbmcplugin.SORT_METHOD_FILE
# SORT_METHOD_TITLE = xbmcplugin.SORT_METHOD_TITLE
# SORT_METHOD_TITLE_IGNORE_THE = xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE
# SORT_METHOD_VIDEO_TITLE = xbmcplugin.SORT_METHOD_VIDEO_TITLE
# SORT_METHOD_VIDEO_SORT_TITLE = xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE
# SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE = xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE
# SORT_METHOD_VIDEO_RUNTIME = xbmcplugin.SORT_METHOD_VIDEO_RUNTIME
# SORT_METHOD_FULLPATH = xbmcplugin.SORT_METHOD_FULLPATH
# SORT_METHOD_LABEL = xbmcplugin.SORT_METHOD_LABEL
# SORT_METHOD_LABEL_IGNORE_THE = xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE
# SORT_METHOD_LABEL_IGNORE_FOLDERS = xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS
# SORT_METHOD_CHANNEL = xbmcplugin.SORT_METHOD_CHANNEL
# SORT_METHOD_DATE = xbmcplugin.SORT_METHOD_DATE
# SORT_METHOD_DATEADDED = xbmcplugin.SORT_METHOD_DATEADDED
# SORT_METHOD_PLAYLIST_ORDER = xbmcplugin.SORT_METHOD_PLAYLIST_ORDER
# SORT_METHOD_EPISODE = xbmcplugin.SORT_METHOD_EPISODE
# SORT_METHOD_STUDIO = xbmcplugin.SORT_METHOD_STUDIO
# SORT_METHOD_STUDIO_IGNORE_THE = xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE
# SORT_METHOD_MPAA_RATING = xbmcplugin.SORT_METHOD_MPAA_RATING
# LOGDEBUG = 0
# LOGERROR = 4
# LOGFATAL = 6
# LOGINFO = 1
# LOGNONE = 7
# LOGNOTICE = 2
# LOGSEVERE = 5
# LOGWARNING = 3
# INFO_LABELS = [
#     'genre',
#     'country',
#     'year',
#     'episode',
#     'season',
#     'sortepisode',
#     'sortseason',
#     'episodeguide',
#     'showlink',
#     'top250',
#     'setid',
#     'tracknumber',
#     'rating',
#     'userrating',
#     'watched',
#     'playcount',
#     'overlay',
#     'cast',
#     'castandrole',
#     'director',
#     'mpaa',
#     'plot',
#     'plotoutline',
#     'title',
#     'originaltitle',
#     'sorttitle',
#     'duration',
#     'studio',
#     'tagline',
#     'writer',
#     'tvshowtitle',
#     'premiered',
#     'status',
#     'set',
#     'setoverview',
#     'tag',
#     'imdbnumber',
#     'code',
#     'aired',
#     'credits',
#     'lastplayed',
#     'album',
#     'artist',
#     'votes',
#     'path',
#     'trailer',
#     'dateadded',
#     'mediatype',
#     'dbid'
# ]
# def get_current_brasilia_utc_offset():
# def get_inputstream_addon():
# def is_inputstream_available():
# def is_live_available():
# def is_vod_available():
# def is_globosat_available():
# def is_globoplay_available():
# def is_globoplay_mais_canais_ao_vivo_available():
# def globoplay_ignore_channel_authorization():
# def is_oiplay_available():
# def is_tntplay_available():
# def is_nowonline_available():
# def is_telecine_available():
# def is_sbt_available():
# def is_pluto_available():
# def getKodiVersion():
# def addonIcon():
# def getBandwidthLimit():
# def addonThumb():
# def addonPoster():
# def addonBanner():
# def addonFanart():
# def addonNext():
# def artPath():
# def okDialog(heading, line1, line2=None, line3=None):
# def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
# def yesnoDialog(line1, line2, line3, heading=addonInfo('name'), nolabel='', yeslabel=''):
# def selectDialog(list, heading=addonInfo('name')):
# def apiLanguage(ret_name=None):
# def version():
# def openSettings(query=None, id=addonInfo('id')):
# def refresh():
# def idle():
# def queueItem():
# def clear_credentials():
# def clear_globosat_credentials():
# def log(msg, level=LOGNOTICE):
# def get_coordinates(affiliate):
# def get_ip_coordinates():
# def get_affiliates_by_id(id):
# def filter_info_labels(info_labels):
# def to_timestamp(date):
# def run_plugin_url(params=None):
# def get_weekday_name(date):


import re
import hashlib
import time
import datetime
import traceback
import inspect
    import cPickle as pickle
    import pickle
    from sqlite3 import dbapi2 as database
    from pysqlite2 import dbapi2 as database
from resources.lib.modules import control
    from collections import OrderedDict
    kargs.pop('lock_obj', None)

    f = repr(function)
    f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)

    a = hashlib.md5()
    for i in args: a.update(str(i))
    for key in kargs:
        if key != 'table':
            a.update('%s=%s' % (key, str(kargs[key])))
    a = str(a.hexdigest())
    # except:
    #     pass

    try:
        table = kargs['table']
        kargs.pop('table')
    except:
        table = 'rel_list'

    try:
        control.makeFile(control.dataPath)
        dbcon = database.connect(control.cacheFile)
        dbcur = dbcon.cursor()

        if not force_refresh:
            response, found = __get_from_cache(dbcur, table, f, a, timeout_hour)
            if found:
                return response
        else:

# Path: resources/lib/modules/control.py
# SORT_METHOD_NONE = xbmcplugin.SORT_METHOD_NONE
# SORT_METHOD_UNSORTED = xbmcplugin.SORT_METHOD_UNSORTED
# SORT_METHOD_VIDEO_RATING = xbmcplugin.SORT_METHOD_VIDEO_RATING
# SORT_METHOD_TRACKNUM = xbmcplugin.SORT_METHOD_TRACKNUM
# SORT_METHOD_FILE = xbmcplugin.SORT_METHOD_FILE
# SORT_METHOD_TITLE = xbmcplugin.SORT_METHOD_TITLE
# SORT_METHOD_TITLE_IGNORE_THE = xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE
# SORT_METHOD_VIDEO_TITLE = xbmcplugin.SORT_METHOD_VIDEO_TITLE
# SORT_METHOD_VIDEO_SORT_TITLE = xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE
# SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE = xbmcplugin.SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE
# SORT_METHOD_VIDEO_RUNTIME = xbmcplugin.SORT_METHOD_VIDEO_RUNTIME
# SORT_METHOD_FULLPATH = xbmcplugin.SORT_METHOD_FULLPATH
# SORT_METHOD_LABEL = xbmcplugin.SORT_METHOD_LABEL
# SORT_METHOD_LABEL_IGNORE_THE = xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE
# SORT_METHOD_LABEL_IGNORE_FOLDERS = xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS
# SORT_METHOD_CHANNEL = xbmcplugin.SORT_METHOD_CHANNEL
# SORT_METHOD_DATE = xbmcplugin.SORT_METHOD_DATE
# SORT_METHOD_DATEADDED = xbmcplugin.SORT_METHOD_DATEADDED
# SORT_METHOD_PLAYLIST_ORDER = xbmcplugin.SORT_METHOD_PLAYLIST_ORDER
# SORT_METHOD_EPISODE = xbmcplugin.SORT_METHOD_EPISODE
# SORT_METHOD_STUDIO = xbmcplugin.SORT_METHOD_STUDIO
# SORT_METHOD_STUDIO_IGNORE_THE = xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE
# SORT_METHOD_MPAA_RATING = xbmcplugin.SORT_METHOD_MPAA_RATING
# LOGDEBUG = 0
# LOGERROR = 4
# LOGFATAL = 6
# LOGINFO = 1
# LOGNONE = 7
# LOGNOTICE = 2
# LOGSEVERE = 5
# LOGWARNING = 3
# INFO_LABELS = [
#     'genre',
#     'country',
#     'year',
#     'episode',
#     'season',
#     'sortepisode',
#     'sortseason',
#     'episodeguide',
#     'showlink',
#     'top250',
#     'setid',
#     'tracknumber',
#     'rating',
#     'userrating',
#     'watched',
#     'playcount',
#     'overlay',
#     'cast',
#     'castandrole',
#     'director',
#     'mpaa',
#     'plot',
#     'plotoutline',
#     'title',
#     'originaltitle',
#     'sorttitle',
#     'duration',
#     'studio',
#     'tagline',
#     'writer',
#     'tvshowtitle',
#     'premiered',
#     'status',
#     'set',
#     'setoverview',
#     'tag',
#     'imdbnumber',
#     'code',
#     'aired',
#     'credits',
#     'lastplayed',
#     'album',
#     'artist',
#     'votes',
#     'path',
#     'trailer',
#     'dateadded',
#     'mediatype',
#     'dbid'
# ]
# def get_current_brasilia_utc_offset():
# def get_inputstream_addon():
# def is_inputstream_available():
# def is_live_available():
# def is_vod_available():
# def is_globosat_available():
# def is_globoplay_available():
# def is_globoplay_mais_canais_ao_vivo_available():
# def globoplay_ignore_channel_authorization():
# def is_oiplay_available():
# def is_tntplay_available():
# def is_nowonline_available():
# def is_telecine_available():
# def is_sbt_available():
# def is_pluto_available():
# def getKodiVersion():
# def addonIcon():
# def getBandwidthLimit():
# def addonThumb():
# def addonPoster():
# def addonBanner():
# def addonFanart():
# def addonNext():
# def artPath():
# def okDialog(heading, line1, line2=None, line3=None):
# def infoDialog(message, heading=addonInfo('name'), icon='', time=3000, sound=False):
# def yesnoDialog(line1, line2, line3, heading=addonInfo('name'), nolabel='', yeslabel=''):
# def selectDialog(list, heading=addonInfo('name')):
# def apiLanguage(ret_name=None):
# def version():
# def openSettings(query=None, id=addonInfo('id')):
# def refresh():
# def idle():
# def queueItem():
# def clear_credentials():
# def clear_globosat_credentials():
# def log(msg, level=LOGNOTICE):
# def get_coordinates(affiliate):
# def get_ip_coordinates():
# def get_affiliates_by_id(id):
# def filter_info_labels(info_labels):
# def to_timestamp(date):
# def run_plugin_url(params=None):
# def get_weekday_name(date):


# Path: resources/lib/modules/cache.py
import re
import hashlib
import time
import datetime
import traceback
import inspect
    import cPickle as pickle
    import pickle
    from sqlite3 import dbapi2 as database
    from pysqlite2 import dbapi2 as database
from resources.lib.modules import control
    from collections import OrderedDict

    kargs.pop('lock_obj', None)

    f = repr(function)
    f = re.sub('.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)

    a = hashlib.md5()
    for i in args: a.update(str(i))
    for key in kargs:
        if key != 'table':
            a.update('%s=%s' % (key, str(kargs[key])))
    a = str(a.hexdigest())
    # except:
    #     pass

    try:
        table = kargs['table']
        kargs.pop('table')
    except:
        table = 'rel_list'

    try:
        control.makeFile(control.dataPath)
        dbcon = database.connect(control.cacheFile)
        dbcur = dbcon.cursor()

        if not force_refresh:
            response, found = __get_from_cache(dbcur, table, f, a, timeout_hour)
            if found:
                return response
        else:

            control.log('BYPASSING CACHE')