<commit_before>from __future__ import unicode_literals, division, absolute_import
from builtins import *  # pylint: disable=unused-import, redefined-builtin

import logging

from flexget import plugin
from flexget.entry import Entry
from flexget.event import event
from flexget.utils.cached_input import cached
from flexget.utils.requests import RequestException
from flexget.utils.soup import get_soup

log = logging.getLogger('horriblesubs')


class HorribleSubs(object):
    """
    Give latest horriblesubs releases
    """
    schema = {'type': 'boolean'}

    @staticmethod
    def horrible_entries(requests, page_url):
        entries = []

        try:
            soup = get_soup(requests.get(page_url).content)
        except RequestException as e:
            return entries

        for td_label in soup.findAll('td', attrs={'class': 'dl-label'}):
            title = '[HorribleSubs] {0}'.format(str(td_label.find('i').string))
            urls = []
            log.debug('Found title `{0}`'.format(title))
            for span in td_label.parent.findAll('span', attrs={'class': 'dl-link'}):
                # skip non torrent based links
                if 'hs-ddl-link' in span.parent.attrs['class']:
                    continue
                url = str(span.find('a').attrs['href'])
                log.debug('Found url `{0}`'.format(url))
                urls.append(url)
            # move magnets to last, a bit hacky
            for url in urls[:]:
                if url.startswith('magnet'):<commit_msg>Added log of error on page request<commit_after>from __future__ import unicode_literals, division, absolute_import
from builtins import *  # pylint: disable=unused-import, redefined-builtin

import logging

from flexget import plugin
from flexget.entry import Entry
from flexget.event import event
from flexget.utils.cached_input import cached
from flexget.utils.requests import RequestException
from flexget.utils.soup import get_soup

log = logging.getLogger('horriblesubs')


class HorribleSubs(object):
    """
    Give latest horriblesubs releases
    """
    schema = {'type': 'boolean'}

    @staticmethod
    def horrible_entries(requests, page_url):
        entries = []

        try:
            soup = get_soup(requests.get(page_url).content)
        except RequestException as e:
            log.error('HorribleSubs request failed: %s', e)
            return entries

        for td_label in soup.findAll('td', attrs={'class': 'dl-label'}):
            title = '[HorribleSubs] {0}'.format(str(td_label.find('i').string))
            urls = []
            log.debug('Found title `{0}`'.format(title))
            for span in td_label.parent.findAll('span', attrs={'class': 'dl-link'}):
                # skip non torrent based links
                if 'hs-ddl-link' in span.parent.attrs['class']:
                    continue
                url = str(span.find('a').attrs['href'])
                log.debug('Found url `{0}`'.format(url))
                urls.append(url)
            # move magnets to last, a bit hacky
            for url in urls[:]:
                if url.startswith('magnet'):
{'fraction_non_alphanumeric': 0.11618257261410789, 'fraction_numerical': 0.001915097350781998, 'mean_word_length': 2.5016759776536315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1441415', 'n_tokens_mistral': 905, 'n_tokens_neox': 888, 'n_words': 232}