#!/usr/bin/env python
# encoding: utf-8

from __future__ import with_statement

__license__ = 'GPL 3'
__copyright__ = 'zotzo'
__docformat__ = 'restructuredtext en'
'''
http://fifthdown.blogs.nytimes.com/
http://offthedribble.blogs.nytimes.com/
http://thequad.blogs.nytimes.com/
http://slapshot.blogs.nytimes.com/
http://goal.blogs.nytimes.com/
http://bats.blogs.nytimes.com/
http://straightsets.blogs.nytimes.com/
http://formulaone.blogs.nytimes.com/
http://onpar.blogs.nytimes.com/
'''

from calibre.web.feeds.news import BasicNewsRecipe


class NYTimesSports(BasicNewsRecipe):
    title = 'New York Times Sports Beat'
    language = 'en_US'
    __author__ = 'rylsfan'
    description = 'Indepth sports from the New York Times'
    publisher = 'The New York Times'
    category = 'Sports'
    oldest_article = 3
    max_articles_per_feed = 25
    use_embedded_content = False
    no_stylesheets = True
    delay = 1

    feeds = [
        ('The Fifth Down', 'https://fifthdown.blogs.nytimes.com/feed/'),
        ('The Quad', 'https://thequad.blogs.nytimes.com/feed/'),
        ('Slap Shot', 'https://slapshot.blogs.nytimes.com/feed/'),
        ('Goal', 'https://goal.blogs.nytimes.com/feed/'),
        ('Bats', 'https://bats.blogs.nytimes.com/feed/'),
        ('Straight Sets', 'https://straightsets.blogs.nytimes.com/feed/'),
        ('Formula One', 'https://formulaone.blogs.nytimes.com/feed/'),
        ('On Par', 'https://onpar.blogs.nytimes.com/feed/'),
    ]

    def preprocess_raw_html(self, raw_html, url):
        if not hasattr(self, 'nyt_parser'):
            from calibre.live import load_module

            m = load_module('calibre.web.site_parsers.nytimes')
            self.nyt_parser = m
        html = self.nyt_parser.extract_html(self.index_to_soup(raw_html))
        return html
