From 55c14d4fe3df6719e18eaea940e5dca8e780bd5a Mon Sep 17 00:00:00 2001 From: hagg Date: Mon, 10 Sep 2012 14:59:13 +0200 Subject: BasePlugin: handle 404s by setting status to 'offline' --- module/plugins/hoster/BasePlugin.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index f1e3006d0..1ac33931f 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -12,10 +12,10 @@ class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" __pattern__ = r"^unmatchable$" - __version__ = "0.15" + __version__ = "0.151" __description__ = """Base Plugin when any other didnt fit""" - __author_name__ = ("RaNaN") - __author_mail__ = ("RaNaN@pyload.org") + __author_name__ = ("RaNaN", 'hagg') + __author_mail__ = ("RaNaN@pyload.org", '') def setup(self): self.chunkLimit = -1 @@ -54,6 +54,8 @@ class BasePlugin(Hoster): self.req.addAuth(pwd) self.downloadFile(pyfile) + elif e.code == 404: + self.offline() else: raise @@ -65,6 +67,10 @@ class BasePlugin(Hoster): header = self.load(pyfile.url, just_header = True) #self.logDebug(header) + # self.load does not raise a BadHeader on 404 responses, do it here + if header.has_key('code') and header['code'] == 404: + raise BadHeader(404) + if 'location' in header: self.logDebug("Location: " + header['location']) url = unquote(header['location']) @@ -86,4 +92,4 @@ class BasePlugin(Hoster): if not name: name = url pyfile.name = name self.logDebug("Filename: %s" % pyfile.name) - self.download(url, disposition=True) \ No newline at end of file + self.download(url, disposition=True) -- cgit v1.2.3