summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar Jeix <devnull@localhost> 2010-07-04 21:50:26 +0200
committerGravatar Jeix <devnull@localhost> 2010-07-04 21:50:26 +0200
commitfa0ff9999de13fe05b0ba671c9ee87b3cded7cda (patch)
tree18414c303162e18b7a2c9862b66b887f2ab2662f /module
parentRapidshareCom premium fix (diff)
downloadpyload-fa0ff9999de13fe05b0ba671c9ee87b3cded7cda.tar.xz
python 2.5 compatibility fix for ShareOnline.Biz
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hoster/ShareonlineBiz.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py
index f7ef3d4f1..928bce1f5 100644
--- a/module/plugins/hoster/ShareonlineBiz.py
+++ b/module/plugins/hoster/ShareonlineBiz.py
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
+import os.path
import re
import tempfile
from time import time
@@ -88,13 +89,27 @@ class ShareonlineBiz(Hoster):
#captcha_image = tempfile.NamedTemporaryFile(suffix=".jpg").name
for i in range(10):
-
- captcha_image = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
+ try:
+ captcha_image = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
+
+ # Fallback for python version <2.6
+ except TypeError:
+ captcha_image_name = os.path.join(tempfile.gettempdir(), "pyload_tmp_%d"%time())
+ captcha_image = open(captcha_image_name, "w+b")
+
imgStr = self.req.load("http://www.share-online.biz/captcha.php?rand="+ "0." + str(random.randint(10**15,10**16)), cookies=True)
captcha_image.write(imgStr)
captcha_image.close()
- captcha = self.ocr.get_captcha(captcha_image.name)
- os.remove(captcha_image.name)
+
+ # again fallback
+ try:
+ captcha = self.ocr.get_captcha(captcha_image.name)
+ os.remove(captcha_image.name)
+
+ except AttributeError:
+ captcha = self.ocr.get_captcha(captcha_image_name)
+ os.remove(captcha_image_name)
+
self.logger.debug("%s Captcha %s: %s" % (self.__name__, i, captcha))
sleep(3)
self.html[1] = self.load(url, post={"captchacode": captcha}, cookies=True)