From a72eea3f44013bd1d08dddf2234fffc1402bedea Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 7 Sep 2009 21:25:48 +0200 Subject: [PATCH] copy headers --- oxweb/karagarga.py | 6 +++++- oxweb/thepiratebay.py | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/oxweb/karagarga.py b/oxweb/karagarga.py index 44f7b3b..acbbebd 100644 --- a/oxweb/karagarga.py +++ b/oxweb/karagarga.py @@ -6,7 +6,8 @@ from oxlib.text import findRe import auth -def _getUrl(url, data=None, headers=cache.DEFAULT_HEADERS.copy(), timeout=cache.cache_timeout, valid=None): +def _getUrl(url, data=None, headers=cache.DEFAULT_HEADERS, timeout=cache.cache_timeout, valid=None): + headers = headers.copy() headers["Cookie"] = auth.get("karagarga.cookie") return cache.getUrl(url, data, headers, timeout) @@ -85,6 +86,9 @@ def getData(id): def getId(url): return url.split("=")[-1] +def getTorrent(id): + return _getUrl(getData(id)['torrent']) + def getIds(lastId = 20): lastId = '%s' % lastId ids = [] diff --git a/oxweb/thepiratebay.py b/oxweb/thepiratebay.py index f9e7a64..d2e23b0 100644 --- a/oxweb/thepiratebay.py +++ b/oxweb/thepiratebay.py @@ -18,7 +18,8 @@ cache_timeout = 24*60*60 # cache search only for 24 hours season_episode = re.compile("S..E..", re.IGNORECASE) -def _getUrl(url, data=None, headers=cache.DEFAULT_HEADERS.copy(), timeout=cache.cache_timeout, valid=None): +def _getUrl(url, data=None, headers=cache.DEFAULT_HEADERS, timeout=cache.cache_timeout, valid=None): + headers = headers.copy() headers['Cookie'] = 'language=en_EN' return cache.getUrl(url, data, headers, timeout)