forked from ping/newsrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolitico-magazine.recipe.py
64 lines (52 loc) · 2.11 KB
/
politico-magazine.recipe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (c) 2022 https://github.com/ping/
#
# This software is released under the GNU General Public License v3.0
# https://opensource.org/licenses/GPL-3.0
"""
politico.com
"""
import os
import sys
# custom include to share code between recipes
sys.path.append(os.environ["recipes_includes"])
from recipes_shared import BasicNewsrackRecipe, format_title
from calibre.web.feeds.news import BasicNewsRecipe
_name = "POLITICO Magazine"
class PoliticoMagazine(BasicNewsrackRecipe, BasicNewsRecipe):
title = _name
__author__ = "ping"
description = "News, Analysis and Opinion from POLITICO https://www.politico.com/"
publisher = "Capitol News Company, LLC"
category = "news, politics, USA"
publication_type = "magazine"
language = "en"
masthead_url = "https://www.politico.com/dims4/default/bbb0fd2/2147483647/resize/1160x%3E/quality/90/?url=https%3A%2F%2Fstatic.politico.com%2F0e%2F5b%2F3cf3e0f04ca58370112ab667c255%2Fpolitico-logo.png"
oldest_article = 7
max_articles_per_feed = 25
keep_only_tags = [dict(name=["main"])]
remove_tags = [
dict(
class_=[
"story-section",
"social-tools",
"below-article-section",
"pop-up-bar",
"inline-super-footer",
]
),
dict(id=["weekend-promo"]),
dict(name=["source"]),
]
extra_css = """
.media-item__summary h2.headline { font-size: 1.8rem; margin-bottom: 0.4rem; }
.media-item__summary p.dek { font-size: 1.2rem; font-style: italic; margin-bottom: 1rem; margin-top: 0; }
.fig-graphic img, .story-photo__image img { max-width: 100%; height: auto; }
.story-meta__credit, .story-photo__caption { font-size: 0.8rem; margin-top: 0.2rem; }
"""
feeds = [("Magazine", "https://rss.politico.com/magazine.xml")]
def populate_article_metadata(self, article, __, _):
if (not self.pub_date) or article.utctime > self.pub_date:
self.pub_date = article.utctime
self.title = format_title(_name, article.utctime)
def parse_feeds(self):
return self.group_feeds_by_date()