diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-14 15:37:58 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-05-14 15:37:58 +0200 |
commit | 9973f09a616900ab0900974da77d22b566598b5f (patch) | |
tree | 0669cdda0a367e1b53b7286f19b6aaf1b9e4004a /module/plugins | |
parent | revert premium account change see #309 (diff) | |
download | pyload-9973f09a616900ab0900974da77d22b566598b5f.tar.xz |
improved some code style issues
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/Plugin.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/LinkSaveIn.py | 4 | ||||
-rw-r--r-- | module/plugins/crypter/NCryptIn.py | 6 | ||||
-rw-r--r-- | module/plugins/crypter/NetfolderIn.py | 4 | ||||
-rw-r--r-- | module/plugins/crypter/RelinkUs.py | 6 | ||||
-rw-r--r-- | module/plugins/hooks/ClickAndLoad.py | 26 | ||||
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 17 | ||||
-rw-r--r-- | module/plugins/hooks/IRCInterface.py | 34 | ||||
-rw-r--r-- | module/plugins/hoster/ShareonlineBiz.py | 13 | ||||
-rw-r--r-- | module/plugins/hoster/UploadStationCom.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/UploadingCom.py | 25 | ||||
-rw-r--r-- | module/plugins/hoster/Xdcc.py | 2 | ||||
-rw-r--r-- | module/plugins/hoster/YourfilesTo.py | 2 |
13 files changed, 69 insertions, 76 deletions
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index cef839861..e23e9558f 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -170,7 +170,7 @@ class Plugin(object): """ #@TODO checksum check hook - return (True, 10) + return True, 10 def setConf(self, option, value): diff --git a/module/plugins/crypter/LinkSaveIn.py b/module/plugins/crypter/LinkSaveIn.py index d77556b0d..03c385cb3 100644 --- a/module/plugins/crypter/LinkSaveIn.py +++ b/module/plugins/crypter/LinkSaveIn.py @@ -49,7 +49,7 @@ class LinkSaveIn(Crypter): name = self.pyfile.package().name
folder = self.pyfile.package().folder
self.log.debug("%s: Default to pyfile name [%s] and folder [%s] for package" % (self.__name__, name, folder))
- return (name, folder)
+ return name, folder
def handleCaptcha(self):
if "<b>Captcha:</b>" in self.html:
@@ -73,7 +73,7 @@ class LinkSaveIn(Crypter): # Log and return
self.log.debug("%s: Javascript cipher key function [%s]" % (self.__name__, jk))
- return (crypted, jk)
+ return crypted, jk
def getLinks(self, crypted, jk):
diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py index 438ee9d0d..d2438b285 100644 --- a/module/plugins/crypter/NCryptIn.py +++ b/module/plugins/crypter/NCryptIn.py @@ -89,7 +89,7 @@ class NCryptIn(Crypter): name = self.package.name
folder = self.package.folder
self.log.debug("%s: Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (self.__name__, name, folder))
- return (name, folder)
+ return name, folder
def unlockProtection(self):
@@ -152,7 +152,7 @@ class NCryptIn(Crypter): try:
url = link.replace("link-", "frame-")
link = self.load(url, just_header=True)['location']
- except Exception as e:
+ except Exception, e:
self.log.debug("%s: Error decrypting Web link %s, %s" % (self.__name__, link, e))
package_links.append(link)
return package_links
@@ -196,7 +196,7 @@ class NCryptIn(Crypter): # Log and return
self.log.debug("%s: Detected %d crypted blocks" % (self.__name__, len(vcrypted)))
- return (vcrypted, vjk)
+ return vcrypted, vjk
def _getLinks(self, crypted, jk):
diff --git a/module/plugins/crypter/NetfolderIn.py b/module/plugins/crypter/NetfolderIn.py index 9d27c33d6..995eb4d4c 100644 --- a/module/plugins/crypter/NetfolderIn.py +++ b/module/plugins/crypter/NetfolderIn.py @@ -71,12 +71,12 @@ class NetfolderIn(Crypter): if m is not None: name = folder = m.group('title') self.log.debug("%s: Found name [%s] and folder [%s] in package info" % (self.__name__, name, folder)) - return (name, folder) + return name, folder else: name = self.pyfile.package().name folder = self.pyfile.package().folder self.log.debug("%s: Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (self.__name__, name, folder)) - return (name, folder) + return name, folder def getLinks(self): diff --git a/module/plugins/crypter/RelinkUs.py b/module/plugins/crypter/RelinkUs.py index 8391deeb4..64fbb9214 100644 --- a/module/plugins/crypter/RelinkUs.py +++ b/module/plugins/crypter/RelinkUs.py @@ -96,12 +96,12 @@ class RelinkUs(Crypter): if m is not None: name = folder = m.group('title') self.log.debug("%s: Found name [%s] and folder [%s] in package info" % (self.__name__, name, folder)) - return (name, folder) + return name, folder else: name = self.package.name folder = self.package.folder self.log.debug("%s: Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (self.__name__, name, folder)) - return (name, folder) + return name, folder def getCipherParams(self): @@ -120,7 +120,7 @@ class RelinkUs(Crypter): # Log and return self.log.debug("%s: Javascript cipher key function [%s]" % (self.__name__, jk)) - return (crypted, jk) + return crypted, jk def getLinks(self, crypted, jk): diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0ca492cb7..97e5cd57d 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -27,31 +27,32 @@ class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __version__ = "0.2" __description__ = """Gives abillity to use jd's click and load. depends on webinterface""" - __config__ = [ ("activated", "bool", "Activated" , "True"), - ("extern", "bool", "Allow external link adding", "False") ] + __config__ = [("activated", "bool", "Activated", "True"), + ("extern", "bool", "Allow external link adding", "False")] __author_name__ = ("RaNaN", "mkaay") __author_mail__ = ("RaNaN@pyload.de", "mkaay@mkaay.de") - + def coreReady(self): - self.port = int(self.core.config['webinterface']['port']) + self.port = int(self.core.config['webinterface']['port']) if self.core.config['webinterface']['activated']: try: - if self.getConfig("extern"): - ip = "0.0.0.0" - else: - ip = "127.0.0.1" - + if self.getConfig("extern"): + ip = "0.0.0.0" + else: + ip = "127.0.0.1" + thread.start_new_thread(proxy, (self, ip, self.port, 9666)) except: self.log.error("ClickAndLoad port already in use.") def proxy(self, *settings): - thread.start_new_thread(server, (self,)+settings) + thread.start_new_thread(server, (self,) + settings) lock = thread.allocate_lock() lock.acquire() lock.acquire() + def server(self, *settings): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -72,9 +73,10 @@ def server(self, *settings): if errno == 98: self.core.log.warning(_("Click'N'Load: Port 9666 already in use")) return - thread.start_new_thread(server, (self,)+settings) + thread.start_new_thread(server, (self,) + settings) except: - thread.start_new_thread(server, (self,)+settings) + thread.start_new_thread(server, (self,) + settings) + def forward(source, destination): string = ' ' diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 8d749b5bd..63ff2b170 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -49,18 +49,15 @@ class ExternalScripts(Hook): self.core.check_file(script_folders, _("folders for scripts"), True) f = lambda x: False if x.startswith("#") or x.endswith("~") else True - self.scripts = {} - - - self.scripts['download_preparing'] = filter(f, listdir(join(folder, 'download_preparing'))) - self.scripts['download_finished'] = filter(f, listdir(join(folder, 'download_finished'))) - self.scripts['package_finished'] = filter(f, listdir(join(folder, 'package_finished'))) - self.scripts['before_reconnect'] = filter(f, listdir(join(folder, 'before_reconnect'))) - self.scripts['after_reconnect'] = filter(f, listdir(join(folder, 'after_reconnect'))) - self.scripts['unrar_finished'] = filter(f, listdir(join(folder, 'unrar_finished'))) + self.scripts = {'download_preparing': filter(f, listdir(join(folder, 'download_preparing'))), + 'download_finished': filter(f, listdir(join(folder, 'download_finished'))), + 'package_finished': filter(f, listdir(join(folder, 'package_finished'))), + 'before_reconnect': filter(f, listdir(join(folder, 'before_reconnect'))), + 'after_reconnect': filter(f, listdir(join(folder, 'after_reconnect'))), + 'unrar_finished': filter(f, listdir(join(folder, 'unrar_finished')))} for script_type, script_name in self.scripts.iteritems(): - if script_name != []: + if script_name: self.log.info("Installed %s Scripts: %s" % (script_type, ", ".join(script_name))) #~ self.core.logger.info("Installed Scripts: %s" % str(self.scripts)) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 31d693018..0142c3610 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -132,7 +132,7 @@ class IRCInterface(Thread, Hook): line = line.rstrip() first = line.split() - if(first[0] == "PING"): + if first[0] == "PING": self.sock.send("PONG %s\r\n" % first[1]) if first[0] == "ERROR": @@ -213,8 +213,7 @@ class IRCInterface(Thread, Hook): return ["INFO: There are no active downloads currently."] temp_progress = "" - lines = [] - lines.append("ID - Name - Status - Speed - ETA - Progress") + lines = ["ID - Name - Status - Speed - ETA - Progress"] for data in downloads: if data['statusmsg'] == 'waiting': @@ -401,21 +400,20 @@ class IRCInterface(Thread, Hook): def event_help(self, args): - lines = [] - lines.append("The following commands are available:") - lines.append("add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)") - lines.append("queue Shows all packages in the queue") - lines.append("collector Shows all packages in collector") - lines.append("del -p|-l <id> [...] Deletes all packages|links with the ids specified") - lines.append("info <id> Shows info of the link with id <id>") - lines.append("packinfo <id> Shows info of the package with id <id>") - lines.append("more Shows more info when the result was truncated") - lines.append("start Starts all downloads") - lines.append("stop Stops the download (but not abort active downloads)") - lines.append("push <id> Push package to queue") - lines.append("pull <id> Pull package from queue") - lines.append("status Show general download status") - lines.append("help Shows this help message") + lines = ["The following commands are available:", + "add <package|packid> <links> [...] Adds link to package. (creates new package if it does not exist)", + "queue Shows all packages in the queue", + "collector Shows all packages in collector", + "del -p|-l <id> [...] Deletes all packages|links with the ids specified", + "info <id> Shows info of the link with id <id>", + "packinfo <id> Shows info of the package with id <id>", + "more Shows more info when the result was truncated", + "start Starts all downloads", + "stop Stops the download (but not abort active downloads)", + "push <id> Push package to queue", + "pull <id> Pull package from queue", + "status Show general download status", + "help Shows this help message"] return lines diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 6dd8933c0..360f0d788 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -72,9 +72,8 @@ class ShareonlineBiz(Hoster): src = self.load(api_url_base, cookies=False, post=api_param_file) fields = src.split(";") - self.api_data = {} - self.api_data["fileid"] = fields[0] - self.api_data["status"] = fields[1] + self.api_data = {"fileid": fields[0], + "status": fields[1]} if not self.api_data["status"] == "OK": self.offline() self.api_data["filename"] = fields[2] @@ -88,7 +87,7 @@ class ShareonlineBiz(Hoster): self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free":"1", "choice": "free"}) if re.search(r"/failure/full/1", self.req.lastEffectiveURL): self.setWait(120) - self.log.info("%s: no free slots, waiting 120 seconds" % (self.__name__)) + self.log.info("%s: no free slots, waiting 120 seconds" % self.__name__) self.wait() self.retry() @@ -160,8 +159,8 @@ class ShareonlineBiz(Hoster): f.close() hexd = h.hexdigest() if hexd == self.api_data["checksum"]: - return (True, 0) + return True, 0 else: - return (False, 1) + return False, 1 else: - return (True, 5) + return True, 5 diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index b45472747..32ab1972a 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -118,7 +118,7 @@ class UploadStationCom(Hoster): self.load(self.pyfile.url, post={"downloadLink" : "show"})
# This may either download our file or forward us to an error page
- self.log.debug("%s: Downloading file." % (self.__name__))
+ self.log.debug("%s: Downloading file." % self.__name__)
dl = self.download(self.pyfile.url, post={"download" : "normal"})
self.handleDownloadedFile()
@@ -145,7 +145,7 @@ class UploadStationCom(Hoster): def handleCaptchaErrors(self, response):
if UploadStationCom.CAPTCHA_WRONG_TOKEN in response:
- self.log.info("%s: Invalid captcha response, retrying." % (self.__name__))
+ self.log.info("%s: Invalid captcha response, retrying." % self.__name__)
self.invalidCaptcha()
self.retry()
else:
diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index 1f3889f0e..3fb2d4ba2 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -68,10 +68,9 @@ class UploadingCom(Hoster): self.download(url)
def handlePremium(self):
- postData = {}
- postData['action'] = 'get_link'
- postData['code'] = re.search('code: "(.*?)",', self.html[0]).group(1)
- postData['pass'] = 'undefined'
+ postData = {'action': 'get_link',
+ 'code': re.search('code: "(.*?)",', self.html[0]).group(1),
+ 'pass': 'undefined'}
self.html[2] = self.load('http://uploading.com/files/get/?JsHttpRequest=%d-xml' % timestamp(), post=postData)
url = re.search(r'"link"\s*:\s*"(.*?)"', self.html[2])
@@ -84,11 +83,10 @@ class UploadingCom(Hoster): self.code = re.search(r'name="code" value="(.*?)"', self.html[0]).group(1)
self.fileid = re.search(r'name="file_id" value="(.*?)"', self.html[0]).group(1)
- postData = {}
- postData['action'] = 'second_page'
- postData['code'] = self.code
- postData['file_id'] = self.fileid
-
+ postData = {'action': 'second_page',
+ 'code': self.code,
+ 'file_id': self.fileid}
+
self.html[1] = self.load(self.pyfile.url, post=postData)
wait_time = re.search(r'timead_counter">(\d+)<', self.html[1])
@@ -102,11 +100,10 @@ class UploadingCom(Hoster): self.wait()
- postData = {}
- postData['action'] = 'get_link'
- postData['code'] = self.code
- postData['pass'] = 'undefined'
-
+ postData = {'action': 'get_link',
+ 'code': self.code,
+ 'pass': 'undefined'}
+
if r'var captcha_src' in self.html[1]:
captcha_url = "http://uploading.com/general/captcha/download%s/?ts=%d" % (self.fileid, timestamp())
postData['captcha_code'] = self.decryptCaptcha(captcha_url)
diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index 7c81ccbe0..849748249 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -156,7 +156,7 @@ class Xdcc(Hoster): line = line.rstrip()
first = line.split()
- if(first[0] == "PING"):
+ if first[0] == "PING":
sock.send("PONG %s\r\n" % first[1])
if first[0] == "ERROR":
diff --git a/module/plugins/hoster/YourfilesTo.py b/module/plugins/hoster/YourfilesTo.py index 18f2d3edf..2c3656c95 100644 --- a/module/plugins/hoster/YourfilesTo.py +++ b/module/plugins/hoster/YourfilesTo.py @@ -57,7 +57,7 @@ class YourfilesTo(Hoster): """
url = re.search(r"var bla = '(.*?)';", self.html).group(1)
url = urllib.unquote(url.replace("http://http:/http://", "http://").replace("dumdidum", ""))
- return url;
+ return url
def get_file_name(self):
if self.html is None:
|