summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-11-10 22:26:08 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-11-10 22:26:08 +0100
commit80e35e5a93845286e04baf56200955576fc2813c (patch)
treee461525c1b479108e74a838bf9f8218c7271e51f
parentremoved debug stuff from hotfile plugin (diff)
downloadpyload-80e35e5a93845286e04baf56200955576fc2813c.tar.xz
netload checksum check
-rw-r--r--module/plugins/NetloadIn.py34
-rw-r--r--module/plugins/RapidshareCom.py10
2 files changed, 38 insertions, 6 deletions
diff --git a/module/plugins/NetloadIn.py b/module/plugins/NetloadIn.py
index 0b53f86b3..c3a421cc8 100644
--- a/module/plugins/NetloadIn.py
+++ b/module/plugins/NetloadIn.py
@@ -6,6 +6,7 @@ import re
import tempfile
from time import time
from time import sleep
+import hashlib
from Plugin import Plugin
@@ -26,6 +27,7 @@ class NetloadIn(Plugin):
self.html = [None, None, None]
self.want_reconnect = False
self.multi_dl = False
+ self.api_data = None
self.init_ocr()
self.read_config()
if self.config['premium']:
@@ -49,6 +51,8 @@ class NetloadIn(Plugin):
if not pyfile.status.exists:
raise Exception, "The file was not found on the server."
+
+ self.download_api_data()
pyfile.status.filename = self.get_file_name()
@@ -72,6 +76,21 @@ class NetloadIn(Plugin):
raise Exception, "Error while preparing DL, HTML dump: %s %s" % (self.html[0], self.html[1])
return True
+
+ def download_api_data(self):
+ url = self.parent.url
+ id_regex = re.compile("http://netload.in/datei(.*)\.htm")
+ match = id_regex.search(url)
+ if match:
+ apiurl = "http://netload.in/share/fileinfos2.php"
+ src = self.req.load(apiurl, cookies=False, get={"file_id": match.group(1)})
+ self.api_data = {}
+ lines = src.split(";")
+ self.api_data["fileid"] = lines[0]
+ self.api_data["filename"] = lines[1]
+ self.api_data["size"] = lines[2] #@TODO formatting? (ex: '2.07 KB')
+ self.api_data["status"] = lines[3]
+ self.api_data["checksum"] = lines[4]
def download_html(self):
@@ -130,6 +149,8 @@ class NetloadIn(Plugin):
def get_file_name(self):
try:
+ if self.api_data and self.api_data["filename"]:
+ return self.api_data["filename"]
file_name_pattern = '\t\t\t(.+)<span style="color: #8d8d8d;">'
return re.search(file_name_pattern, self.html[0]).group(1)
except:
@@ -146,3 +167,16 @@ class NetloadIn(Plugin):
def proceed(self, url, location):
self.req.download(url, location, cookies=True)
+
+ def check_file(self, local_file):
+ if self.api_data and self.api_data["checksum"]:
+ h = hashlib.md5()
+ with open(local_file, "rb") as f:
+ h.update(f.read())
+ hexd = h.hexdigest()
+ if hexd == self.api_data["checksum"]:
+ return (True, 0)
+ else:
+ return (False, 1)
+ else:
+ return (True, 5)
diff --git a/module/plugins/RapidshareCom.py b/module/plugins/RapidshareCom.py
index 67db37245..7eeddf007 100644
--- a/module/plugins/RapidshareCom.py
+++ b/module/plugins/RapidshareCom.py
@@ -14,7 +14,7 @@ class RapidshareCom(Plugin):
props = {}
props['name'] = "RapidshareCom"
props['type'] = "hoster"
- props['pattern'] = r"http://(?:www.)?(rs\d*.)?rapidshare.com/files/"
+ props['pattern'] = r"http://(?:www\.)?(?:rs\d*\.)?rapidshare.com/files/(\d*?)/(.*)"
props['version'] = "0.5"
props['description'] = """Rapidshare.com Download Plugin"""
props['author_name'] = ("spoob", "RaNaN", "mkaay")
@@ -25,8 +25,6 @@ class RapidshareCom(Plugin):
self.html_old = None #time() where loaded the HTML
self.time_plus_wait = None #time() + wait in seconds
self.want_reconnect = False
-
- self.urlRegex = re.compile(r'http://[\w\.]*?rapidshare\.com/files/([\d]{3,9})/?(.+)') # regex from jdownloader
self.read_config()
if self.config['premium']:
@@ -83,10 +81,10 @@ class RapidshareCom(Plugin):
url = self.parent.url
api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi"
api_param = {"sub": "checkfiles_v1", "files": "", "filenames": "", "incmd5": "1"}
- m = self.urlRegex.search(url)
+ m = re.compile(self.props['pattern']).search(url)
if m:
- api_param["files"] = m.group(1)
- api_param["filenames"] = m.group(2)
+ api_param["files"] = m.group(3)
+ api_param["filenames"] = m.group(4)
src = self.req.load(api_url_base, cookies=False, get=api_param)
if not src.find("ERROR"):
return