Esempio n. 1
0
File: ga.py Progetto: roeiba/xbmc
def get_ga():
    from pyga.requests import Tracker, Session, Config
    with plugin.get_storage("analytics") as ga:
        config = Config()
        tracker = Tracker(TRACKING_ID, 'steeve.io', conf=config)
        session = ga.setdefault("session", Session())
        if not ga.get("visitor"):
            ga["visitor"] = make_visitor()
        return tracker, session, ga["visitor"]
Esempio n. 2
0
def get_ga():
    from pyga.requests import Tracker, Session, Config
    with plugin.get_storage("analytics") as ga:
        config = Config()
        tracker = Tracker(TRACKING_ID, 'steeve.io', conf=config)
        session = ga.setdefault("session", Session())
        if not ga.get("visitor"):
            ga["visitor"] = make_visitor()
        return tracker, session, ga["visitor"]
Esempio n. 3
0
def get_ga():
    from pyga.requests import Tracker, Session, Config

    ga = plugin.get_storage("analytics")
    config = Config()
    config.anonimize_ip_address = True
    tracker = Tracker(TRACKING_ID, 'steeve.io', conf=config)
    session = ga.setdefault("session", Session())
    visitor = ensure_screen_res(ga.setdefault("visitor", make_visitor()))
    return tracker, session, visitor
Esempio n. 4
0
def get_ga():
    from pyga.requests import Tracker, Session, Config

    ga = plugin.get_storage("analytics")
    config = Config()
    config.anonimize_ip_address = True
    tracker = Tracker(TRACKING_ID, 'steeve.io', conf=config)
    session = ga.setdefault("session", Session())
    visitor = ensure_screen_res(ga.setdefault("visitor", make_visitor()))
    return tracker, session, visitor
Esempio n. 5
0
def eztv_shows_by_letter(letter):
    import re
    import xbmc
    import xbmcgui
    from bs4 import BeautifulSoup
    from contextlib import nested, closing
    from itertools import izip, groupby
    from multiprocessing.pool import ThreadPool
    from xbmctorrent.scrapers import ungenerate
    from xbmctorrent.utils import terminating, url_get
    from xbmctorrent import tvdb

    plugin.set_content("tvshows")
    shows_cache = plugin.get_storage("eztv_shows") # 1 day cache
    if not len(shows_cache.keys()):
        response = url_get("http://eztv.it/showlist/", headers=HEADERS)
        soup = BeautifulSoup(response, "html5lib")
        nodes = soup.findAll("a", "thread_link")
        for node in nodes:
            show_id, show_named_id = node["href"].split("/")[2:4]
            show_name = node.text
            show_first_letter = show_name[0].lower()
            if re.match("\d+", show_first_letter):
                show_first_letter = "0-9"
            shows_cache.setdefault(show_first_letter, {}).update({
                show_id: {
                    "id": show_id,
                    "named_id": show_named_id,
                    "name": node.text,
                }
            })

    shows_list = sorted(shows_cache[letter.lower()].values(), key=lambda x: x["name"].lower())

    @plugin.cached()
    @ungenerate
    def _eztv_shows_by_letter(letter):
        with closing(xbmcgui.DialogProgress()) as dialog:
            dialog.create(plugin.name)
            dialog.update(percent=0, line1="Fetching serie information...", line2="", line3="")

            state = {"done": 0}
            def on_serie(data):
                state["done"] += 1
                dialog.update(
                    percent=int(state["done"] * 100.0 / len(shows_list)),
                    line2=data and data["seriesname"] or "",
                )

            with terminating(ThreadPool(5)) as pool_tvdb:
                tvdb_list = [pool_tvdb.apply_async(tvdb.search, [show["name"], True], callback=on_serie) for show in shows_list]
                while not all(job.ready() for job in tvdb_list):
                    if dialog.iscanceled():
                        dialog.close()
                        return
                    xbmc.sleep(50)

        tvdb_list = [job.get() for job in tvdb_list]
        for i, (eztv_show, tvdb_show) in enumerate(izip(shows_list, tvdb_list)):
            if tvdb_show:
                item = tvdb.get_list_item(tvdb_show)
                item.update({
                    "path": plugin.url_for("eztv_get_show_seasons", show_id=eztv_show["id"], tvdb_id=tvdb_show["id"])
                })
                yield item
            else:
                yield {
                    "label": eztv_show["name"],
                    "path": plugin.url_for("eztv_get_show_seasons", show_id=eztv_show["id"])
                }
    return _eztv_shows_by_letter(letter)