From b18abd1a3b61bdffc159e87312d527bc71216087 Mon Sep 17 00:00:00 2001 From: flubshi Date: Tue, 13 Jan 2015 23:20:26 +0100 Subject: Host FreeWayMe: Improve error handling, try five times This update allows 4 additional attempts if download fails. --- module/plugins/hoster/FreeWayMe.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/module/plugins/hoster/FreeWayMe.py b/module/plugins/hoster/FreeWayMe.py index ffc8115d3..6d08e1f8d 100644 --- a/module/plugins/hoster/FreeWayMe.py +++ b/module/plugins/hoster/FreeWayMe.py @@ -6,7 +6,7 @@ from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo class FreeWayMe(MultiHoster): __name__ = "FreeWayMe" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'https://(?:www\.)?free-way\.me/.+' @@ -24,13 +24,30 @@ class FreeWayMe(MultiHoster): def handlePremium(self, pyfile): user, data = self.account.selectAccount() - self.download("https://www.free-way.me/load.php", + for _i in xrange(5): + # try it five times + header = self.load("https://www.free-way.me/load.php", get={'multiget': 7, 'url' : pyfile.url, 'user' : user, 'pw' : self.account.getAccountData(user)['password'], - 'json' : ""}, - disposition=True) + 'json' : ""}, just_header=True) + if "location" in header: + #download + self.logInfo("Download: " + header['location']) + headers = self.load(header['location'],just_header=True) + if headers['code'] == 500: + #error on 2nd stage + self.logInfo("Free-Way Error [stage2]") + # todo: handle errors + else: + # seems to work.. + self.download(header['location']) + break + else: + #error page first stage + self.logInfo("Free-Way Error [stage1]") + # todo: handle errors getInfo = create_getInfo(FreeWayMe) -- cgit v1.2.3