From cea5a881e0f2f0c0a4dd7ac4090d4d415192496e Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 22 Jan 2012 11:26:37 +0000 Subject: Bring Oron's premium account handling to latest api. --- module/plugins/hoster/OronCom.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/plugins/hoster/OronCom.py b/module/plugins/hoster/OronCom.py index 0be840d76..120aa8ff4 100755 --- a/module/plugins/hoster/OronCom.py +++ b/module/plugins/hoster/OronCom.py @@ -129,13 +129,13 @@ class OronCom(Hoster): self.logError("error in parsing site") def handlePremium(self): - info = self.account.getAccountInfo(self.user, True) - self.logDebug("Traffic left: %s" % info['trafficleft']) + self.account.getAccountInfo(True) + self.logDebug("Traffic left: %s" % self.account.trafficleft) self.logDebug("File Size: %d" % int(self.pyfile.size / 1024)) - if int(self.pyfile.size / 1024) > info["trafficleft"]: + if int(self.pyfile.size / 1024) > self.account.trafficleft: self.logInfo(_("Not enough traffic left")) - self.account.empty(self.user) + self.account.empty() self.fail(_("Traffic exceeded")) post_url = "http://oron.com/" + self.file_id @@ -147,3 +147,4 @@ class OronCom(Hoster): self.html = self.load(post_url, post=post_dict, ref=False, decode=True).encode("utf-8") link = re.search('href="(.*?)" class="atitle"', self.html).group(1) self.download(link) + -- cgit v1.2.3 From 78ca4947e9d9df1b851fbe67cdde780ee3bf7cb6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 22 Jan 2012 12:41:39 +0000 Subject: Fix encoding/decoding issues while extracting RAR archives. --- module/plugins/internal/UnRar.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'module') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 9f57a9ad6..b3c2fe6af 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -19,11 +19,10 @@ import os import re -from os.path import join from glob import glob from subprocess import Popen, PIPE -from module.utils.fs import save_join, decode +from module.utils.fs import save_join, decode, fs_decode, fs_encode from module.plugins.internal.AbstractExtractor import AbtractExtractor, WrongPassword, ArchiveError, CRCError class UnRar(AbtractExtractor): @@ -39,7 +38,7 @@ class UnRar(AbtractExtractor): @staticmethod def checkDeps(): if os.name == "nt": - UnRar.CMD = join(pypath, "UnRAR.exe") + UnRar.CMD = safe_join(pypath, "UnRAR.exe") p = Popen([UnRar.CMD], stdout=PIPE, stderr=PIPE) p.communicate() else: @@ -66,9 +65,9 @@ class UnRar(AbtractExtractor): if match: #only add first parts if int(match[0][1]) == 1: - result.append((file, id)) + result.append((fs_decode(file), id)) else: - result.append((file, id)) + result.append((fs_decode(file), id)) return result @@ -80,7 +79,7 @@ class UnRar(AbtractExtractor): self.password = "" #save the correct password def checkArchive(self): - p = self.call_unrar("l", "-v", self.file) + p = self.call_unrar("l", "-v", fs_encode(self.file)) out, err = p.communicate() if self.re_wrongpwd.search(err): self.passwordProtected = True @@ -102,7 +101,7 @@ class UnRar(AbtractExtractor): def checkPassword(self, password): #at this point we can only verify header protected files if self.headerProtected: - p = self.call_unrar("l", "-v", self.file, password=password) + p = self.call_unrar("l", "-v", fs_encode(self.file), password=password) out, err = p.communicate() if self.re_wrongpwd.search(err): return False @@ -115,7 +114,7 @@ class UnRar(AbtractExtractor): # 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) + p = self.call_unrar(command, fs_encode(self.file), self.out, password=password) renice(p.pid, self.renice) progress(0) @@ -135,13 +134,13 @@ class UnRar(AbtractExtractor): def getDeleteFiles(self): - if ".part" in self.file: - return glob(re.sub("(?<=\.part)([01]+)", "*", self.file, re.IGNORECASE)) - return [self.file] + if ".part" in fs_encode(self.file): + return glob(re.sub("(?<=\.part)([01]+)", "*", fs_decode(self.file), re.IGNORECASE)) + return [fs_decode(self.file)] def listContent(self): command = "vb" if self.fullpath else "lb" - p = self.call_unrar(command, "-v", self.file, password=self.password) + p = self.call_unrar(command, "-v", fs_encode(self.file), password=self.password) out, err = p.communicate() if "Cannot open" in err: @@ -176,7 +175,7 @@ class UnRar(AbtractExtractor): #NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue call = [self.CMD, command] + args + list(xargs) - self.m.logDebug(" ".join(call)) + self.m.logDebug(" ".join([decode(a) for a in call])) p = Popen(call, stdout=PIPE, stderr=PIPE) @@ -188,4 +187,5 @@ def renice(pid, value): try: Popen(["renice", str(value), str(pid)], stdout=PIPE, stderr=PIPE, bufsize=-1) except: - print "Renice failed" \ No newline at end of file + print "Renice failed" + -- cgit v1.2.3