diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-19 00:36:50 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-07-19 00:36:50 +0200 |
commit | 876673902e5ea8d5336e144cad18d23fda613e94 (patch) | |
tree | 5b6ba792882eb110e822b2e64dda2b6a4f3722e9 | |
parent | improved hook loader (diff) | |
download | pyload-876673902e5ea8d5336e144cad18d23fda613e94.tar.xz |
cleanup
-rw-r--r-- | module/Api.py | 19 | ||||
-rw-r--r-- | module/common/packagetools.py | 64 | ||||
-rw-r--r-- | module/network/HTTPRequest.py | 1 | ||||
-rw-r--r-- | module/plugins/Container.py | 11 | ||||
-rw-r--r-- | module/plugins/Crypter.py | 17 | ||||
-rw-r--r-- | module/plugins/hoster/RealdebridCom.py | 5 | ||||
-rw-r--r-- | module/web/filters.py | 1 | ||||
-rw-r--r-- | module/web/pyload_app.py | 2 |
8 files changed, 48 insertions, 72 deletions
diff --git a/module/Api.py b/module/Api.py index 648174a1f..be72ee359 100644 --- a/module/Api.py +++ b/module/Api.py @@ -24,10 +24,11 @@ from time import time from remote.thriftbackend.thriftgen.pyload.ttypes import * from remote.thriftbackend.thriftgen.pyload.Pyload import Iface -from module.PyFile import PyFile -from module.database.UserDatabase import ROLE -from module.utils import freeSpace, compare_time -from module.common.packagetools import parseNames +from PyFile import PyFile +from database.UserDatabase import ROLE +from utils import freeSpace, compare_time +from common.packagetools import parseNames +from network.RequestFactory import getURL class Api(Iface): @@ -265,8 +266,13 @@ class Api(Iface): return pid def parseURLs(self, html): - #TODO implement - pass + html = getURL(html) + + # TODO parse + urls = [] + + return self.checkURLs(urls) + def checkURLs(self, urls): data = self.core.pluginManager.parseUrls(urls) @@ -318,7 +324,6 @@ class Api(Iface): return OnlineCheck(rid, result) - def generatePackages(self, links): """ Parses links, generates packages names only from urls diff --git a/module/common/packagetools.py b/module/common/packagetools.py index 9912a3f95..200f29c2f 100644 --- a/module/common/packagetools.py +++ b/module/common/packagetools.py @@ -5,8 +5,6 @@ import re from urlparse import urlparse -from ..remote.thriftbackend.thriftgen.pyload.ttypes import OnlineStatus - def matchFirst(string, *args): """ matches against list of regexp and returns first match""" for patternlist in args: @@ -95,49 +93,29 @@ def parseNames(files): name = name.replace(r.group(0), "") patternMatch = True - # remove extension - index = name.rfind(".") - if index <= 0: - index = name.rfind("_") - if index > 0: - length = len(name) - index - if length <= 4: - name = name[:-length] - - # remove endings like . _ - - r = pat3.search(name) - if r is not None: - name = r.group(1) - - # replace . and _ with space - name = name.replace(".", " ") - name = name.replace("_", " ") - - name = name.strip() - - # special checks if no extension pattern matched - if patternMatch is False: - # checks if name could be a hash - if file.find("file/" + name) >= 0: - name = "" - - if file.find("files/" + name) >= 0: - name = "" - - r = re.search("^[0-9]+$", name, re.I) + # additional checks if extension pattern matched + if patternMatch: + # remove extension + index = name.rfind(".") + if index <= 0: + index = name.rfind("_") + if index > 0: + length = len(name) - index + if length <= 4: + name = name[:-length] + + # remove endings like . _ - + r = pat3.search(name) if r is not None: - name = "" + name = r.group(1) - r = re.search("^[0-9a-z]+$", name, re.I) - if r is not None: - r1 = re.search("[0-9]+.+[0-9]", name) - r2 = re.search("[a-z]+.+[a-z]+", name, re.I) - if r1 is not None and r2 is not None: - name = "" - - path = urlparse(file).path - if path == "/" + name or path == "/" + name + ".htm": - name = "" + # replace . and _ with space + name = name.replace(".", " ") + name = name.replace("_", " ") + + name = name.strip() + else: + name = "" # fallback: package by hoster if not name: diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index bd04ac3cf..4dd41674c 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -24,7 +24,6 @@ from urllib import quote, urlencode from logging import getLogger from cStringIO import StringIO -from module.utils import html_unescape from module.plugins.Plugin import Abort def myquote(url): diff --git a/module/plugins/Container.py b/module/plugins/Container.py index 8d195b4a3..c233d3710 100644 --- a/module/plugins/Container.py +++ b/module/plugins/Container.py @@ -32,9 +32,7 @@ class Container(Crypter): __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - - - #---------------------------------------------------------------------- + def preprocessing(self, thread): """prepare""" @@ -48,13 +46,12 @@ class Container(Crypter): self.createPackages() - - #---------------------------------------------------------------------- + def loadToDisk(self): """loads container to disk if its stored remotely and overwrite url, or check existent on several places at disk""" - if self.pyfile.url.startswith("http://"): + if self.pyfile.url.startswith("http"): self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] content = self.load(self.pyfile.url) self.pyfile.url = join(self.config["general"]["download_folder"], self.pyfile.name) @@ -71,8 +68,6 @@ class Container(Crypter): self.fail(_("File not exists.")) - - #---------------------------------------------------------------------- def deleteTmp(self): if self.pyfile.name.startswith("tmp_"): remove(self.pyfile.url) diff --git a/module/plugins/Crypter.py b/module/plugins/Crypter.py index 9c56eb91b..d1549fe80 100644 --- a/module/plugins/Crypter.py +++ b/module/plugins/Crypter.py @@ -19,8 +19,6 @@ from module.plugins.Plugin import Plugin -from os.path import join, exists, basename - class Crypter(Plugin): __name__ = "Crypter" __version__ = "0.1" @@ -33,15 +31,16 @@ class Crypter(Plugin): def __init__(self, pyfile): Plugin.__init__(self, pyfile) - """ Put all packages here. It's a list of tuples like: - ( name, [list of links], folder ) """ + #: Put all packages here. It's a list of tuples like: ( name, [list of links], folder ) self.packages = [] + + #: List of urls, pyLoad will generate packagenames + self.urls = [] self.multiDL = True self.limitDL = 0 - self.setup() - #---------------------------------------------------------------------- + def preprocessing(self, thread): """prepare""" self.setup() @@ -54,8 +53,7 @@ class Crypter(Plugin): def decrypt(self, pyfile): raise NotImplementedError - - #---------------------------------------------------------------------- + def createPackages(self): """ create new packages from self.packages """ for pack in self.packages: @@ -68,4 +66,7 @@ class Crypter(Plugin): if self.pyfile.package().password: self.core.api.setPackageData(pid, {"password": self.pyfile.package().password}) + + if self.urls: + self.core.api.generateAndAddPackages(self.urls) diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index 2d35108bc..c23e19b4d 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -4,13 +4,12 @@ import re
from urllib import quote, unquote
from random import randrange
-from time import sleep
from module.plugins.Hoster import Hoster
class RealdebridCom(Hoster):
__name__ = "RealdebridCom"
- __version__ = "0.4"
+ __version__ = "0.41"
__type__ = "hoster"
__pattern__ = r"https?://.*real-debrid\..*"
@@ -80,5 +79,5 @@ class RealdebridCom(Hoster): if check == "error":
#usual this download can safely be retried
- self.retry(reason="An error occured while generating link.")
+ self.retry(reason="An error occured while generating link.", wait_time=60)
diff --git a/module/web/filters.py b/module/web/filters.py index 1b10f7cb4..13b8345fc 100644 --- a/module/web/filters.py +++ b/module/web/filters.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import os from os.path import abspath, commonprefix, join -from time import strftime, mktime, gmtime quotechar = "::/" diff --git a/module/web/pyload_app.py b/module/web/pyload_app.py index 22003da43..923d5d756 100644 --- a/module/web/pyload_app.py +++ b/module/web/pyload_app.py @@ -36,7 +36,7 @@ from utils import render_to_response, parse_permissions, parse_userdata, \ from filters import relpath, unquotepath -from module.utils import formatSize, decode, fs_decode, freeSpace +from module.utils import formatSize, decode, fs_decode # Helper |