# -*- coding: utf-8 -*- import re 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): __name__ = "OneFichierCom" __type__ = "hoster" __pattern__ = r"http://(?P[a-z0-9]+)\.1fichier\.com(?P.*)" __version__ = "0.3" __description__ = """1fichier.com download hoster""" __author_name__ = ("fragonib") __author_mail__ = ("fragonib[AT]yahoo[DOT]es") FILE_NAME_PATTERNS = ( r'">File name :[\t\r\n ]+(?P.*?)', r">Click here to download (?P.*?)", r"content=\"Download the file named (?P.*?)\">", r"Download the file\s*:\s*(?P<name>.*?)" ) FILE_SIZE_PATTERN = r"File size :\s+(?P[\d\.]*) (?P\w+)" DOWNLOAD_LINK_PATTERN = r'
 
 
 \s+