Beispiel #1
0
plugin.name = addon.getAddonInfo("name")
user_agent = "Dalvik/2.1.0 (Linux; U; Android 5.1.1; AFTS Build/LVY48F)"
USER_DATA_DIR = xbmc.translatePath(addon.getAddonInfo("profile")).decode(
    "utf-8")  # !!
CACHE_TIME = int(addon.getSetting("cache_time"))
CACHE_FILE = os.path.join(USER_DATA_DIR, "cache")
expire_after = timedelta(hours=CACHE_TIME)

if not os.path.exists(USER_DATA_DIR):
    os.makedirs(USER_DATA_DIR)

s = CachedSession(CACHE_FILE,
                  allowable_methods="GET",
                  expire_after=expire_after,
                  old_data_on_error=True)
s.hooks = {"response": lambda r, *args, **kwargs: r.raise_for_status()}
s.headers.update({"User-Agent": user_agent})

data_url = "http://swiftstreamz.com/SwiftLive/swiftlive.php"
api_url = "http://swiftstreamz.com/SwiftLive/api.php"
list_url = "http://swiftstreamz.com/SwiftLive/api.php?cat_id={0}"
thumb_url = "http://swiftstreamz.com/SwiftLive/images/thumbs/{0}|User-Agent={1}"

USER = "******"
PASS = "******"


def quote(s, safe=""):
    return orig_quote(s.encode("utf-8"), safe.encode("utf-8"))