当前位置: 首页>>代码示例>>Python>>正文


Python plugin.get_setting函数代码示例

本文整理汇总了Python中xbmctorrent.plugin.get_setting函数的典型用法代码示例。如果您正苦于以下问题:Python get_setting函数的具体用法?Python get_setting怎么用?Python get_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_setting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

 def init(self, magnet_uri):
     self.magnet_uri = magnet_uri
     self.magnet_args = urlparse.parse_qs(self.magnet_uri.replace("magnet:?", "")) # I know about urlparse.urlsplit but this is faster
     self.magnet_display_name = ""
     if self.magnet_args["dn"]:
         self.magnet_display_name = self.magnet_args["dn"][0]
     self.torrent2http_options = {
         "magnet": magnet_uri,
         "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".",
         "dlrate": plugin.get_setting("max_download_rate") or "0",
         "ulrate": plugin.get_setting("max_upload_rate") or "0",
         "encryption": plugin.get_setting("encryption"),
     }
     # Check for Android and FAT32 SD card issues
     if PLATFORM["os"] == "android" and "sdcard" in self.torrent2http_options["dlpath"].lower():
         plugin.notify("Downloading to SD card is not supported (FAT32). Resetting.", delay=15000)
         plugin.set_setting("dlpath", "")
         self.torrent2http_options["dlpath"] = xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or "."
     # Translate smb:// url to UNC path on windows, very hacky
     if PLATFORM["os"] == "windows" and "smb://" in self.torrent2http_options["dlpath"].lower():
         self.torrent2http_options["dlpath"] = self.torrent2http_options["dlpath"].replace("smb:", "").replace("/", "\\")
     if plugin.get_setting("keep_files", bool):
         plugin.log.info("Will keep file after playback.")
         self.torrent2http_options["keep"] = None
     self.on_playback_started = []
     self.on_playback_resumed = []
     self.on_playback_paused = []
     self.on_playback_stopped = []
     return self
开发者ID:samheg,项目名称:xbmctorrent,代码行数:29,代码来源:player.py

示例2: url_get

def url_get(url, params={}, headers={}, post=None):
    from urllib2 import HTTPCookieProcessor, URLError
    from xbmctorrent.utils import url_get as url_get_origin

    _cookiejar = get_cookie_jar()
    cookie_handler = HTTPCookieProcessor(_cookiejar)

    plugin.log.debug("loading uri: %s with cookies %s params %s post %s" % (url, _cookiejar, str(params), str(post)))

    try:
        result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])
    except URLError:
        result = "profile.php?mode=sendpassword"
        pass

    if url.find("dl.php?") >= 0 and result.find("profile.php?mode=sendpassword") >= 0:
        if not plugin.get_setting("rutracker_login") or not plugin.get_setting("rutracker_passw"):
            plugin.notify("Проверьте настройки авторизации.", delay=15000)
            return ""
        if not _rutracker_login(cookie_handler):
            return ""

        _cookiejar.save()
        result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])
        pass

    plugin.log.debug("uri loaded: " + url)
    return result
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:28,代码来源:rutracker.py

示例3: _rutracker_login

def _rutracker_login(_cookiejar):
    from xbmctorrent.utils import url_get as url_get_origin
    import urllib2

    values = {
        "login_username": plugin.get_setting("rutracker_login"),
        "login_password": plugin.get_setting("rutracker_passw"),
        'login': 'Вход'
    }

    plugin.log.debug("Login user")
    HEADERS["Referer"] = LOGIN_URL
    HEADERS["Content-Type"] = "application/x-www-form-urlencoded"

    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)

    html = url_get_origin(LOGIN_URL, post=values, headers=HEADERS, handlers=[cookie_handler])
    if html.find("profile.php?mode=sendpassword") >= 0:
        plugin.notify("Проверьте настройки авторизации.", delay=15000)
    else:
        plugin.log.debug("Login sucessfull")
        return True
    _cookiejar.save()
    HEADERS["Referer"] = BASE_URL  # restore referer
    return False
开发者ID:smoky-jr,项目名称:XBMC.ru-forum-Add-ons,代码行数:25,代码来源:rutracker.py

示例4: rutor_play

def rutor_play(tid, pulsar):
    from contextlib import closing
    from bencode import bdecode
    from urlparse import urljoin
    from xbmctorrent.magnet import generate_magnet
    from xbmctorrent.utils import first, SafeDialogProgress
    from xbmctorrent.acestream import ace_supported

    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1="Получение информации о раздаче...")

        torrent_url = urljoin(BASE_URL, "download/%s" % tid)
        try:
            metadata = bdecode(url_get(torrent_url, headers=HEADERS))
        except Exception:
            import xbmcgui
            plugin.log.error("Unexpected error: %s" % sys.exc_info()[0])
            xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера")
            return

        dialog.update(percent=100, line1="Готово")

        if "files" in metadata["info"]:  # and ace_supported():
            items = []
            for index, info in enumerate(metadata["info"]["files"]):
                name = "/".join(info["path"])
                if not _rutor_valid_file(name):
                    continue

                if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                    path = plugin.url_for("torrent_play", url=torrent_url, index=index, name=name)
                else:
                    path = plugin.url_for("play_file", uri=generate_magnet(metadata, name), index=index)

                items.append({"label": name, "path": path})

            items = sorted(items, key=lambda x: x["label"])
            if len(items) == 1:  # start playback if torrent contains only one file
                plugin.redirect(items[0]["path"])
            else:               # ask to select which file to play
                import xbmcgui
                select_items = [item["label"] for item in items]
                select = xbmcgui.Dialog().select("Выберите файл для проигрывания", select_items)
                if select >= 0:
                    plugin.redirect(items[select]["path"])
        else:
            name = metadata["info"].get("name") or " / ".join(first(metadata["info"]["files"])["path"]) or "rutor.org"
            if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                path = plugin.url_for("torrent_play", url=torrent_url, index=0, name=name)
            else:
                path = plugin.url_for(["play", "play_with_pulsar"][int(pulsar)], uri=generate_magnet(metadata, name))
            plugin.redirect(path)
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:53,代码来源:rutor.py

示例5: rutracker_play

def rutracker_play(tid, pulsar):
    from contextlib import closing
    from bencode import bdecode
    from urlparse import urljoin
    from xbmctorrent.magnet import generate_magnet
    from xbmctorrent.utils import first, SafeDialogProgress
    from xbmctorrent.acestream import ace_supported

    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1="Получение информации о раздаче...")

        try:
            data = url_get(urljoin(BASE_URL, "dl.php?t=%s" % tid))
            metadata = bdecode(data)
        except Exception:
            plugin.log.error("Unexpected error: %s " % format_exc().split('\n')[-2])
            xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера")
            return

        dialog.update(percent=100, line1="Готово")

        if "files" in metadata["info"]:  # and ace_supported():
            items = []
            for index, info in enumerate(metadata["info"]["files"]):
                name = "/".join(info["path"])
                decname = _rutracker_decode_try(name)
                if not _rutracker_valid_file(decname):
                    continue
                name = uenc(decname)

                if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                    path = plugin.url_for("play_torrent_raw", raw=data, index=index, name=name)
                else:
                    path = plugin.url_for("play_file", uri=generate_magnet(metadata, name), index=index)

                items.append({"label": name, "path": path})

            if len(items) == 1:  # start playback if torrent contains only one file
                plugin.redirect(items[0]["path"])
            else:
                select_items = [item["label"] for item in items]
                select = xbmcgui.Dialog().select("Выберите файл для проигрывания", select_items)
                if select >= 0:
                    plugin.redirect(items[select]["path"])
        else:
            name = metadata["info"].get("name") or " / ".join(first(metadata["info"]["files"])["path"]) or "rutracker.org"
            if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                path = plugin.url_for("play_torrent_raw", raw=data, index=0, name=name)
            else:
                path = plugin.url_for(["play", "play_with_pulsar"][int(pulsar)], uri=generate_magnet(metadata, name))
            plugin.redirect(path)
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:52,代码来源:rutracker.py

示例6: torrents3d_play

def torrents3d_play(article):
    import xbmcgui
    from bs4 import BeautifulSoup
    from contextlib import closing
    from urlparse import urljoin
    from xbmctorrent.magnet import generate_magnet
    from xbmctorrent.utils import SafeDialogProgress

    article = int(article)

    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1=u"Получение информации о релизе...", line2="", line3="")

        url = urljoin(BASE_URL, "article/%d" % article)

        try:
            html_data = url_get(url, headers=HEADERS)
            soup = BeautifulSoup(html_data, "html5lib")
            torrent_href = soup.find("a", class_="genmed")

            if not torrent_href:
                dialog.update(percent=50, line2=u"Требуется авторизация. Авторизация...")

                if not plugin.get_setting("t3d_login") and not plugin.get_setting("t3d_passwd"):
                    plugin.notify("Проверьте настройки авторизации.", delay=15000)
                    return

                html_data = _torrents3d_login(url)
                soup = BeautifulSoup(html_data, "html5lib")
                torrent_href = soup.find("a", class_="genmed")

            if not torrent_href:
                xbmcgui.Dialog().ok(plugin.name, "Авторизация неудалась. Проверьте настройки авторизации.")
                return

            dialog.update(percent=100, line2=u"Обработка данных.")

            from bencode import bdecode

            title = "[%s] %s" % _torrents3d_cleantitle(soup.find("a", class_="tt-text").text)
            torrent_data = url_get(torrent_href["href"], headers=HEADERS)
            metadata = bdecode(torrent_data)

            plugin.redirect(plugin.url_for("play", uri=generate_magnet(metadata, uenc(title))))

        except Exception:
            plugin.log.error("Cannot get data from remote server")
            xbmcgui.Dialog().ok(plugin.name, u"Не удалось получить данные от сервера")
            return
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:50,代码来源:t3d.py

示例7: _lostfilm_login

def _lostfilm_login():
    from json import loads

    values = {
        "act": "users",
        "type": "login",
        "mail": plugin.get_setting("lostfilm_login"),
        "pass": plugin.get_setting("lostfilm_passw"),
        "rem": 1,
    }

    jsn = url_get(AJAX_URL, post=values)
    result = loads(jsn)

    return result.get("result", "") == "ok" and result.get("success", False)
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:15,代码来源:lostfilm.py

示例8: url_get

def url_get(url, params={}, headers={}, with_immunicity=True):
    import urllib2
    from contextlib import closing
    from xbmctorrent import plugin
    from xbmctorrent.common import USER_AGENT

    if params:
        import urllib
        url = "%s?%s" % (url, urllib.urlencode(params))

    req = urllib2.Request(url)
    req.add_header("User-Agent", USER_AGENT)
    for k, v in headers.items():
        req.add_header(k, v)

    if with_immunicity and plugin.get_setting("immunicity", bool):
        from xbmctorrent import immunicity
        proxy = immunicity.get_proxy_for(url)
        if proxy:
            from urlparse import urlsplit
            parts = urlsplit(url)
            req.set_proxy(proxy, parts[0])

    try:
        with closing(urllib2.urlopen(req)) as response:
            data = response.read()
            if response.headers.get("Content-Encoding", "") == "gzip":
                import zlib
                return zlib.decompressobj(16 + zlib.MAX_WBITS).decompress(data)
            return data
    except urllib2.HTTPError:
        return None
开发者ID:ravishi,项目名称:xbmctorrent,代码行数:32,代码来源:utils.py

示例9: init

    def init(self, magnet_uri):
        self.magnet_uri = magnet_uri
        self.magnet_args = urlparse.parse_qs(
            self.magnet_uri.replace("magnet:?", "")
        )  # I know about urlparse.urlsplit but this is faster
        self.magnet_display_name = ""
        if self.magnet_args["dn"]:
            self.magnet_display_name = self.magnet_args["dn"][0]
        self.torrent2http_options = {
            "magnet": magnet_uri,
            "dlpath": xbmc.validatePath(xbmc.translatePath(plugin.get_setting("dlpath"))) or ".",
            "dlrate": plugin.get_setting("max_download_rate") or "0",
            "ulrate": plugin.get_setting("max_upload_rate") or "0",
            "encryption": plugin.get_setting("encryption"),
        }

        if "://" in self.torrent2http_options["dlpath"]:
            # Translate smb:// url to UNC path on windows, very hackish
            if PLATFORM["os"] == "windows" and self.torrent2http_options["dlpath"].lower().startswith("smb://"):
                self.torrent2http_options["dlpath"] = (
                    self.torrent2http_options["dlpath"].replace("smb:", "").replace("/", "\\")
                )
            else:
                plugin.notify("Downloading to an unmounted network share is not supported. Resetting.", delay=15000)
                plugin.set_setting("dlpath", "")
                self.torrent2http_options["dlpath"] = "."

        # Check for Android and FAT32 SD card issues
        if PLATFORM["os"] == "android" and self.torrent2http_options["dlpath"] != ".":
            from xbmctorrent.utils import get_path_fs

            fs = get_path_fs(self.torrent2http_options["dlpath"])
            plugin.log.info("Download path filesytem is %s" % fs)
            if fs == "vfat":  # FAT32 is not supported
                plugin.notify("Downloading to FAT32 is not supported. Resetting.", delay=15000)
                plugin.set_setting("dlpath", "")
                self.torrent2http_options["dlpath"] = "."

        if plugin.get_setting("keep_files", bool):
            plugin.log.info("Will keep file after playback.")
            self.torrent2http_options["keep"] = None
        self.on_playback_started = []
        self.on_playback_resumed = []
        self.on_playback_paused = []
        self.on_playback_stopped = []
        return self
开发者ID:kashkai,项目名称:xbmctorrent,代码行数:46,代码来源:player.py

示例10: _filelist_login

def _filelist_login(referer = BASE_URL):
    from bs4 import BeautifulSoup
    from urlparse import urljoin
    
    HEADERS["Referer"] = urljoin(BASE_URL, 'login.php')
    HEADERS["Origin"] = BASE_URL
    HEADERS["Content-Type"] = "application/x-www-form-urlencoded"

    values = {
        "username": plugin.get_setting("filelist_user"),
        "password": plugin.get_setting("filelist_pass"),
        "unlock": 1
    }

    html_data = url_get(urljoin(BASE_URL, "takelogin.php"), post=values, headers=HEADERS)
    #soup = BeautifulSoup(html_data, "html5lib")
    
    
开发者ID:vladady,项目名称:xbmctorrent,代码行数:16,代码来源:filelist.py

示例11: kat_index

def kat_index():
    cats = [
        {"label": "Search", "path": plugin.url_for("kat_search", sort_field="seeders", sort_order="desc")},
        {"label": "Movies", "path": plugin.url_for("kat_movies")},
        {"label": "Series", "path": plugin.url_for("kat_series", sort_field="seeders", sort_order="desc")},
        {"label": "Anime", "path": plugin.url_for("kat_anime")},
    ]
    if plugin.get_setting("porn", bool):
        cats += [{"label": "XXX", "path": plugin.url_for("kat_porn")}]
    return cats
开发者ID:JonathanHuot,项目名称:xbmctorrent,代码行数:10,代码来源:kickass.py

示例12: track_event

def track_event(*args, **kwargs):
    if not plugin.get_setting("ga_disable", bool) or kwargs.pop("force", False):
        try:
            from pyga.requests import Event
            tracker, session, visitor = get_ga()
            plugin.log.info("GA: Tracking event %s" % repr(args))
            tracker.track_event(Event(*args, **kwargs), session, visitor)
        except Exception, e:
            import traceback
            plugin.log.error("GA: Call failed.")
            plugin.log.error(traceback.format_exc())
开发者ID:smoky-jr,项目名称:XBMC.ru-forum-Add-ons,代码行数:11,代码来源:ga.py

示例13: track_page

def track_page(path, force=False):
    if not plugin.get_setting("ga_disable", bool) or force:
        try:
            from pyga.requests import Page
            tracker, session, visitor = get_ga()
            plugin.log.info("GA: Tracking %s" % path)
            tracker.track_pageview(Page(path), session, visitor)
        except Exception, e:
            import traceback
            plugin.log.error("GA: Call failed.")
            plugin.log.error(traceback.format_exc())
开发者ID:smoky-jr,项目名称:XBMC.ru-forum-Add-ons,代码行数:11,代码来源:ga.py

示例14: _torrents3d_login

def _torrents3d_login(referer=BASE_URL):
    from urlparse import urljoin

    HEADERS["Referer"] = referer
    HEADERS["Origin"] = BASE_URL
    HEADERS["Content-Type"] = "application/x-www-form-urlencoded"

    values = {
        "login_username": plugin.get_setting("t3d_login"),
        "login_password": plugin.get_setting("t3d_passw"),
        "autologin": 1,
        "login": "Вход"
    }

    html_data = url_get(urljoin(BASE_URL, "login.php"), post=values, headers=HEADERS)

    HEADERS["Referer"] = BASE_URL
    del HEADERS["Origin"]

    return html_data
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:20,代码来源:t3d.py

示例15: _rutracker_login

def _rutracker_login(cookie_handler):
    from urlparse import urljoin
    from xbmctorrent.utils import url_get as url_get_origin

    values = {
        "login_username": plugin.get_setting("rutracker_login"),
        "login_password": plugin.get_setting("rutracker_passw"),
        "login": "Вход"
    }

    headers = HEADERS.copy()
    headers["Referer"] = urljoin(BASE_URL, "index.php")
    headers["Content-Type"] = "application/x-www-form-urlencoded"

    html = url_get_origin(urljoin(BASE_URL, "login.php"), post=values, headers=headers, handlers=[cookie_handler])
    if html.find("profile.php?mode=sendpassword") >= 0:
        plugin.notify("Проверьте настройки авторизации.", delay=15000)
    else:
        plugin.log.debug("login sucessfull.")
        return True

    return False
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:22,代码来源:rutracker.py


注:本文中的xbmctorrent.plugin.get_setting函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。