diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-11-15 23:10:26 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-11-15 23:10:26 +0100 |
commit | 6891645614426aab6fae1561ba925f81b214e993 (patch) | |
tree | 20cd3963d4e05af10fa0eae2b899181b699bc128 /module | |
parent | improved plugin loader, import hook to always use newest plugin versions (diff) | |
download | pyload-6891645614426aab6fae1561ba925f81b214e993.tar.xz |
closed #420
Diffstat (limited to 'module')
-rw-r--r-- | module/PyPackage.py | 9 | ||||
-rw-r--r-- | module/Utils.py | 6 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 19 | ||||
-rw-r--r-- | module/plugins/crypter/SerienjunkiesOrg.py | 82 | ||||
-rw-r--r-- | module/web/templates/default/queue.html | 2 | ||||
-rw-r--r-- | module/web/webinterface.py | 4 |
6 files changed, 63 insertions, 59 deletions
diff --git a/module/PyPackage.py b/module/PyPackage.py index 991b18e54..f3be6c886 100644 --- a/module/PyPackage.py +++ b/module/PyPackage.py @@ -18,6 +18,7 @@ """ from module.PullEvents import UpdateEvent +from module.utils import save_path class PyPackage(): """ @@ -29,15 +30,17 @@ class PyPackage(): self.id = int(id) self.name = name - self.folder = folder + self._folder = folder self.site = site self.password = password self.queue = queue self.order = order - - self.setFinished = False + @property + def folder(self): + return save_path(self._folder) + def toDict(self): """ Returns a dictionary representation of the data. diff --git a/module/Utils.py b/module/Utils.py index 939baad96..36713b778 100644 --- a/module/Utils.py +++ b/module/Utils.py @@ -32,6 +32,12 @@ def removeChars(string, repl): elif type(string) == unicode: return string.translate(dict([(ord(s), None) for s in repl])) +def save_path(name): + #remove some chars + if os.name == 'nt': + return removeChars(name, '/\\?%*:|"<>') + else: + return removeChars(name, '/\\"') def save_join(*args): """ joins a path, encoding aware """ diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index 7a7ecd974..1abf02bbe 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -17,17 +17,11 @@ @author: RaNaN, spoob, mkaay """ -from time import time -from time import sleep - +from time import time, sleep from random import randint import os -from os import remove -from os import makedirs -from os import chmod -from os import stat -from os import name as os_name +from os import remove, makedirs, chmod, stat from os.path import exists, join if os.name != "nt": @@ -37,7 +31,7 @@ if os.name != "nt": from itertools import islice -from module.utils import save_join, fs_encode, removeChars +from module.utils import save_join, save_path, fs_encode def chunks(iterable, size): it = iter(iterable) @@ -495,12 +489,7 @@ class Plugin(Base): except Exception, e: self.log.warning(_("Setting User and Group failed: %s") % str(e)) - name = self.pyfile.name - if os_name == 'nt': - #delete illegal characters - name = removeChars(name, '/\\?%*:|"<>') - else: - name = removeChars(name, '/\\"') + name = save_path(self.pyfile.name) filename = join(location, fs_encode(name)) diff --git a/module/plugins/crypter/SerienjunkiesOrg.py b/module/plugins/crypter/SerienjunkiesOrg.py index 5b6295fe7..2178f5300 100644 --- a/module/plugins/crypter/SerienjunkiesOrg.py +++ b/module/plugins/crypter/SerienjunkiesOrg.py @@ -12,12 +12,14 @@ class SerienjunkiesOrg(Crypter): __type__ = "container" __pattern__ = r"http://.*?serienjunkies.org/.*?" __version__ = "0.31" - __config__ = [ ("preferredHoster", "str", "preferred hoster" , "RapidshareCom,UploadedTo,NetloadIn,FilefactoryCom,FreakshareNet,FilebaseTo,MegauploadCom,HotfileCom,DepositfilesCom,EasyshareCom,KickloadCom"), - ("changeName", "bool", "Take SJ.org episode name", "True") ] + __config__ = [("preferredHoster", "str", "preferred hoster", + "RapidshareCom,UploadedTo,NetloadIn,FilefactoryCom,FreakshareNet,FilebaseTo,MegauploadCom,HotfileCom,DepositfilesCom,EasyshareCom,KickloadCom") + , + ("changeName", "bool", "Take SJ.org episode name", "True")] __description__ = """serienjunkies.org Container Plugin""" __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - + def setup(self): self.hosterMap = { "rc": "RapidshareCom", @@ -33,26 +35,26 @@ class SerienjunkiesOrg(Crypter): "es": "EasyshareCom", "kl": "KickloadCom", "fc": "FilesonicCom", - } - self.hosterMapReverse = dict((v,k) for k, v in self.hosterMap.iteritems()) - + } + self.hosterMapReverse = dict((v, k) for k, v in self.hosterMap.iteritems()) + self.multiDL = False self.limitDL = 4 - + def getSJSrc(self, url): src = self.req.load(str(url)) if not src.find("Enter Serienjunkies") == -1: sleep(1) src = self.req.load(str(url)) return src - + def handleShow(self, url): src = self.getSJSrc(url) soup = BeautifulSoup(src) nav = soup.find("div", attrs={"id": "scb"}) for a in nav.findAll("a"): self.packages.append((unescape(a.text), [a["href"]], unescape(a.text))) - + def handleSeason(self, url): src = self.getSJSrc(url) soup = BeautifulSoup(src) @@ -63,7 +65,7 @@ class SerienjunkiesOrg(Crypter): self.log.debug("Preferred hoster: %s" % ", ".join(preferredHoster)) groups = {} gid = -1 - seasonName = unescape(soup.find("a", attrs={"rel":"bookmark"}).string) + seasonName = unescape(soup.find("a", attrs={"rel": "bookmark"}).string) for p in ps: if re.search("<strong>Dauer|<strong>Sprache|<strong>Format", str(p)): var = p.findAll("strong") @@ -115,37 +117,40 @@ class SerienjunkiesOrg(Crypter): if hmatch: break self.packages.append((package, links, package)) - + def handleEpisode(self, url): src = self.getSJSrc(url) - if not src.find("Du hast das Download-Limit überschritten! Bitte versuche es später nocheinmal.") == -1: + if not src.find( + "Du hast das Download-Limit überschritten! Bitte versuche es später nocheinmal.") == -1: self.fail(_("Downloadlimit reached")) else: soup = BeautifulSoup(src) form = soup.find("form") - packageName = soup.find("h1", attrs={"class":"wrap"}).text - captchaTag = soup.find(attrs={"src":re.compile("^/secure/")}) - if not captchaTag: - sleep(1) - self.retry() - - captchaUrl = "http://download.serienjunkies.org"+captchaTag["src"] - result = self.decryptCaptcha(str(captchaUrl), imgtype="png") - sinp = form.find(attrs={"name":"s"}) - - self.req.lastURL = str(url) - sj = self.load(str(url), post={'s': sinp["value"], 'c': result, 'action': "Download"}) - - soup = BeautifulSoup(sj) + h1 = soup.find("h1") + packageName = h1.text + if h1.get("class") == "wrap": + captchaTag = soup.find(attrs={"src": re.compile("^/secure/")}) + if not captchaTag: + sleep(1) + self.retry() + + captchaUrl = "http://download.serienjunkies.org" + captchaTag["src"] + result = self.decryptCaptcha(str(captchaUrl), imgtype="png") + sinp = form.find(attrs={"name": "s"}) + + self.req.lastURL = str(url) + sj = self.load(str(url), post={'s': sinp["value"], 'c': result, 'action': "Download"}) + + soup = BeautifulSoup(sj) rawLinks = soup.findAll(attrs={"action": re.compile("^http://download.serienjunkies.org/")}) - + if not len(rawLinks) > 0: sleep(1) self.retry() return - + self.correctCaptcha() - + links = [] for link in rawLinks: frameUrl = link["action"].replace("/go-", "/frame/go-") @@ -156,27 +161,28 @@ class SerienjunkiesOrg(Crypter): packageName = self.pyfile.package().name self.packages.append((packageName, links, packageName)) - + def handleOldStyleLink(self, url): sj = self.req.load(str(url)) soup = BeautifulSoup(sj) - form = soup.find("form", attrs={"action":re.compile("^http://serienjunkies.org")}) - captchaTag = form.find(attrs={"src":re.compile("^/safe/secure/")}) - captchaUrl = "http://serienjunkies.org"+captchaTag["src"] + form = soup.find("form", attrs={"action": re.compile("^http://serienjunkies.org")}) + captchaTag = form.find(attrs={"src": re.compile("^/safe/secure/")}) + captchaUrl = "http://serienjunkies.org" + captchaTag["src"] result = self.decryptCaptcha(str(captchaUrl)) url = form["action"] - sinp = form.find(attrs={"name":"s"}) - - self.req.load(str(url), post={'s': sinp["value"], 'c': result, 'dl.start': "Download"}, cookies=False, just_header=True) + sinp = form.find(attrs={"name": "s"}) + + self.req.load(str(url), post={'s': sinp["value"], 'c': result, 'dl.start': "Download"}, cookies=False, + just_header=True) decrypted = self.req.lastEffectiveURL if decrypted == str(url): self.retry() self.packages.append((self.pyfile.package().name, [decrypted], self.pyfile.package().folder)) - + def handleFrame(self, url): self.req.load(str(url)) return self.req.lastEffectiveURL - + def decrypt(self, pyfile): showPattern = re.compile("^http://serienjunkies.org/serie/(.*)/$") seasonPattern = re.compile("^http://serienjunkies.org/.*?/(.*)/$") diff --git a/module/web/templates/default/queue.html b/module/web/templates/default/queue.html index b11910bac..c88fa3568 100644 --- a/module/web/templates/default/queue.html +++ b/module/web/templates/default/queue.html @@ -28,6 +28,7 @@ document.addEvent("domready", function(){ {% endblock %}
{% block content %}
+{% autoescape true %}
<ul id="package-list" style="list-style: none; padding-left: 0; margin-top: -10px;">
{% for package in content %}
@@ -69,6 +70,7 @@ document.addEvent("domready", function(){ </li>
{% endfor %}
</ul>
+{% endautoescape %}
{% endblock %}
{% block hidden %}
diff --git a/module/web/webinterface.py b/module/web/webinterface.py index b531d0583..68724e3f6 100644 --- a/module/web/webinterface.py +++ b/module/web/webinterface.py @@ -79,7 +79,7 @@ loader = PrefixLoader({ 'js': FileSystemLoader(join(PROJECT_DIR, 'media', 'js')) }) -env = Environment(loader=loader, extensions=['jinja2.ext.i18n'], trim_blocks=True, auto_reload=False, +env = Environment(loader=loader, extensions=['jinja2.ext.i18n', 'jinja2.ext.autoescape'], trim_blocks=True, auto_reload=False, bytecode_cache=bcc) from filters import quotepath, path_make_relative, path_make_absolute, truncate, date @@ -118,8 +118,6 @@ web = GZipMiddleWare(web) if PREFIX: web = PrefixMiddleware(web, prefix=PREFIX) -#TODO: compress plugin, install(otfcompress) - import pyload_app import json_app import cnl_app |