diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-26 17:04:38 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-26 17:04:38 +0100 |
commit | ccb6aaee9d987b56faf19fb48dd06a04ff8ca721 (patch) | |
tree | 6a385417ff77f3ed17329e2d606f80b673bdb3c0 /pyload/plugin/addon/SkipRev.py | |
parent | Prepare to merging (diff) | |
parent | Tiny code cosmetics (diff) | |
download | pyload-ccb6aaee9d987b56faf19fb48dd06a04ff8ca721.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/accounts/Keep2ShareCc.py
module/plugins/captcha/OCR.py
module/plugins/captcha/captcha.py
module/plugins/crypter/DailymotionBatch.py
module/plugins/crypter/DailymotionComFolder.py
module/plugins/crypter/YoutubeBatch.py
module/plugins/crypter/YoutubeComFolder.py
module/plugins/internal/CaptchaService.py
pyload/plugin/Extractor.py
pyload/plugin/OCR.py
pyload/plugin/account/DebridItaliaCom.py
pyload/plugin/account/MegaRapidCz.py
pyload/plugin/account/NoPremiumPl.py
pyload/plugin/account/RapideoPl.py
pyload/plugin/addon/AndroidPhoneNotify.py
pyload/plugin/addon/Checksum.py
pyload/plugin/addon/ClickAndLoad.py
pyload/plugin/addon/DeleteFinished.py
pyload/plugin/addon/DownloadScheduler.py
pyload/plugin/addon/ExternalScripts.py
pyload/plugin/addon/ExtractArchive.py
pyload/plugin/addon/HotFolder.py
pyload/plugin/addon/IRCInterface.py
pyload/plugin/addon/JustPremium.py
pyload/plugin/addon/MergeFiles.py
pyload/plugin/addon/MultiHome.py
pyload/plugin/addon/RestartFailed.py
pyload/plugin/addon/RestartSlow.py
pyload/plugin/addon/SkipRev.py
pyload/plugin/addon/UnSkipOnFail.py
pyload/plugin/addon/UpdateManager.py
pyload/plugin/addon/WindowsPhoneNotify.py
pyload/plugin/crypter/DDLMusicOrg.py
pyload/plugin/crypter/DailymotionBatch.py
pyload/plugin/crypter/DevhostSt.py
pyload/plugin/crypter/EmbeduploadCom.py
pyload/plugin/crypter/MultiloadCz.py
pyload/plugin/crypter/YoutubeBatch.py
pyload/plugin/extractor/SevenZip.py
pyload/plugin/extractor/UnRar.py
pyload/plugin/extractor/UnZip.py
pyload/plugin/hook/BypassCaptcha.py
pyload/plugin/hook/Captcha9Kw.py
pyload/plugin/hook/CaptchaBrotherhood.py
pyload/plugin/hook/DeathByCaptcha.py
pyload/plugin/hook/ExpertDecoders.py
pyload/plugin/hook/ImageTyperz.py
pyload/plugin/hook/XFileSharingPro.py
pyload/plugin/hoster/AlldebridCom.py
pyload/plugin/hoster/CzshareCom.py
pyload/plugin/hoster/EuroshareEu.py
pyload/plugin/hoster/FastixRu.py
pyload/plugin/hoster/FastshareCz.py
pyload/plugin/hoster/GooIm.py
pyload/plugin/hoster/MediafireCom.py
pyload/plugin/hoster/MegaDebridEu.py
pyload/plugin/hoster/NitroflareCom.py
pyload/plugin/hoster/OverLoadMe.py
pyload/plugin/hoster/PremiumTo.py
pyload/plugin/hoster/PremiumizeMe.py
pyload/plugin/hoster/RapidgatorNet.py
pyload/plugin/hoster/RealdebridCom.py
pyload/plugin/hoster/SimplyPremiumCom.py
pyload/plugin/hoster/SimplydebridCom.py
pyload/plugin/hoster/SmoozedCom.py
pyload/plugin/hoster/SoundcloudCom.py
pyload/plugin/hoster/UlozTo.py
pyload/plugin/hoster/UploadableCh.py
pyload/plugin/hoster/UploadedTo.py
pyload/plugin/hoster/UploadheroCom.py
pyload/plugin/hoster/VeehdCom.py
pyload/plugin/hoster/VimeoCom.py
pyload/plugin/hoster/ZeveraCom.py
pyload/plugin/hoster/ZippyshareCom.py
pyload/plugin/internal/BasePlugin.py
pyload/plugin/internal/MultiHoster.py
pyload/plugin/internal/SimpleDereferer.py
pyload/plugin/internal/SimpleHoster.py
pyload/plugin/internal/XFSHoster.py
pyload/plugin/ocr/GigasizeCom.py
pyload/plugin/ocr/LinksaveIn.py
pyload/plugin/ocr/NetloadIn.py
pyload/plugin/ocr/ShareonlineBiz.py
Diffstat (limited to 'pyload/plugin/addon/SkipRev.py')
-rw-r--r-- | pyload/plugin/addon/SkipRev.py | 81 |
1 files changed, 50 insertions, 31 deletions
diff --git a/pyload/plugin/addon/SkipRev.py b/pyload/plugin/addon/SkipRev.py index efc96cb7b..157b55bbd 100644 --- a/pyload/plugin/addon/SkipRev.py +++ b/pyload/plugin/addon/SkipRev.py @@ -1,35 +1,46 @@ # -*- coding: utf-8 -*- +import re + from types import MethodType from urllib import unquote from urlparse import urlparse -from pyload.datatype.File import PyFile -from pyload.plugin.Addon import Addon -from pyload.plugin.Plugin import SkipDownload - - -def _setup(self): - self.pyfile.plugin._setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) +from module.PyFile import PyFile +from module.plugins.Hook import Hook +from module.plugins.Plugin import SkipDownload -class SkipRev(Addon): +class SkipRev(Hook): __name__ = "SkipRev" - __type__ = "addon" - __version__ = "0.25" + __type__ = "hook" + __version__ = "0.29" - __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] + __config__ = [("mode" , "Auto;Manual", "Choose recovery archives to skip" , "Auto"), + ("revtokeep", "int" , "Number of recovery archives to keep for package", 0 )] - __description__ = """Skip files ending with extension rev""" + __description__ = """Skip recovery archives (.rev)""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - def _pyname(self, pyfile): - if hasattr(pyfile.pluginmodule, "getInfo"): - return getattr(pyfile.pluginmodule, "getInfo")([pyfile.url]).next()[0] + interval = 0 #@TODO: Remove in 0.4.10 + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + + @staticmethod + def _setup(self): + self.pyfile.plugin._setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) + + + def _name(self, pyfile): + if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 + return pyfile.pluginmodule.getInfo([pyfile.url]).next()[0] else: self.logWarning("Unable to grab file name") return urlparse(unquote(pyfile.url)).path.split('/')[-1] @@ -49,44 +60,52 @@ class SkipRev(Addon): def downloadPreparing(self, pyfile): - if pyfile.statusname is "unskipped" or not self._pyname(pyfile).endswith(".rev"): + name = self._name(pyfile) + + if pyfile.statusname is _("unskipped") or not name.endswith(".rev") or not ".part" in name: return - tokeep = self.getConfig("tokeep") + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if tokeep: - status_list = (1, 4, 8, 9, 14) if tokeep < 0 else (1, 3, 4, 8, 9, 14) + 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.core.api.getPackageData(pyfile.package().id).links \ - if link.name.endswith(".rev") and link.status not in status_list].count(True) + if link.status not in status_list and pyname.match(link.name)].count(True) - if not queued or queued < tokeep: #: keep one rev at least in auto mode + if not queued or queued < revtokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin + + if not hasattr(pyfile.plugin, "_setup"): + # Work-around: inject status checker inside the preprocessing routine of the plugin + pyfile.plugin._setup = pyfile.plugin.setup + pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) def downloadFailed(self, pyfile): #: Check if pyfile is still "failed", # maybe might has been restarted in meantime - if pyfile.status != 8: + if pyfile.status != 8 or pyfile.name.rsplit('.', 1)[-1].strip() not in ("rar", "rev"): return - tokeep = self.getConfig("tokeep") + revtokeep = -1 if self.getConfig('mode') == "Auto" else self.getConfig('revtokeep') - if not tokeep: + if not revtokeep: return + pyname = re.compile(r'%s\.part\d+\.rev$' % pyfile.name.rsplit('.', 2)[0].replace('.', '\.')) + for link in self.core.api.getPackageData(pyfile.package().id).links: - if link.status is 4 and link.name.endswith(".rev"): + if link.status is 4 and pyname.match(link.name): pylink = self._pyfile(link) - if tokeep > -1 or pyfile.name.endswith(".rev"): + if revtokeep > -1 or pyfile.name.endswith(".rev"): pylink.setStatus("queued") else: - pylink.setCustomStatus("unskipped", "queued") + pylink.setCustomStatus(_("unskipped"), "queued") self.core.files.save() pylink.release() |