# -*- coding: utf-8 -*-
from __future__ import with_statement
import re
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
from module.common.json_layer import json_loads
from module.network.RequestFactory import getURL
from module.utils import parseFileSize
def getInfo(urls):
reg = r"
(http://(?:www\.)?fileserve\.com/file/.+(?:[\r\n\t]+)?) | [\r\n\t ]+(.*?) | [\r\n\t ]+(.*?) | [\r\n\t ]+(Available|Not available)(?:\ )?(?:)"
url = "http://fileserve.com/link-checker.php"
#get all at once, shows strange behavior otherwise
html = getURL(url, post={"submit": "Check Urls", "urls": "\n".join(urls)}, decode=True)
match = re.findall(reg, html, re.IGNORECASE + re.MULTILINE)
result = []
for url, name, size, status in match:
result.append((name, parseFileSize(size), 1 if status == "Not available" else 2, url))
yield result
class FileserveCom(Hoster):
__name__ = "FileserveCom"
__type__ = "hoster"
__pattern__ = r"http://(www\.)?fileserve\.com/file/[a-zA-Z0-9]+"
__version__ = "0.43"
__description__ = """Fileserve.Com File Download Hoster"""
__author_name__ = ("jeix", "mkaay", "paul king")
__author_mail__ = ("jeix@hasnomail.de", "mkaay@mkaay.de", "")
FILE_ID_KEY = r"fileserve\.com/file/(?P\w+)"
FILE_CHECK_KEY = r"http://www.fileserve\.com/file/(?P\w+) | .*?(?P.*?) | .*?(?P.*?) (?P.B) | .*?(?P.*?) | "
CAPTCHA_KEY_PATTERN = r"var reCAPTCHA_publickey='(?P.*?)';"
LONG_WAIT_PATTERN = r"You need to wait (\d+) seconds to start another download"
def init(self):
if not self.premium:
self.multiDL = False
self.resumeDownload = False
self.chunkLimit = 1
def process(self, pyfile):
self.checkFile()
if self.account and self.premium:
self.handlePremium()
else:
self.handleFree()
def checkFile(self):
self.file_id = re.search(self.FILE_ID_KEY, self.pyfile.url).group("id")
self.logDebug("file id is %s" % self.file_id)
self.pyfile.url = "http://www.fileserve.com/file/" + self.file_id
linkCheck = self.load("http://www.fileserve.com/link-checker.php",
post={"urls": self.pyfile.url},
ref=False, cookies=False if self.account else True, decode=True)
linkMatch = re.search(self.FILE_CHECK_KEY, linkCheck.replace("\r\n", ""))
if not linkMatch:
self.logDebug("couldn't extract file status")
self.offline()
if linkMatch.group("online").find("Available"):
self.logDebug("file is not available : %s" % linkMatch.group("online"))
self.offline()
self.pyfile.name = linkMatch.group("name")
def handlePremium(self):
# TODO: handle login timeouts
self.download(self.pyfile.url)
check = self.checkDownload({"login": ' |