diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-28 12:52:56 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-28 12:52:56 +0200 |
commit | c9eb7081bbd4cedf9a6574c39ceb0cfde1083113 (patch) | |
tree | 7c3e26941ccf347c6a1571b155cc8ef1cc2d685c /Plugins | |
parent | fexed little bug (diff) | |
download | pyload-c9eb7081bbd4cedf9a6574c39ceb0cfde1083113.tar.xz |
clean up some code, new config parser, basic time shedule
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/Plugin.py | 33 | ||||
-rw-r--r-- | Plugins/RSDF.py | 38 | ||||
-rw-r--r-- | Plugins/RapidshareCom.py | 42 | ||||
-rw-r--r-- | Plugins/UploadedTo.py | 21 | ||||
-rw-r--r-- | Plugins/YoutubeCom.py | 22 |
5 files changed, 77 insertions, 79 deletions
diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index 0eefd8d9b..0345d7b1d 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -1,24 +1,26 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +import ConfigParser import re -from time import time + from module.network.Request import Request class Plugin(): def __init__(self, parent): - self.plugin_name = None + self.plugin_name = "Base" self.plugin_pattern = None self.plugin_type = "hoster" - plugin_config = {} - plugin_config['name'] = "Base Plugin" - plugin_config['version'] = "0.1" - plugin_config['format'] = "*.py" - plugin_config['description'] = """bla""" - plugin_config['author'] = "Spoob" - plugin_config['author_email'] = "nn@nn.de" - self.plugin_config = plugin_config + self.parser = ConfigParser.SafeConfigParser() + props = {} + props['name'] = "Base Plugin" + props['version'] = "0.1" + props['format'] = "*.py" + props['description'] = """bla""" + props['author'] = "Spoob" + props['author_email'] = "nn@nn.de" + self.props = props self.parent = parent self.req = Request() self.html = None @@ -49,7 +51,7 @@ class Plugin(): def get_file_name(self): - return re.findall("([^\/=]+)",self.parent.url)[-1] + return re.findall("([^\/=]+)", self.parent.url)[-1] def wait_until(self): if self.html != None: @@ -58,6 +60,13 @@ class Plugin(): def proceed(self, url, location): self.req.download(url, location) - + + def set_config(self): + pass + + def get_config(self, value): + self.parser.read("pluginconfig") + return self.parser.get(self.props['name'], value) + def __call__(self): return self.plugin_name diff --git a/Plugins/RSDF.py b/Plugins/RSDF.py index 27938bb17..bbbf3d960 100644 --- a/Plugins/RSDF.py +++ b/Plugins/RSDF.py @@ -1,30 +1,24 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import urllib2 -import urllib -import re -import time -import binascii import base64 -import sys +import binascii from Plugin import Plugin -from time import time class RSDF(Plugin): def __init__(self, parent): Plugin.__init__(self, parent) - plugin_config = {} - plugin_config['name'] = "RSDF" - plugin_config['type'] = "container" - plugin_config['pattern'] = r".*\.rsdf" - plugin_config['version'] = "0.2" - plugin_config['description'] = """RSDF Container Decode Plugin""" - plugin_config['author_name'] = ("RaNaN", "spoob") - plugin_config['author_mail'] = ("RaNaN@pyload.org", "spoob@pyload.org") - self.plugin_config = plugin_config + props = {} + props['name'] = "RSDF" + props['type'] = "container" + props['pattern'] = r".*\.rsdf" + props['version'] = "0.2" + props['description'] = """RSDF Container Decode Plugin""" + props['author_name'] = ("RaNaN", "spoob") + props['author_mail'] = ("RaNaN@pyload.org", "spoob@pyload.org") + self.props = props self.parent = parent self.multi_dl = True self.links = [] @@ -35,22 +29,22 @@ class RSDF(Plugin): return True def __call__(self): - return self.plugin_config['name'] + return self.props['name'] def proceed(self, url, location): try: from Crypto.Cipher import AES - infile = url.replace("\n","") + infile = url.replace("\n", "") Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000') IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') - IV_Cipher = AES.new(Key,AES.MODE_ECB) + IV_Cipher = AES.new(Key, AES.MODE_ECB) IV = IV_Cipher.encrypt(IV) - obj = AES.new(Key,AES.MODE_CFB,IV) + obj = AES.new(Key, AES.MODE_CFB, IV) - rsdf = open(infile,'r') + rsdf = open(infile, 'r') data = rsdf.read() data = binascii.unhexlify(''.join(data.split())) @@ -59,7 +53,7 @@ class RSDF(Plugin): for link in data: link = base64.b64decode(link) link = obj.decrypt(link) - decryptedUrl = link.replace('CCF: ','') + decryptedUrl = link.replace('CCF: ', '') self.links.append(decryptedUrl) rsdf.close() diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index 694fa29c9..8f774937b 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -1,27 +1,25 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import urllib2 -import urllib import re import time +from time import time from Plugin import Plugin -from time import time class RapidshareCom(Plugin): def __init__(self, parent): Plugin.__init__(self, parent) - plugin_config = {} - plugin_config['name'] = "RapidshareCom" - plugin_config['type'] = "hoster" - plugin_config['pattern'] = r"http://(?:www.)?rapidshare.com/files/" - plugin_config['version'] = "0.1" - plugin_config['description'] = """Rapidshare.com Download Plugin""" - plugin_config['author_name'] = ("spoob") - plugin_config['author_mail'] = ("spoob@pyload.org") - self.plugin_config = plugin_config + props = {} + props['name'] = "RapidshareCom" + props['type'] = "hoster" + props['pattern'] = r"http://(?:www.)?rapidshare.com/files/" + props['version'] = "0.1" + props['description'] = """Rapidshare.com Download Plugin""" + props['author_name'] = ("spoob") + props['author_mail'] = ("spoob@pyload.org") + self.props = props self.parent = parent self.html = [None, None] self.html_old = None #time() where loaded the HTML @@ -57,7 +55,7 @@ class RapidshareCom(Plugin): file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) #free user #free_user_encode = urllib.urlencode({"dl.start" : "Free"}) - self.html[1] = self.req.load(file_server_url, None,{"dl.start" : "Free"}) + self.html[1] = self.req.load(file_server_url, None, {"dl.start": "Free"}) self.html_old = time() self.get_wait_time() @@ -65,17 +63,17 @@ class RapidshareCom(Plugin): def get_wait_time(self): if self.html[1] == None: - download_serverhtml(self) + self.download_serverhtml(self) if re.search(r".*is already downloading.*", self.html[1]) != None: - self.time_plus_wait = time() + 10*60 + self.time_plus_wait = time() + 10 * 60 try: wait_minutes = re.search(r"Or try again in about (\d+) minute", self.html[1]).group(1) self.time_plus_wait = time() + 60 * int(wait_minutes) self.want_reconnect = True except: if re.search(r".*Currently a lot of users.*", self.html[1]) != None: - self.time_plus_wait = time() + 2*60 + self.time_plus_wait = time() + 2 * 60 wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1) self.time_plus_wait = time() + int(wait_seconds) + 5 @@ -85,10 +83,10 @@ class RapidshareCom(Plugin): if self.html[0] == None: self.download_html() if re.search(r".*The File could not be found.*", self.html[0]) != None or \ - re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \ - re.search(r"(.*is momentarily not available.*)", self.html[0]) or \ - re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]) or \ - re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]): + re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \ + re.search(r"(.*is momentarily not available.*)", self.html[0]) or \ + re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]) or \ + re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]): return False else: return True @@ -98,7 +96,7 @@ class RapidshareCom(Plugin): """ if self.html[1] == None: self.download_serverhtml() - if (self.html_old + 5*60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell + if (self.html_old + 5 * 60) < time(): # nach einiger zeit ist die file_url nicht mehr aktuell self.download_serverhtml() if not self.want_reconnect: @@ -122,4 +120,4 @@ class RapidshareCom(Plugin): return self.time_plus_wait def __call__(self): - return self.plugin_config['name'] + return self.props['name'] diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index 7c579ea15..29817e992 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -import urllib2 import re from time import time from Plugin import Plugin @@ -9,15 +8,15 @@ class UploadedTo(Plugin): def __init__(self, parent): Plugin.__init__(self, parent) - plugin_config = {} - plugin_config['name'] = "UploadedTo" - plugin_config['type'] = "hoster" - plugin_config['pattern'] = r"http://(www\.)?uploaded.to/" - plugin_config['version'] = "0.1" - plugin_config['description'] = """Uploaded.to Download Plugin""" - plugin_config['author_name'] = ("spoob") - plugin_config['author_mail'] = ("spoob@pyload.org") - self.plugin_config = plugin_config + props = {} + props['name'] = "UploadedTo" + props['type'] = "hoster" + props['pattern'] = r"http://(www\.)?uploaded.to/" + props['version'] = "0.1" + props['description'] = """Uploaded.to Download Plugin""" + props['author_name'] = ("spoob") + props['author_mail'] = ("spoob@pyload.org") + self.plugin_config = props self.parent = parent self.html = None self.html_old = None #time() where loaded the HTML @@ -83,4 +82,4 @@ class UploadedTo(Plugin): return self.time_plus_wait def __call__(self): - return self.plugin_config['name'] + return self.props['name'] diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py index d6b0473d3..c1ad22102 100644 --- a/Plugins/YoutubeCom.py +++ b/Plugins/YoutubeCom.py @@ -1,23 +1,21 @@ #!/usr/bin/env python -import urllib2 import re -from time import time from Plugin import Plugin class YoutubeCom(Plugin): def __init__(self, parent): Plugin.__init__(self, parent) - plugin_config = {} - plugin_config['name'] = "YoutubeCom" - plugin_config['type'] = "hoster" - plugin_config['pattern'] = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" - plugin_config['version'] = "0.1" - plugin_config['description'] = """Youtube.com Video Download Plugin""" - plugin_config['author_name'] = ("spoob") - plugin_config['author_mail'] = ("spoob@pyload.org") - self.plugin_config = plugin_config + props = {} + props['name'] = "YoutubeCom" + props['type'] = "hoster" + props['pattern'] = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*" + props['version'] = "0.1" + props['description'] = """Youtube.com Video Download Plugin""" + props['author_name'] = ("spoob") + props['author_mail'] = ("spoob@pyload.org") + self.props = props self.parent = parent self.html = None self.html_old = None #time() where loaded the HTML @@ -71,4 +69,4 @@ class YoutubeCom(Plugin): return self.time_plus_wait def __call__(self): - return self.plugin_config['name'] + return self.props['name'] |