<commit_before># -*- coding: utf-8 -*-

import re
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo

class OneFichierCom(SimpleHoster):
    __name__ = "OneFichierCom"
    __type__ = "hoster"
    __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.44"
    __description__ = """1fichier.com download hoster"""
    __author_name__ = ("fragonib", "the-razer", "zoidberg")
    __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "daniel_ AT gmx DOT net", "<EMAIL>")
    
    FILE_NAME_PATTERN = r'">File name :</th>\s*<td>(?P<N>[^<]+)</td>'
    FILE_SIZE_PATTERN = r'<th>File size :</th>\s*<td>(?P<S>[^<]+)</td>'
    FILE_OFFLINE_PATTERN = r'The (requested)? file (could not be found|has been deleted)' 
    FILE_URL_REPLACEMENTS = [(r'(http://[^/]*).*', r'\1/en/')]
    
    DOWNLOAD_LINK_PATTERN = r'<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;\s+<a href="(?P<url>http://.*?)"'       
    PASSWORD_PROTECTED_TOKEN = "<PASSWORD>"
    WAITING_PATTERN = "Warning ! Without premium status, you can download only one file at a time and you must wait at least (\d+) minutes between each downloads."
    def process(self, pyfile):
        found = re.search(self.__pattern__, pyfile.url)
        file_id = found.group(2)      
        url = "http://%s.%s/en/" % (found.group(2), found.group(3))         
        self.html = self.load(url, decode = True)
        
        found = re.search(self.WAITING_PATTERN, self.html)
        if found:
            self.waitAndRetry(int(found.group(1)) * 60)
        
        self.getFileInfo()
        
        url, inputs = self.parseHtmlForm('action="http://%s' % file_id)
        if not url or not inputs:
            self.parseError("Download link not found")
        
        # Check for protection 
        if "pass" in inputs:
            inputs['pass'] = self.getPassword()
            
        self.download(url, post = inputs)
        
        # Check download 
        self.checkDownloadedFile()
            
    def checkDownloadedFile(self):
        check = self.checkDownload({"wait": self.WAITING_PATTERN})
        if check == "wait":
            self.waitAndRetry(int(self.lastcheck.group(1)) * 60)
    
    def waitAndRetry(self, wait_time):
        self.setWait(wait_time, True)
        self.wait()
        self.retry()
        
getInfo = create_getInfo(OneFichierCom)   
<commit_msg>Incremented version & added author.<commit_after># -*- coding: utf-8 -*-

import re
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo

class OneFichierCom(SimpleHoster):
    __name__ = "OneFichierCom"
    __type__ = "hoster"
    __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.45"
    __description__ = """1fichier.com download hoster"""
    __author_name__ = ("fragonib", "the-razer", "zoidberg","imclem")
    __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "daniel_ AT gmx DOT net",
    "<EMAIL>","imclem on github")
    
    FILE_NAME_PATTERN = r'">File name :</th>\s*<td>(?P<N>[^<]+)</td>'
    FILE_SIZE_PATTERN = r'<th>File size :</th>\s*<td>(?P<S>[^<]+)</td>'
    FILE_OFFLINE_PATTERN = r'The (requested)? file (could not be found|has been deleted)' 
    FILE_URL_REPLACEMENTS = [(r'(http://[^/]*).*', r'\1/en/')]
    
    DOWNLOAD_LINK_PATTERN = r'<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;\s+<a href="(?P<url>http://.*?)"'       
    PASSWORD_PROTECTED_TOKEN = "<PASSWORD>"
    WAITING_PATTERN = "Warning ! Without premium status, you can download only one file at a time and you must wait at least (\d+) minutes between each downloads."
    def process(self, pyfile):
        found = re.search(self.__pattern__, pyfile.url)
        file_id = found.group(2)      
        url = "http://%s.%s/en/" % (found.group(2), found.group(3))         
        self.html = self.load(url, decode = True)
        
        found = re.search(self.WAITING_PATTERN, self.html)
        if found:
            self.waitAndRetry(int(found.group(1)) * 60)
        
        self.getFileInfo()
        
        url, inputs = self.parseHtmlForm('action="http://%s' % file_id)
        if not url or not inputs:
            self.parseError("Download link not found")
        
        # Check for protection 
        if "pass" in inputs:
            inputs['pass'] = self.getPassword()
            
        self.download(url, post = inputs)
        
        # Check download 
        self.checkDownloadedFile()
            
    def checkDownloadedFile(self):
        check = self.checkDownload({"wait": self.WAITING_PATTERN})
        if check == "wait":
            self.waitAndRetry(int(self.lastcheck.group(1)) * 60)
    
    def waitAndRetry(self, wait_time):
        self.setWait(wait_time, True)
        self.wait()
        self.retry()
        
getInfo = create_getInfo(OneFichierCom)   

{'fraction_non_alphanumeric': 0.16225819186735096, 'fraction_numerical': 0.006711409395973154, 'mean_word_length': 2.7477810650887573, 'pattern_counts': {'":': 4, '<': 39, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2750207', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1742, 'n_words': 323}