diff options
Diffstat (limited to 'module/plugins/hoster/WebshareCz.py')
-rw-r--r-- | module/plugins/hoster/WebshareCz.py | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index e3424fc21..c898d23ab 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -9,51 +9,49 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class WebshareCz(SimpleHoster): __name__ = "WebshareCz" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.18" - __pattern__ = r'https?://(?:www\.)?webshare\.cz/(?:#/)?file/(?P<ID>\w+)' + __pattern__ = r'https?://(?:www\.)?(en\.)?webshare\.cz/(?:#/)?file/(?P<ID>\w+)' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """WebShare.cz hoster plugin""" __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("rush", "radek.senfeld@gmail.com")] + __authors__ = [("stickell", "l.stickell@yahoo.it "), + ("rush" , "radek.senfeld@gmail.com")] @classmethod - def getInfo(cls, url="", html=""): - info = super(WebshareCz, self).getInfo(url, html) + def apiInfo(cls, url): + info = super(WebshareCz, cls).apiInfo(url) - if url: - info['pattern'] = re.match(cls.__pattern__, url).groupdict() + info['pattern'] = re.match(cls.__pattern__, url).groupdict() - api_data = getURL("https://webshare.cz/api/file_info/", - post={'ident': info['pattern']['ID']}, - decode=True) + api_data = getURL("https://webshare.cz/api/file_info/", + post={'ident': info['pattern']['ID'], 'wst': ""}, + decode=True) - if 'File not found' in api_data: - info['status'] = 1 - else: - info["status"] = 2 - info['name'] = re.search('<name>(.+)</name>', api_data).group(1) or info['name'] - info['size'] = re.search('<size>(.+)</size>', api_data).group(1) or info['size'] + if not re.search(r'<status>OK', api_data): + info['status'] = 1 + else: + info['status'] = 2 + info['name'] = re.search(r'<name>(.+?)<', api_data).group(1) + info['size'] = re.search(r'<size>(.+?)<', api_data).group(1) return info def handleFree(self, pyfile): - wst = self.account.infos['wst'] if self.account and 'wst' in self.account.infos else "" + wst = self.account.getAccountData(self.user).get('wst', None) if self.account else None - api_data = getURL('https://webshare.cz/api/file_link/', + api_data = getURL("https://webshare.cz/api/file_link/", post={'ident': self.info['pattern']['ID'], 'wst': wst}, decode=True) self.logDebug("API data: " + api_data) m = re.search('<link>(.+)</link>', api_data) - if m is None: - self.error(_("Unable to detect direct link")) - - self.link = m.group(1) + if m: + self.link = m.group(1) def handlePremium(self, pyfile): |