def check_file(plugin, urls):
    html = get_url(plugin.URLS[1], post={'urls': "\n".join(urls)})

    file_info = []
    for li in re.finditer(plugin.LINKCHECK_TR, html, re.S):
        try:
            cols = re.findall(plugin.LINKCHECK_TD, li.group(1))
            if cols:
                file_info.append((
                    cols[1] if cols[1] != '--' else cols[0],
                    parse_size(cols[2]) if cols[2] != '--' else 0,
                    2 if cols[3].startswith('Available') else 1,
                    cols[0]))

        except Exception, e:
            continue
    def handle_premium(self, pyfile):
        data  = self.account.get_data()
        page  = self.load("https://api.over-load.me/getdownload.php",
                          get={'auth': data['password'],
                               'link': pyfile.url})

        data = json.loads(page)

        self.log_debug(data)

        if data['error'] == 1:
            self.log_warning(data['msg'])
            self.temp_offline()
        else:
            self.link = data['downloadlink']
            if pyfile.name and pyfile.name.endswith('.tmp') and data['filename']:
                pyfile.name = data['filename']
                pyfile.size = parse_size(data['filesize'])
    def handle_premium(self, pyfile):
        password = self.get_password()

        data = json.loads(self.load("http://www.alldebrid.com/service.php",
                                     get={'link': pyfile.url, 'json': "true", 'pw': password}))

        self.log_debug("Json data", data)

        if data['error']:
            if data['error'] == "This link isn't available on the hoster website.":
                self.offline()
            else:
                self.log_warning(data['error'])
                self.temp_offline()
        else:
            if pyfile.name and not pyfile.name.endswith('.tmp'):
                pyfile.name = data['filename']
            pyfile.size = parse_size(data['filesize'])
            self.link = data['link']
    def handle_premium(self, pyfile):
        data = json.loads(self.load("https://real-debrid.com/ajax/unrestrict.php",
                                    get={'lang'    : "en",
                                         'link'    : pyfile.url,
                                         'password': self.get_password(),
                                         'time'    : int(time.time() * 1000)}))

        self.log_debug("Returned Data: %s" % data)

        if data['error'] != 0:
            if data['message'] == "Your file is unavailable on the hoster.":
                self.offline()
            else:
                self.log_warning(data['message'])
                self.temp_offline()
        else:
            if pyfile.name and pyfile.name.endswith('.tmp') and data['file_name']:
                pyfile.name = data['file_name']
            pyfile.size = parse_size(data['file_size'])
            self.link = data['generated_links'][0][-1]
    def check_traffic(self):
        #: Check if user logged in
        m = re.search(self.USER_CREDIT_PATTERN, self.data)
        if m is None:
            self.account.relogin()
            self.data = self.load(self.pyfile.url)
            m = re.search(self.USER_CREDIT_PATTERN, self.data)
            if m is None:
                return False

        #: Check user credit
        try:
            credit = parse_size(m.group(1).replace(' ', ''), m.group(2))
            self.log_info(_("Premium download for %i KiB of Credit") % (self.pyfile.size / 1024))
            self.log_info(_("User %s has %i KiB left") % (self.account.user, credit / 1024))
            if credit < self.pyfile.size:
                self.log_info(_("Not enough credit to download file: %s") % self.pyfile.name)
                return False

        except Exception, e:
            #: let's continue and see what happens...
            self.log_error(e, trace=True)
 def parse_traffic(self, size, unit=None):  #@NOTE: Returns kilobytes in 0.4.9
     self.log_debug("Size: %s" % size,
                    "Unit: %s" % (unit or "N/D"))
     return parse_size(size, unit or "byte") / 1024  #@TODO: Remove `/ 1024` in 0.4.10