From 6815c6436e2374e184ddc8c0ad8a3e301ee2883e Mon Sep 17 00:00:00 2001 From: Jat Date: Mon, 20 Jan 2014 14:01:03 +0800 Subject: [PATCH] Thank @torta https://github.com/iambus/xunlei-lixian/pull/380 --- handlers/add_task.py | 4 ++-- libs/lixian_api.py | 22 ++++++++++++++-------- static/css/add_task.css | 3 ++- templates/add_task.html | 4 ++-- templates/add_task_anonymous.html | 7 ++++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/handlers/add_task.py b/handlers/add_task.py index 169d81c..17f9ac9 100644 --- a/handlers/add_task.py +++ b/handlers/add_task.py @@ -62,8 +62,8 @@ def post(self, anonymous): anonymous = True if anonymous else False render_path = "add_task_anonymous.html" if anonymous else "add_task.html" email = self.current_user['email'] - verifycode = self.get_argument("verifycode", None) - verifykey = self.get_cookie("verifykey") or None +# verifycode = self.get_argument("verifycode", None) +# verifykey = self.get_cookie("verifykey") or None if anonymous and not self.has_permission("add_anonymous_task"): raise HTTPError(403, "You might not have permission to add anonymous task.") diff --git a/libs/lixian_api.py b/libs/lixian_api.py index 7c7e75c..444eabe 100644 --- a/libs/lixian_api.py +++ b/libs/lixian_api.py @@ -8,7 +8,7 @@ import requests import xml.sax.saxutils from hashlib import md5 -from random import random, sample +from random import random, sample, randint from urlparse import urlparse from pprint import pformat from jsfunctionParser import parser_js_function_call @@ -210,8 +210,11 @@ def add_bt_task_with_dict(self, url, info, verifycode=None, verifykey=None): ) data["from"] = 0 DEBUG(pformat(data)) - if verifycode and verifykey: - self.session.cookies = self.update_verifykey(self.session.cookies, verifykey) +# if verifycode and verifykey: +# self.session.cookies = self.update_verifykey(self.session.cookies, 'VERIFY_KEY', verifykey) + # Thank @torta https://github.com/iambus/xunlei-lixian/pull/380 + userid = '0' * randint(0, 3000) + str(int(self.session.cookies['userid'])) + self.session.cookies = self.update_cookie(self.session.cookies, 'userid', userid) DEBUG(pformat(self.session.cookies)) r = self.session.post(self.BT_TASK_COMMIT_URL, data=data) r.raise_for_status() @@ -279,8 +282,11 @@ def add_task_with_dict(self, url, info, verifycode=None, verifykey=None): verify_code = verifycode ) DEBUG(pformat(params)) - if verifycode and verifykey: - self.session.cookies = self.update_verifykey(self.session.cookies, verifykey) +# if verifycode and verifykey: +# self.session.cookies = self.update_cookie(self.session.cookies, 'VERIFY_KEY', verifykey) + # Thank @torta https://github.com/iambus/xunlei-lixian/pull/380 + userid = '0' * randint(0, 3000) + str(int(self.session.cookies['userid'])) + self.session.cookies = self.update_cookie(self.session.cookies, 'userid', userid) DEBUG(pformat(self.session.cookies)) r = self.session.get(self.TASK_COMMIT_URL, params=params) r.raise_for_status() @@ -410,10 +416,10 @@ def add(self, url, title=None): else: return self.add_batch_task([url, ]) - def update_verifykey(self, cookiejar, verifykey): + def update_cookie(self, cookiejar, cookie_name, cookie_value): _cookies = requests.cookies - _cookies.remove_cookie_by_name(cookiejar, 'VERIFY_KEY') - cookiejar.set_cookie(_cookies.create_cookie('VERIFY_KEY', verifykey, **{'domain': '.xunlei.com'})) + _cookies.remove_cookie_by_name(cookiejar, cookie_name) + cookiejar.set_cookie(_cookies.create_cookie(cookie_name, cookie_value, **{'domain': '.xunlei.com'})) return cookiejar FILL_BT_LIST = "http://dynamic.cloud.vip.xunlei.com/interface/fill_bt_list" diff --git a/static/css/add_task.css b/static/css/add_task.css index eddd264..924fc87 100644 --- a/static/css/add_task.css +++ b/static/css/add_task.css @@ -64,7 +64,8 @@ input, textarea { clear: both; overflow: hidden; width: 410px; - padding: 20px 0 0 150px; +/* padding: 20px 0 0 150px; */ + padding: 20px 0 0 90px; } .CAPTCHA { float: left; diff --git a/templates/add_task.html b/templates/add_task.html index 9feb46f..d298be8 100644 --- a/templates/add_task.html +++ b/templates/add_task.html @@ -50,10 +50,10 @@
-
+
{% if options.using_xsrf %}{% raw handler.xsrf_form_html() %}{% end %} diff --git a/templates/add_task_anonymous.html b/templates/add_task_anonymous.html index c0cdca4..fb336a5 100644 --- a/templates/add_task_anonymous.html +++ b/templates/add_task_anonymous.html @@ -20,7 +20,8 @@ } .addtask_button { width: 410px; - padding-left: 195px; +/* padding-left: 195px; */ + padding-left: 125px; } .up { margin: 5px 0 3px 80px; @@ -60,10 +61,10 @@
-
+
{% if options.using_xsrf %}{% raw handler.xsrf_form_html() %}{% end %}