calibre/recipes/foxnews.recipe
2025-01-24 11:14:14 +01:00

75 lines
2.6 KiB
Python

#!/usr/bin/env python
# vim:fileencoding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
from calibre.web.feeds.news import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(
attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
class FoxNews(BasicNewsRecipe):
title = 'FOX News'
__author__ = 'Darko Miletic'
description = 'Breaking News from FOX'
publisher = 'FOXNews.com'
category = 'news, breaking news, latest news, current news, world news, national news, USA'
oldest_article = 2
max_articles_per_feed = 200
no_stylesheets = True
encoding = 'utf8'
use_embedded_content = False
language = 'en_US'
remove_empty_feeds = True
extra_css = '''
body{font-family: Arial,sans-serif }
.caption{font-size: x-small}
.author,.dateline{font-size: small}
'''
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)
conversion_options = {
'comment': description,
'tags': category,
'publisher': publisher,
'language': language}
remove_attributes = ['xmlns', 'lang']
ignore_duplicate_articles = {'title', 'url'}
keep_only_tags = [
dict(itemprop=['headline', 'articleBody']),
dict(name='h1'),
classes('byline author date source article-info article-body featured-image'),
]
remove_tags = [
classes('featured-video video-container'),
]
feeds = [(u'Latest Headlines', u'http://feeds.foxnews.com/foxnews/latest'),
(u'National', u'http://feeds.foxnews.com/foxnews/national'),
(u'World', u'http://feeds.foxnews.com/foxnews/world'),
(u'Politics', u'http://feeds.foxnews.com/foxnews/politics'),
(u'Opinion', u'http://feeds.foxnews.com/foxnews/opinion'),
(u'Science', u'http://feeds.foxnews.com/foxnews/science'),
(u'Technology', u'http://feeds.foxnews.com/foxnews/tech'),
(u'Health', u'http://feeds.foxnews.com/foxnews/health'),
(u'Lifestyle', u'http://feeds.foxnews.com/foxnews/section/lifestyle'),
(u'Travel', u'http://feeds.foxnews.com/foxnews/internal/travel/mixed')]