Repository: pyload/pyload

Issue:
[OneFichierCom]Non restricted file
Hello, i try to download little files on 1fichier( like this : ) but i cannot

```
ff^[^[^[^[^[^[19.08.2015 07:59:13 INFO      Added package Nonrestricted file containing 1 links
19.08.2015 07:59:13 DEBUG     Run Info Fetching for OneFichierCom
19.08.2015 07:59:14 INFO      Download starts: https://1fichier.com/?86zu29oou8
19.08.2015 07:59:14 DEBUG     HOOK UserAgentSwitcher: Use custom user-agent string: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
19.08.2015 07:59:14 DEBUG     HOOK UserAgentSwitcher: Use custom user-agent string: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
19.08.2015 07:59:14 DEBUG     HOSTER OneFichierCom[126]: PROCESS URL https://1fichier.com/?86zu29oou8 | PLUGIN VERSION 0.88
19.08.2015 07:59:14 INFO      HOSTER OneFichierCom[126]: Updating file info...
Traceback (most recent call last):
  File "/usr/share/pyload/module/network/HTTPRequest.py", line 279, in write
    raise Exception("Loaded Url exceeded limit")
Exception: Loaded Url exceeded limit
19.08.2015 07:59:15 DEBUG     Finished Info Fetching for OneFichierCom
Traceback (most recent call last):
  File "/usr/share/pyload/module/network/HTTPRequest.py", line 279, in write
    raise Exception("Loaded Url exceeded limit")
Exception: Loaded Url exceeded limit
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: File info: {'status': 3, 'url': u'https://1fichier.com/?86zu29oou8', 'size': 0, 'name': u'86zu29oou8', 'pattern': {'HOST': u'1fichier.com', 'ID2': u'86zu29oou8', 'ID1': None}}
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: Previous file info: {}
19.08.2015 07:59:17 INFO      HOSTER OneFichierCom[126]: File name: 86zu29oou8
19.08.2015 07:59:17 INFO      HOSTER OneFichierCom[126]: File size: Unknown
19.08.2015 07:59:17 INFO      HOSTER OneFichierCom[126]: File status: queued
19.08.2015 07:59:17 INFO      HOSTER OneFichierCom[126]: Looking for direct download link...
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: Redirect #0 to: https://1fichier.com/?86zu29oou8
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: LOAD URL https://1fichier.com/?86zu29oou8 | cookies=True | get={} | req=None | decode=True | multipart=False | post={} | ref=True | just_header=True
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: Redirect #1 to: https://a-9.1fichier.com/s25134576
19.08.2015 07:59:17 DEBUG     HOSTER OneFichierCom[126]: LOAD URL https://a-9.1fichier.com/s25134576 | cookies=True | get={} | req=None | decode=True | multipart=False | post={} | ref=True | just_header=True
19.08.2015 07:59:19 INFO      HOSTER OneFichierCom[126]: Direct download link detected
19.08.2015 07:59:19 INFO      HOSTER OneFichierCom[126]: Downloading file...
19.08.2015 07:59:19 DEBUG     HOSTER OneFichierCom[126]: DOWNLOAD URL https://a-9.1fichier.com/s25134576 | cookies=True | get={} | disposition=True | post={} | ref=True
19.08.2015 07:59:20 INFO      HOSTER OneFichierCom[126]: Checking file...
19.08.2015 07:59:20 DEBUG     HOSTER OneFichierCom[126]: Using default check rules...
19.08.2015 07:59:20 WARNING   HOSTER OneFichierCom[126]: Check result: Html file | Waiting 1 minute and retry
19.08.2015 07:59:20 INFO      HOSTER OneFichierCom[126]: WAIT 60 seconds
19.08.2015 07:59:20 DEBUG     HOSTER OneFichierCom[126]: Previous waitUntil: 0.000000
19.08.2015 07:59:20 INFO      HOSTER OneFichierCom[126]: RECONNECT disabled
19.08.2015 07:59:20 DEBUG     HOSTER OneFichierCom[126]: Previous wantReconnect: True
19.08.2015 07:59:20 WARNING   HOSTER OneFichierCom[126]: Ignore reconnection due logged account
```

curl : 

```
curl 7.26.0 (arm-unknown-linux-gnueabihf) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp 
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
```

OS : Raspberry Rasbian 7

```
greg@serveur-pi ~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
```



Discussion:

Resolving patch:
diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py
--- a/module/plugins/hoster/OneFichierCom.py
+++ b/module/plugins/hoster/OneFichierCom.py
@@ -2,13 +2,14 @@
 
 import re
 
+from module.network.RequestFactory import getURL as get_url
 from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
 
 
 class OneFichierCom(SimpleHoster):
     __name__    = "OneFichierCom"
     __type__    = "hoster"
-    __version__ = "0.88"
+    __version__ = "0.89"
     __status__  = "testing"
 
     __pattern__ = r'https?://(?:www\.)?(?:(?P<ID1>\w+)\.)?(?P<HOST>1fichier\.com|alterupload\.com|cjoint\.net|d(es)?fichiers\.com|dl4free\.com|megadl\.fr|mesfichiers\.org|piecejointe\.net|pjointe\.com|tenvoi\.com)(?:/\?(?P<ID2>\w+))?'
@@ -28,6 +29,8 @@ class OneFichierCom(SimpleHoster):
 
     COOKIES     = [("1fichier.com", "LG", "en")]
 
+    DIRECT_LINK = True
+
     NAME_PATTERN    = r'>File\s*Name :</td>\s*<td.*>(?P<N>.+?)<'
     SIZE_PATTERN    = r'>Size :</td>\s*<td.*>(?P<S>[\d.,]+) (?P<U>[\w^_]+)'
     OFFLINE_PATTERN = r'File not found !\s*<'
@@ -40,7 +43,61 @@ def setup(self):
         self.resume_download = True
 
 
+    @classmethod
+    def get_info(cls, url="", html=""):
+        redirect = url
+        for i in xrange(10):
+            try:
+                headers = dict(re.findall(r"(?P<name>.+?): (?P<value>.+?)\r?\n", get_url(redirect, just_header=True).lower()))
+                if 'location' in headers and headers['location']:
+                    redirect = headers['location']
+                else:
+                    if 'content-type' in headers and headers['content-type'] == "application/octet-stream":
+                        if "filename=" in headers.get('content-disposition'):
+                            name = dict(_i.split("=") for _i in map(str.strip, headers['content-disposition'].split(";"))[1:]['filename'].strip("\"'")
+                        else:
+                            name = url
+
+                        info = {'name'  : name,
+                                'size'  : long(headers.get('content-length')),
+                                'status': 3,
+                                'url'   : url}
+
+                    else:
+                        info = super(OneFichierCom, cls).get_info(url, html)
+
+                    break
+
+            except Exception, e:
+                info = {'status' : 8,
+                        'error'  : e.message}
+
+        else:
+            info = {'status' : 8,
+                    'error'    : _("Too many redirects")}
+
+        return info
+
+
+    def handle_direct(self, pyfile):
+        redirect = pyfile.url
+        for i in xrange(self.get_config("maxredirs", plugin="UserAgentSwitcher")):
+
+            headers = self.load(redirect, just_header=True)
+            if 'location' in headers and headers['location']:
+                self.log_debug("Redirect #%d to: %s" % (i, redirect))
+                redirect = headers['location']
+            else:
+                if 'content-type' in headers and headers['content-type'] == "application/octet-stream":
+                    self.link = pyfile.url
+                break
+        else:
+            self.fail(_("Too many redirects"))
+
+
     def handle_free(self, pyfile):
+        self.check_errors()
+
         id = self.info['pattern']['ID1'] or self.info['pattern']['ID2']
         url, inputs = self.parse_html_form('action="https://1fichier.com/\?%s' % id)
 


Test patch: