summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
authorGravatar fragonib <devnull@localhost> 2010-10-19 23:40:49 +0200
committerGravatar fragonib <devnull@localhost> 2010-10-19 23:40:49 +0200
commit3e6aa7db2869e8482bea8cc337b3587964c7a5b1 (patch)
tree8a3b42602dfb479fd5d4bc61c6deb310ff419729 /module/plugins/hoster
parentDLC for python 2.7, password in add package dialog (diff)
downloadpyload-3e6aa7db2869e8482bea8cc337b3587964c7a5b1.tar.xz
OneFichierCom hoster plugin regex bug fixes
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/OneFichierCom.py38
1 files changed, 17 insertions, 21 deletions
diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py
index ce7697943..ffb89a5f6 100644
--- a/module/plugins/hoster/OneFichierCom.py
+++ b/module/plugins/hoster/OneFichierCom.py
@@ -9,7 +9,7 @@ class OneFichierCom(Hoster):
__name__ = "OneFichierCom"
__type__ = "hoster"
__pattern__ = r"http://[a-z0-9]+\.1fichier\.com/(.*)"
- __version__ = "0.1"
+ __version__ = "0.2"
__description__ = """1fichier.com download hoster"""
__author_name__ = ("fragonib")
__author_mail__ = ("fragonib AT yahoo DOT es")
@@ -48,46 +48,42 @@ class OneFichierCom(Hoster):
def get_file_url(self):
self.log.debug("OneFichierCom: Getting file URL")
- file_url_pattern = r"<br/>\&nbsp;<br/>\&nbsp;<br/>\&nbsp;[\t\n\r ]+<a href=\"(http://.*?)\""
+ file_url_pattern = r"<br/>\&nbsp;<br/>\&nbsp;<br/>\&nbsp;[\t\n\r ]+<a href=\"(?P<url>http://.*?)\""
m = re.search(file_url_pattern, self.html)
if m is not None:
- url = m.group(1)
+ url = m.group('url')
self.log.debug("OneFichierCom: File URL [%s]" % url)
return url
def get_file_name(self):
self.log.debug("OneFichierCom: Getting file name")
file_name_patterns = (
- r"content=\"Téléchargement du fichier (.*?)\">",
- r"(>Cliquez ici pour télécharger|>Click here to download) (.*?)</a>",
- r"\">(Nom du fichier :|File name :)</th>[\t\r\n ]+<td>(.*?)</td>",
- r"<title>Download of (.*?)</title>"
+ r"\">(Nom du fichier :|File name :)</th>[\t\r\n ]+<td>(?P<name>.*?)</td>",
+ r"(>Cliquez ici pour télécharger|>Click here to download) (?P<name>.*?)</a>",
+ r"content=\"(Téléchargement du fichier |Download the file named )(?P<name>.*?)\">",
+ r"<title>(Téléchargement du fichier|Download the file)\s*:\s*(?P<name>.*?)</title>"
)
for pattern in file_name_patterns:
m = re.search(pattern, self.html)
if m is not None:
- name = m.group(1).strip()
+ name = m.group('name').strip()
self.log.debug("OneFichierCom: File name [%s]" % name)
return name
def get_file_size(self):
self.log.debug("OneFichierCom: Getting file size")
- file_size_pattern = r"<th>(Taille :|File size :)</th>[\t\n\r ]+<td>(\d*)\s+(.*?)</td>"
+ file_size_pattern = r"<th>(Taille :|File size :)</th>[\t\n\r ]+<td>(?P<size>\d*)\s+(?P<units>.*?)</td>"
m = re.search(file_size_pattern, self.html)
if m is not None:
- size = m.group(2)
- units = m.group(3)
- multiplier = 1
- if units in ("Go", "Gb"):
- multiplier = 1024 ** 3
- if units in ("Mo", "Mb"):
- multiplier = 1024 ** 2
- if units in ("Ko", "Kb"):
- multiplier = 1024 ** 1
- bytes = int(size) * multiplier
+ size = int(m.group('size'))
+ units = m.group('units')[0].upper()
+ try:
+ multiplier = 1024 ** {"K":1, "M":2, "G":3}[units]
+ except KeyError:
+ multiplier = 1
+ bytes = size * multiplier
self.log.debug("OneFichierCom: File size [%s] bytes" % bytes)
- return bytes
- \ No newline at end of file
+ return bytes \ No newline at end of file