mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-09-29 15:31:08 -04:00
47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
# vim:fileencoding=utf-8
|
|
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
|
|
|
|
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
|
|
|
|
|
def classes(classes):
|
|
q = frozenset(classes.split(' '))
|
|
return dict(attrs={
|
|
'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
|
|
|
|
|
class NationalPost(BasicNewsRecipe):
|
|
|
|
title = 'National Post'
|
|
__author__ = 'Kovid Goyal'
|
|
description = 'Canadian national newspaper'
|
|
timefmt = ' [%d %b, %Y]'
|
|
language = 'en_CA'
|
|
no_stylesheets = True
|
|
oldest_article = 1.5
|
|
use_embedded_content = False
|
|
|
|
recipe_specific_options = {
|
|
'days': {
|
|
'short': 'Oldest article to download from this news source. In days ',
|
|
'long': 'For example, 0.5, gives you articles from the past 12 hours',
|
|
'default': str(oldest_article)
|
|
}
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
BasicNewsRecipe.__init__(self, *args, **kwargs)
|
|
d = self.recipe_specific_options.get('days')
|
|
if d and isinstance(d, str):
|
|
self.oldest_article = float(d)
|
|
|
|
keep_only_tags = [
|
|
dict(itemprop='headline'),
|
|
classes('featured-image'),
|
|
dict(itemprop='articleBody'),
|
|
]
|
|
|
|
feeds = ['http://nationalpost.com/rss']
|