summaryrefslogtreecommitdiffstats
path: root/Plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-18 13:17:18 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-06-18 13:17:18 +0200
commit0a705696089fdc28463d45598fde2ceb78220790 (patch)
tree17b8fa4dbd2c04075891e1cec44556e239484e96 /Plugins
parentfixed disconnecting (diff)
downloadpyload-0a705696089fdc28463d45598fde2ceb78220790.tar.xz
plugin for gigasize
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/GigasizeCom.py74
-rw-r--r--Plugins/Plugin.py20
2 files changed, 92 insertions, 2 deletions
diff --git a/Plugins/GigasizeCom.py b/Plugins/GigasizeCom.py
new file mode 100644
index 000000000..ef39cc3cc
--- /dev/null
+++ b/Plugins/GigasizeCom.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import re
+import tempfile
+
+from Plugin import Plugin
+
+class GigasizeCom(Plugin):
+
+ def __init__(self, parent):
+ Plugin.__init__(self, parent)
+ props = {}
+ props['name'] = "GigasizeCom"
+ props['type'] = "hoster"
+ props['pattern'] = r"(?:http://)?(?:www.)?gigasize.com/get.php\?d="
+ props['version'] = "0.1"
+ props['description'] = """Gigasize.com Download Plugin"""
+ props['author_name'] = ("spoob")
+ props['author_mail'] = ("spoob@pyload.org")
+ self.props = props
+ self.parent = parent
+ self.html = [None, None]
+ self.want_reconnect = False
+ self.init_ocr()
+ self.multi_dl = False
+
+ def download_html(self):
+ url = self.parent.url
+ self.html[0] = self.req.load(url, cookies=True)
+
+ captcha_image = tempfile.NamedTemporaryFile().name + ".jpg"
+ self.req.download("http://www.gigasize.com/randomImage.php", captcha_image, cookies=True)
+ captcha = self.ocr.get_captcha(captcha_image)
+
+ os.remove(captcha_image)
+ print captcha
+
+ self.html[1] = self.req.load(file_server_url, None, {"txtNumber": captcha}, cookies=True)
+
+ def get_file_url(self):
+ """ returns the absolute downloadable filepath
+ """
+ if self.html[0] == None:
+ self.download_html()
+ if not self.want_reconnect:
+ file_url_pattern = r"<form action=\"(/getcgi.php\?t=.*)\" method=\"post\" id=\"formDownload\">"
+ return "http://gigazise.com" + re.search(file_url_pattern, self.html[1]).group(1)
+ else:
+ return False
+
+ def get_file_name(self):
+ if self.html[0] == None:
+ self.download_html()
+ if not self.want_reconnect:
+ file_name_pattern = "<p><strong>Name</strong>: <b>(.*)</b></p>"
+ return re.search(file_name_pattern, self.html[0]).group(1)
+ else:
+ return self.parent.url
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html[0] == None:
+ self.download_html()
+ if re.search(r"HTTP Status 404", self.html) != None:
+ return False
+ else:
+ return True
+
+ def proceed(self, url, location):
+
+ self.req.download(url, location, cookies=True) \ No newline at end of file
diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py
index f43172b55..ba3ee29b3 100644
--- a/Plugins/Plugin.py
+++ b/Plugins/Plugin.py
@@ -1,6 +1,22 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-
+#
+#Copyright (C) 2009 kingzero, RaNaN
+#
+#This program is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 3 of the License,
+#or (at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#See the GNU General Public License for more details.
+#
+#You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+###
import ConfigParser
import re
@@ -76,7 +92,7 @@ class Plugin():
self.config[option] = False if self.config[option].lower() == 'false' else self.config[option]
def init_ocr(self):
- modul = __import__(self.props['name'], fromlist=['plugins'])
+ modul = __import__("captcha."+self.props['name'], fromlist=['captcha'])
captchaClass = getattr(modul, self.props['name'])
self.ocr = captchaClass()