<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 import requests
from flexget.utils.soup import get_soup

log = logging.getLogger('pogcal')


class InputPogDesign(object):

    schema = {
        'type': 'object',
        'properties': {
            'username': {'type': 'string'},
            'password': {'type': 'string'}
        },
        'required': ['username', 'password'],
        'additionalProperties': False
    }

    name_map = {'The Tonight Show [Leno]': 'The Tonight Show With Jay Leno',
                'Late Show [Letterman]': '<NAME>'}

    def on_task_input(self, task, config):
        session = requests.Session()
        data = {'username': config['username'], 'password': config['password'], 'sub_login': 'Account Login'}
        try:
            r = session.post('http://www.pogdesign.co.uk/cat/login', data=data)
            if 'U / P Invalid' in r.text:
                raise plugin.PluginError('Invalid username/password for pogdesign.')
            page = session.get('http://www.pogdesign.co.uk/cat/show-select')
        except requests.RequestException as e:
            raise plugin.PluginError('Error retrieving source: %s' % e)
        soup = get_soup(page.text)
        entries = []
        for row in soup.find_all('li', {'class': 'selectgrp checked'}):

            # Get name
            t = row.find('strong')
            
            # Remove <span> tags
            spantags = t.find_all('span')
            for s in spantags:
                s.extract()
            t = row.text

            if t.endswith('[The]'):
                t = 'The ' + t[:-6]

            # Make certain names friendlier
            if t in self.name_map:
                t = self.name_map[t]

            e = Entry()
            e['title'] = t
            #url = row.find_next('a', {'class': 'slink'})
            #e['url'] = 'http://www.pogdesign.co.uk' + url['href']
            entries.append(e)

        return entries


@event('plugin.register')
def register_plugin():
    plugin.register(InputPogDesign, 'pogcal', api_ver=2)<commit_msg>Fix newlines in pogcal input<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 import requests
from flexget.utils.soup import get_soup

log = logging.getLogger('pogcal')


class InputPogDesign(object):

    schema = {
        'type': 'object',
        'properties': {
            'username': {'type': 'string'},
            'password': {'type': 'string'}
        },
        'required': ['username', 'password'],
        'additionalProperties': False
    }

    name_map = {'The Tonight Show [Leno]': 'The Tonight Show With Jay Leno',
                'Late Show [Letterman]': '<NAME>'}

    def on_task_input(self, task, config):
        session = requests.Session()
        data = {'username': config['username'], 'password': config['password'], 'sub_login': 'Account Login'}
        try:
            r = session.post('http://www.pogdesign.co.uk/cat/login', data=data)
            if 'U / P Invalid' in r.text:
                raise plugin.PluginError('Invalid username/password for pogdesign.')
            page = session.get('http://www.pogdesign.co.uk/cat/show-select')
        except requests.RequestException as e:
            raise plugin.PluginError('Error retrieving source: %s' % e)
        soup = get_soup(page.text)
        entries = []
        for row in soup.find_all('li', {'class': 'selectgrp checked'}):

            # Get name
            t = row.find('strong')
            
            # Remove <span> tags
            spantags = t.find_all('span')
            for s in spantags:
                s.extract()
            t = row.text
            # remove newlines and whitepsace
            t = t.replace('\n', '').strip()

            if t.endswith('[The]'):
                t = 'The ' + t[:-6]

            # Make certain names friendlier
            if t in self.name_map:
                t = self.name_map[t]

            e = Entry()
            e['title'] = t
            #url = row.find_next('a', {'class': 'slink'})
            #e['url'] = 'http://www.pogdesign.co.uk' + url['href']
            entries.append(e)

        return entries


@event('plugin.register')
def register_plugin():
    plugin.register(InputPogDesign, 'pogcal', api_ver=2)
{'fraction_non_alphanumeric': 0.1354344122657581, 'fraction_numerical': 0.0008517887563884157, 'mean_word_length': 2.14180602006689, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '2112403', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1347, 'n_words': 350}