summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Christopher <4Christopher@gmx.de> 2013-04-13 21:06:34 +0200
committerGravatar Christopher <4Christopher@gmx.de> 2013-04-13 21:06:34 +0200
commit0b2e9ddcafed94fb780ea8d07ea23f6f14612830 (patch)
tree36f60fb82cc61cf17947cbe7dcbbc719994e234c /module/plugins/internal
parentCleanup. (diff)
parentMBLinkInfo: updated pattern (diff)
downloadpyload-0b2e9ddcafed94fb780ea8d07ea23f6f14612830.tar.xz
Merge branch 'stable' of git://github.com/pyload/pyload into stable
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/SimpleCrypter.py10
-rw-r--r--module/plugins/internal/SimpleHoster.py4
-rw-r--r--module/plugins/internal/UnRar.py34
3 files changed, 35 insertions, 13 deletions
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index b8942c724..c9e350e86 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -18,18 +18,20 @@
"""
import re
+
from module.plugins.Crypter import Crypter
+
class SimpleCrypter(Crypter):
__name__ = "SimpleCrypter"
- __version__ = "0.03"
+ __version__ = "0.04"
__pattern__ = None
__type__ = "crypter"
__description__ = """Base crypter plugin"""
__author_name__ = ("stickell", "zoidberg")
__author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz")
"""
- These patterns should be defined by each hoster:
+ These patterns should be defined by each crypter:
LINK_PATTERN: group(1) must be a download link
example: <div class="link"><a href="(http://speedload.org/\w+)
@@ -39,7 +41,7 @@ class SimpleCrypter(Crypter):
"""
def decrypt(self, pyfile):
- self.html = self.load(pyfile.url)
+ self.html = self.load(pyfile.url, decode=True)
package_name, folder_name = self.getPackageNameAndFolder()
@@ -55,7 +57,7 @@ class SimpleCrypter(Crypter):
if hasattr(self, 'TITLE_PATTERN'):
m = re.search(self.TITLE_PATTERN, self.html)
if m:
- name = folder = m.group('title')
+ name = folder = m.group('title').strip()
self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder))
return name, folder
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index cfc9f2b43..69ed57ff8 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -155,8 +155,8 @@ class SimpleHoster(Hoster):
"""
These patterns should be defined by each hoster:
FILE_INFO_PATTERN = r'(?P<N>file_name) (?P<S>file_size) (?P<U>units)'
- or FILE_NAME_INFO = r'(?P<N>file_name)'
- and FILE_SIZE_INFO = r'(?P<S>file_size) (?P<U>units)'
+ or FILE_NAME_PATTERN = r'(?P<N>file_name)'
+ and FILE_SIZE_PATTERN = r'(?P<S>file_size) (?P<U>units)'
FILE_OFFLINE_PATTERN = r'File (deleted|not found)'
TEMP_OFFLINE_PATTERN = r'Server maintainance'
"""
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index 240dc0233..da8e7cf3d 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -22,18 +22,20 @@ import re
from os.path import join
from glob import glob
from subprocess import Popen, PIPE
+from string import digits
from module.utils import save_join, decode
from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError
class UnRar(AbtractExtractor):
__name__ = "UnRar"
- __version__ = "0.11"
+ __version__ = "0.13"
# there are some more uncovered rar formats
- re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$")
+ re_splitfile = re.compile(r"(.*)\.part(\d+)\.rar$", re.I)
+ re_partfiles = re.compile(r".*\.(rar|r[0-9]+)", re.I)
re_filelist = re.compile(r"(.+)\s+(\d+)\s+(\d+)\s+")
- re_wrongpwd = re.compile("(Corrupt file or wrong password|password incorrect)")
+ re_wrongpwd = re.compile("(Corrupt file or wrong password|password incorrect)", re.I)
CMD = "unrar"
@staticmethod
@@ -113,15 +115,31 @@ class UnRar(AbtractExtractor):
def extract(self, progress, password=None):
command = "x" if self.fullpath else "e"
- # popen thinks process is still alive (just like pexpect) - very strange behavior
- # so for now progress can not be determined correctly
p = self.call_unrar(command, self.file, self.out, password=password)
renice(p.pid, self.renice)
progress(0)
- out, err = p.communicate() #wait for process
+ progressstring = ""
+ while True:
+ c = p.stdout.read(1)
+ # quit loop on eof
+ if not c:
+ break
+ # reading a percentage sign -> set progress and restart
+ if c == '%':
+ progress(int(progressstring))
+ progressstring = ""
+ # not reading a digit -> therefore restart
+ elif c not in digits:
+ progressstring = ""
+ # add digit to progressstring
+ else:
+ progressstring = progressstring + c
progress(100)
+ # retrieve stderr
+ err = p.stderr.read()
+
if "CRC failed" in err and not password and not self.passwordProtected:
raise CRCError
elif "CRC failed" in err:
@@ -139,7 +157,9 @@ class UnRar(AbtractExtractor):
def getDeleteFiles(self):
if ".part" in self.file:
return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE))
- return [self.file]
+ # get files which matches .r* and filter unsuited files out
+ parts = glob(re.sub(r"(?<=\.r)ar$", "*", self.file, re.IGNORECASE))
+ return filter(lambda x: self.re_partfiles.match(x), parts)
def listContent(self):
command = "vb" if self.fullpath else "lb"