# -*- coding: utf-8 -*-

import re

from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo
from module.utils import html_unescape


class RarefileNet(XFSHoster):
    __name__    = "RarefileNet"
    __type__    = "hoster"
    __version__ = "0.06"

    __pattern__ = r'http://(?:www\.)?rarefile\.net/\w{12}'

    __description__ = """Rarefile.net hoster plugin"""
    __license__     = "GPLv3"
    __authors__     = [("zoidberg", "zoidberg@mujmail.cz")]


    HOSTER_DOMAIN = "rarefile.net"

    NAME_PATTERN = r'<td><font color="red">(?P<N>.*?)</font></td>'
    SIZE_PATTERN = r'<td>Size : (?P<S>.+?)&nbsp;'

    LINK_PATTERN = r'<a href="(?P<link>[^"]+)">(?P=link)</a>'


    def handleCaptcha(self, inputs):
        captcha_div = re.search(r'<b>Enter code.*?<div.*?>(.*?)</div>', self.html, re.S).group(1)
        self.logDebug(captcha_div)
        numerals = re.findall('<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div))
        inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))])
        self.logDebug("CAPTCHA", inputs['code'], numerals)
        return 3


getInfo = create_getInfo(RarefileNet)

@@ -105,47 +105,8 @@
 nfo%0A
-from module.utils import html_unescape%0A
 %0A%0Acl
@@ -218,9 +218,9 @@
 %220.0
-6
+7
 %22%0A%0A 
@@ -469,636 +469,65 @@
     
-NAME_PATTERN = r'%3Ctd%3E%3Cfont color=%22red%22%3E(?P%3CN%3E.*?)%3C/font%3E%3C/td%3E'%0A    SIZE_PATTERN = r'%3Ctd%3ESize : (?P%3CS%3E.+?)&nbsp;'%0A%0A    LINK_PATTERN = r'%3Ca href=%22(?P%3Clink%3E%5B%5E%22%5D+)%22%3E(?P=link)%3C/a%3E'%0A%0A%0A    def handleCaptcha(self, inputs):%0A        captcha_div = re.search(r'%3Cb%3EEnter code.*?%3Cdiv.*?%3E(.*?)%3C/div%3E', self.html, re.S).group(1)%0A        self.logDebug(captcha_div)%0A        numerals = re.findall('%3Cspan.*?padding-left%5Cs*:%5Cs*(%5Cd+).*?%3E(%5Cd)%3C/span%3E', html_unescape(captcha_div))%0A        inputs%5B'code'%5D = %22%22.join(%5Ba%5B1%5D for a in sorted(numerals, key=lambda num: int(num%5B0%5D))%5D)%0A        self.logDebug(%22CAPTCHA%22, inputs%5B'code'%5D, numerals)%0A        return 3
+LINK_PATTERN = r'%3Ca href=%22(?P%3Clink%3E%5B%5E%22%5D+)%22%3E(?P=link)%3C/a%3E'
 %0A%0A%0Ag

Remove old handleCaptcha