Esempio n. 1
0
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
Esempio n. 2
0
def url_get(url, params={}, headers={}, post=None):
    global _cookiejar

    import re, time, cookielib
    from urlparse import urlparse
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os, urllib2, xbmc, xbmcvfs, Cookie

        sid_file = os.path.join(xbmc.translatePath('special://temp/'),
                                plugin.id, 'rutor.cookies.dat')  #
        if not xbmcvfs.exists(os.path.dirname(sid_file)):
            xbmcvfs.mkdir(os.path.dirname(sid_file))

        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)

    result = url_get_origin(url,
                            params,
                            headers,
                            post,
                            handlers=[cookie_handler])

    if not result:
        return ""

    match = re.search(
        r'document.cookie=\'_ddn_intercept_2_=(.*?); max-age=([0-9]*?); path=/\';',
        result)

    if match:
        parts = urlparse(url)
        expires = time.time() + int(match.group(2))
        cookie = cookielib.Cookie(version=0, name='_ddn_intercept_2_', value=match.group(1), port=(parts.port or "80"), port_specified=(parts.port is not None), \
            domain=parts.hostname, domain_specified=(parts.hostname is not None), domain_initial_dot=parts.hostname.startswith('.'), path='/', path_specified=True, \
            secure=(parts.scheme == "https"), expires=expires, discard=False, comment=None, comment_url=None, rest={'HttpOnly': False}, rfc2109=False)

        _cookiejar.set_cookie(cookie)
        _cookiejar.save()

        result = url_get_origin(url,
                                params,
                                headers,
                                post,
                                handlers=[cookie_handler])

    _cookiejar.save()

    return result
Esempio n. 3
0
def url_get(url, params={}, headers={}, post=None, cookie=None):
    global _cookiejar
    import xbmcvfs, urllib2
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os, xbmc, cookielib

        sid_file = os.path.join(xbmc.translatePath('special://temp/'),
                                plugin.id, 'LostFilm.cookies.dat')  #
        if not xbmcvfs.exists(os.path.dirname(sid_file)):
            xbmcvfs.mkdir(os.path.dirname(sid_file))

        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

    if cookie:
        _cookiejar.set_cookie(cookie)
    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)
    plugin.log.debug("Loading uri: %s with cookies %s params %s post %s" %
                     (url, _cookiejar, str(params), str(post)))
    result = url_get_origin(url,
                            params,
                            headers,
                            post,
                            handlers=[cookie_handler])
    _cookiejar.save()
    plugin.log.debug("Uri loaded: " + url)

    if result.find("profile.php?mode=sendpassword") >= 0:
        if not plugin.get_setting(
                "rutracker_login") and not plugin.get_setting(
                    "rutracker_passwd"):
            plugin.notify("Проверьте настройки авторизации.", delay=15000)
            return
        if _rutracker_login(_cookiejar):
            result = url_get_origin(url,
                                    params,
                                    headers,
                                    post,
                                    handlers=[cookie_handler])
            _cookiejar.save()

    return result
Esempio n. 4
0
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
Esempio n. 5
0
def url_get(url, params={}, headers=None, post=None):
    global _cookiejar
    import xbmcvfs
    import urllib2
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os
        import cookielib

        sid_file = os.path.join(CACHE_DIR, 'LostFilm2.cookies.dat')
        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)

    if headers is None:
        headers = HEADERS

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

    return result
Esempio n. 6
0
def url_get(url, params={}, headers={}, post=None):
    global _cookiejar
    import urllib2
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os, cookielib, xbmc, xbmcvfs

        sid_file = os.path.join(xbmc.translatePath('special://temp/'),
                                plugin.id, 'torrents3d.cookies.dat')  #
        if not xbmcvfs.exists(os.path.dirname(sid_file)):
            xbmcvfs.mkdir(os.path.dirname(sid_file))

        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

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

    return result
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
Esempio n. 8
0
def url_get(url, params={}, headers={}, post=None):
    global _cookiejar

    import re
    import time
    import cookielib
    from urlparse import urlparse
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os
        import urllib2
        import xbmcvfs

        sid_file = os.path.join(CACHE_DIR, 'rutor.cookies.dat')
        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)

    result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])

    if not result:
        return ""

    match = re.search(r'document.cookie=\'_ddn_intercept_2_=(.*?); max-age=([0-9]*?); path=/\';', result)

    if match:
        parts = urlparse(url)
        expires = time.time() + int(match.group(2))
        cookie = cookielib.Cookie(version=0, name='_ddn_intercept_2_', value=match.group(1), port=(parts.port or "80"), port_specified=(parts.port is not None),
                                  domain=parts.hostname, domain_specified=(parts.hostname is not None), domain_initial_dot=parts.hostname.startswith('.'), path='/', path_specified=True,
                                  secure=(parts.scheme == "https"), expires=expires, discard=False, comment=None, comment_url=None, rest={'HttpOnly': False}, rfc2109=False)

        _cookiejar.set_cookie(cookie)
        _cookiejar.save()

        result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])

    _cookiejar.save()

    return result
def url_get(url, params={}, headers={}, post=None, cookie=None):
    global _cookiejar
    import xbmcvfs, urllib2
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os, xbmc, cookielib

        sid_file = os.path.join(xbmc.translatePath('special://temp/'), plugin.id, 'LostFilm.cookies.dat')  #
        if not xbmcvfs.exists(os.path.dirname(sid_file)):
            xbmcvfs.mkdir(os.path.dirname(sid_file))

        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

    if cookie:
        _cookiejar.set_cookie(cookie)
    cookie_handler = urllib2.HTTPCookieProcessor(_cookiejar)
    plugin.log.debug("Loading uri: %s with cookies %s params %s post %s" % (url, _cookiejar,str(params), str(post)))
    result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])
    _cookiejar.save()
    plugin.log.debug("Uri loaded: " + url)

    if result.find("profile.php?mode=sendpassword") >= 0:
        if not plugin.get_setting("rutracker_login") and not plugin.get_setting("rutracker_passwd"):
            plugin.notify("Проверьте настройки авторизации.", delay=15000)
            return
        if _rutracker_login(_cookiejar):
            result = url_get_origin(url, params, headers, post, handlers=[cookie_handler])
            _cookiejar.save()

    return result
Esempio n. 10
0
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
Esempio n. 11
0
def url_get(url, params={}, headers={}, post = None):
    from xbmctorrent.utils import url_get as url_get_origin

    if not STATIC_VARS["cookie"]:
        import os, xbmc, urllib2, cookielib

        sid_file = os.path.join(xbmc.translatePath('special://temp/'), 'plugin.video.xbmctorrent.filelist.cookies.dat') #
        cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not os.path.isfile(sid_file):
            cookiejar.save()

        cookiejar.load()
        STATIC_VARS["cookie"] = cookiejar

        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
        urllib2.install_opener(opener)

    result = url_get_origin(url, params, headers, post)
    STATIC_VARS["cookie"].save()

    return result
Esempio n. 12
0
def url_get(url, params={}, headers={}, post = None):
    global _cookiejar
    import urllib2
    from xbmctorrent.utils import url_get as url_get_origin

    if not _cookiejar:
        import os, cookielib, xbmc, xbmcvfs

        sid_file = os.path.join(xbmc.translatePath('special://temp/'), plugin.id, 'torrents3d.cookies.dat') #
        if not xbmcvfs.exists(os.path.dirname(sid_file)):
            xbmcvfs.mkdir(os.path.dirname(sid_file))

        _cookiejar = cookielib.MozillaCookieJar(sid_file)

        if not xbmcvfs.exists(sid_file):
            _cookiejar.save()

        _cookiejar.load()

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

    return result