diff options
Diffstat (limited to 'module/plugins/hooks/SkipRev.py')
-rw-r--r-- | module/plugins/hooks/SkipRev.py | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 6ce1750d3..429737e94 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,9 +1,6 @@ # -*- coding: utf-8 -*- import re -import urllib - -from types import MethodType from module.PyFile import PyFile from module.plugins.internal.Addon import Addon @@ -12,7 +9,7 @@ from module.plugins.internal.Addon import Addon class SkipRev(Addon): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __status__ = "testing" __config__ = [("activated", "bool" , "Activated" , False ), @@ -28,17 +25,18 @@ class SkipRev(Addon): return pyfile.pluginclass.get_info(pyfile.url)['name'] - def _pyfile(self, link): + def _create_pyFile(self, data): + pylink = self.pyload.api._convertPyFile(data) return PyFile(self.pyload.files, - link.fid, - link.url, - link.name, - link.size, - link.status, - link.error, - link.plugin, - link.packageID, - link.order) + pylink.fid, + pylink.url, + pylink.name, + pylink.size, + pylink.status, + pylink.error, + pylink.plugin, + pylink.packageID, + pylink.order) def download_preparing(self, pyfile): @@ -47,14 +45,14 @@ class SkipRev(Addon): if pyfile.statusname is _("unskipped") or not name.endswith(".rev") or not ".part" in name: return - revtokeep = -1 if self.get_config('mode') == "Auto" else self.get_config('revtokeep') + revtokeep = -1 if self.config.get('mode') == "Auto" else self.config.get('revtokeep') if revtokeep: status_list = (1, 4, 8, 9, 14) if revtokeep < 0 else (1, 3, 4, 8, 9, 14) pyname = re.compile(r'%s\.part\d+\.rev$' % name.rsplit('.', 2)[0].replace('.', '\.')) - queued = [True for link in self.pyload.api.getPackageData(pyfile.package().id).links \ - if link.status not in status_list and pyname.match(link.name)].count(True) + queued = [True for fid, fdata in pyfile.package().getChildren().items() \ + if fdata['status'] not in status_list and pyname.match(fdata['name'])].count(True) if not queued or queued < revtokeep: #: Keep one rev at least in auto mode return @@ -63,26 +61,25 @@ class SkipRev(Addon): def download_failed(self, pyfile): - #: Check if pyfile is still "failed", maybe might has been restarted in meantime - if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): + if pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - revtokeep = -1 if self.get_config('mode') == "Auto" else self.get_config('revtokeep') + revtokeep = -1 if self.config.get('mode') == "Auto" else self.config.get('revtokeep') if not revtokeep: return pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) - for link in self.pyload.api.getPackageData(pyfile.package().id).links: - if link.status is 4 and pyname.match(link.name): - pylink = self._pyfile(link) + for fid, fdata in pyfile.package().getChildren().items(): + if fdata['status'] is 4 and pyname.match(fdata['name']): + pyfile_new = self._create_pyFile(fdata) if revtokeep > -1 or pyfile.name.endswith(".rev"): - pylink.setStatus("queued") + pyfile_new.setStatus("queued") else: - pylink.setCustomStatus(_("unskipped"), "queued") + pyfile_new.setCustomStatus(_("unskipped"), "queued") self.pyload.files.save() - pylink.release() + pyfile_new.release() return |