summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-01-12 17:10:25 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2012-01-12 17:10:25 +0100
commit0715dcafc11567e07b8f1c252bbd2b86065ae760 (patch)
treedbb00ef45362bb0f9fb0ae5cb3b1e7d65536a348 /module/plugins/hoster
parentUnrar fix (diff)
downloadpyload-0715dcafc11567e07b8f1c252bbd2b86065ae760.tar.xz
linkdecrypter api (thx flowlee), fix uloz.to, 1fichier - closed #493, #494, #496
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/DlFreeFr.py73
-rw-r--r--module/plugins/hoster/OneFichierCom.py130
-rw-r--r--module/plugins/hoster/UlozTo.py14
3 files changed, 33 insertions, 184 deletions
diff --git a/module/plugins/hoster/DlFreeFr.py b/module/plugins/hoster/DlFreeFr.py
deleted file mode 100644
index 8ab9dd8eb..000000000
--- a/module/plugins/hoster/DlFreeFr.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import re
-
-from module.plugins.Hoster import Hoster
-
-class DlFreeFr(Hoster):
- __name__ = "DlFreeFr"
- __type__ = "hoster"
- __pattern__ = r"http://dl\.free\.fr/([a-zA-Z0-9]+|getfile\.pl\?file=/[a-zA-Z0-9]+)$"
- __version__ = "0.1"
- __description__ = """dl.free.fr download hoster"""
- __author_name__ = ("the-razer")
- __author_mail__ = ("daniel_ AT gmx DOT net")
-
- def setup(self):
- self.html = None
- self.multiDL = False
-
- def process(self, pyfile):
-
- self.download_html()
-
- if not self.file_exists():
- self.log.debug(self.__name__+": File not yet available.")
- self.offline()
-
- pyfile.name = self.get_file_name()
-
- url = self.get_file_url()
- if url:
- self.download(url)
- else:
- self.offline()
-
- def download_html(self):
- self.html = self.load(self.pyfile.url, cookies=False)
-
- def file_exists(self):
- warnings = (r"Erreur 404 - Document non trouv",
- r"Fichier inexistant.",
- r"Le fichier demand&eacute; n'a pas &eacute;t&eacute; trouv&eacute;")
- expr = '(' + '|'.join(warnings) + ')'
- if re.search(expr, self.html) is not None:
- return False
- return True
-
- def get_file_url(self):
- self.log.debug(self.__name__+": Getting file URL")
- file_url_pattern = r'href="(?P<url>http://.*?)">T&eacute;l&eacute;charger ce fichier'
-
- m = re.search(file_url_pattern, self.html)
- if m is not None:
- url = m.group('url')
- self.log.debug(self.__name__+": File URL [%s]" % url)
- return url
- else:
- self.log.debug(self.__name__+": Error getting URL")
- return False
-
- def get_file_name(self):
- self.log.debug(self.__name__+": Getting file name")
-
- file_name_pattern = r"Fichier:</td>\s*<td.*>(?P<name>.*?)</td>"
- m = re.search(file_name_pattern, self.html)
-
- if m is not None:
- name = m.group('name').strip()
- self.log.debug(self.__name__+": File name [%s]" % name)
- return name
- else:
- self.log.debug(self.__name__+": Could not find filename")
diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py
index 3343c7c8c..16401891b 100644
--- a/module/plugins/hoster/OneFichierCom.py
+++ b/module/plugins/hoster/OneFichierCom.py
@@ -1,80 +1,29 @@
# -*- coding: utf-8 -*-
import re
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
-from module.plugins.Hoster import Hoster
-from module.network.RequestFactory import getURL
-
-
-def getInfo(urls):
- result = []
-
- for url in urls:
-
- # Get file info html
- id = re.match(OneFichierCom.__pattern__, url).group('id')
- url = 'http://%s.1fichier.com/en' % id # Force response in english
- html = getURL(url)
-
- # Offline?
- if re.search(OneFichierCom.FILE_OFFLINE_PATTERN, html):
- result.append((url, 0, 1, url))
- continue
-
- # Name
- for pattern in OneFichierCom.FILE_NAME_PATTERNS:
- m = re.search(pattern, html)
- if m is not None:
- name = m.group('name').strip()
-
- # Size
- m = re.search(OneFichierCom.FILE_SIZE_PATTERN, html)
- value = float(m.group('size'))
- units = m.group('units')[0].upper()
- pow = {'K' : 1, 'M' : 2, 'G' : 3}[units]
- size = int(value*1024**pow)
-
- # Return info
- result.append((name, size, 2, url))
-
- yield result
-
-
-class OneFichierCom(Hoster):
+class OneFichierCom(SimpleHoster):
__name__ = "OneFichierCom"
__type__ = "hoster"
- __pattern__ = r"http://(?P<id>[a-z0-9]+)\.1fichier\.com(?P<remain>.*)"
- __version__ = "0.3"
+ __pattern__ = r"(http://\w+\.((1fichier|d(es)?fichiers|pjointe)\.(com|fr|net|org)|(cjoint|mesfichiers|piecejointe|oi)\.(org|net)|tenvoi\.(com|org|net)|dl4free\.com|alterupload\.com|megadl.fr))"
+ __version__ = "0.4"
__description__ = """1fichier.com download hoster"""
- __author_name__ = ("fragonib")
- __author_mail__ = ("fragonib[AT]yahoo[DOT]es")
+ __author_name__ = ("fragonib", "the-razer", "zoidberg")
+ __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "daniel_ AT gmx DOT net", "zoidberg@mujmail.cz")
+
+ FILE_NAME_PATTERN = r'">File name :</th>[\t\r\n ]+<td>(?P<N>.*?)</td>'
+ FILE_SIZE_PATTERN = r'<th>File size :</th>\s+<td>(?P<S>[\d\.]*) (?P<U>\w+)</td>'
+ FILE_OFFLINE_PATTERN = r'The (requested)? file (could not be found|has been deleted)'
+ FILE_URL_REPLACEMENTS = [(r'(http://[^/]*).*', r'\1/en/')]
- FILE_NAME_PATTERNS = (
- r'">File name :</th>[\t\r\n ]+<td>(?P<name>.*?)</td>',
- r">Click here to download (?P<name>.*?)</a>",
- r"content=\"Download the file named (?P<name>.*?)\">",
- r"<title>Download the file\s*:\s*(?P<name>.*?)</title>"
- )
- FILE_SIZE_PATTERN = r"<th>File size :</th>\s+<td>(?P<size>[\d\.]*) (?P<units>\w+)</td>"
- DOWNLOAD_LINK_PATTERN = r'<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;\s+<a href="(?P<url>http://.*?)"'
- FILE_OFFLINE_PATTERN = r"(The requested file could not be found|The file may has been deleted by its owner)"
+ DOWNLOAD_LINK_PATTERN = r'<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;\s+<a href="(?P<url>http://.*?)"'
PASSWORD_PROTECTED_TOKEN = "protected by password"
WAITING_TOKEN = "Please wait a few seconds"
-
- def setup(self):
- self.html = None
- self.multiDL = False
-
- def process(self, pyfile):
-
- # Get main page (english version)
- url = self.getEnglishURL()
- self.html = self.load(url)
- self.handleErrors()
-
- # Get file info
- pyfile.name = self.getFileName()
- pyfile.size = self.getFileSize()
+
+ def handleFree(self):
+ if self.WAITING_TOKEN in self.html:
+ self.waitAndRetry(60)
# Check for protection
if self.isProtected():
@@ -86,33 +35,7 @@ class OneFichierCom(Hoster):
self.download(downloadLink)
# Check download
- self.handleDownloadedFile()
-
- def getEnglishURL(self):
- id = re.match(self.__pattern__, self.pyfile.url).group('id')
- url = 'http://%s.1fichier.com/en' % id
- return url
-
- def getFileName(self):
- for pattern in self.FILE_NAME_PATTERNS:
- m = re.search(pattern, self.html)
- if m is not None:
- name = m.group('name').strip()
- self.logDebug("Got file name [%s]" % name)
- return name
-
- def getFileSize(self):
- m = re.search(self.FILE_SIZE_PATTERN, self.html)
- if m is not None:
- size = float(m.group('size'))
- units = m.group('units')[0].upper()
- try:
- multiplier = 1024 ** {"K":1, "M":2, "G":3}[units]
- except KeyError:
- multiplier = 1
- bytes = int(size * multiplier)
- self.logDebug("Got file size of [%s] bytes" % bytes)
- return bytes
+ self.checkDownloadedFile()
def isProtected(self):
if self.PASSWORD_PROTECTED_TOKEN in self.html:
@@ -126,16 +49,15 @@ class OneFichierCom(Hoster):
url = m.group('url')
self.logDebug("Got file URL [%s]" % url)
return url
-
- def handleErrors(self):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None:
- self.logDebug("File not yet available.")
- self.offline()
- def handleDownloadedFile(self):
+ def checkDownloadedFile(self):
check = self.checkDownload({"wait": self.WAITING_TOKEN})
if check == "wait":
- wait = 5
- self.setWait(wait, True)
- self.wait()
- self.retry() \ No newline at end of file
+ self.waitAndRetry(60)
+
+ def waitAndRetry(self, wait_time):
+ self.setWait(wait_time, True)
+ self.wait()
+ self.retry()
+
+getInfo = create_getInfo(OneFichierCom) \ No newline at end of file
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py
index 9c9f502c3..6b699e39f 100644
--- a/module/plugins/hoster/UlozTo.py
+++ b/module/plugins/hoster/UlozTo.py
@@ -20,21 +20,21 @@ import re
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
def convertDecimalPrefix(m):
- # decimal prefixes used in filesize and traffic
- return "%s%s%s B" % (m.group(1), m.group(2).ljust(3, '0') if m.group(2) else '000', {'k': '', 'M': '000', 'G': '000000'}[m.group(3)])
+ # decimal prefixes used in filesize and traffic
+ return ("%%.%df" % {'k':3,'M':6,'G':9}[m.group(2)] % float(m.group(1))).replace('.','')
class UlozTo(SimpleHoster):
__name__ = "UlozTo"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/.*"
- __version__ = "0.80"
+ __version__ = "0.81"
__description__ = """uloz.to"""
__author_name__ = ("zoidberg")
FILE_NAME_PATTERN = r'<a share_url="[^&]*&amp;t=(?P<N>[^"]+)"'
#FILE_NAME_PATTERN = r'<h2 class="nadpis" style="margin-left:196px;"><a href="[^"]+">(?P<N>[^<]+)</a></h2>'
FILE_SIZE_PATTERN = r'<div class="info_velikost" style="top:-55px;">\s*<div>[^<]*\s+(?P<S>[0-9.]+\s[kMG]B)\s*</div>\s*</div>'
- FILE_SIZE_REPLACEMENTS = [('(\d+)\.?(\d+)? (\w)B', convertDecimalPrefix), (' ','')]
+ FILE_SIZE_REPLACEMENTS = [('([0-9.]+)\s([kMG])B', convertDecimalPrefix)]
FILE_OFFLINE_PATTERN = r'http://www.uloz.to/(neexistujici|smazano|nenalezeno)'
PASSWD_PATTERN = r'<input type="password" class="text" name="file_password" id="frmfilepasswordForm-file_password" />'
@@ -70,7 +70,7 @@ class UlozTo(SimpleHoster):
if re.search(self.VIPLINK_PATTERN, self.html):
self.html = self.load(pyfile.url, get={"disclaimer": "1"})
- if self.premium and self.checkCredit():
+ if self.premium and self.checkTrafficLeft():
self.handlePremium()
else:
self.handleFree()
@@ -97,7 +97,7 @@ class UlozTo(SimpleHoster):
self.log.debug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha + ' CAPTCHA_NB:' + captcha_nb)
# download and check
- self.download(parsed_url, post={"captcha_user": captcha, "captcha_nb": captcha_nb}, cookies=True, disposition = True)
+ self.download(parsed_url, post={"captcha_user": captcha, "captcha_nb": captcha_nb}, cookies=True)
self.doCheckDownload()
self.setStorage("captchaUser", captcha)
@@ -105,7 +105,7 @@ class UlozTo(SimpleHoster):
def handlePremium(self):
parsed_url = self.findDownloadURL(premium=True)
- self.download(parsed_url, disposition = True)
+ self.download(parsed_url)
self.doCheckDownload()
def findDownloadURL(self, premium=False):