| 1 |
#!/usr/bin/env python |
| 2 |
# vim:fileencoding=utf-8 |
| 3 |
|
| 4 |
__license__ = 'GPL v3' |
| 5 |
__author__ = 'quatorze' |
| 6 |
__copyright__ = '2025, quatorze' |
| 7 |
__version__ = 'v1.00' |
| 8 |
__date__ = '8 July 2025' |
| 9 |
__description__ = 'La Presse ' |
| 10 |
|
| 11 |
import re |
| 12 |
|
| 13 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 14 |
|
| 15 |
|
| 16 |
class LaPresse(BasicNewsRecipe): |
| 17 |
title = 'La Presse' |
| 18 |
__author__ = 'quatorze' |
| 19 |
timefmt = ' %Y-%m-%d' |
| 20 |
language = 'fr_CA' |
| 21 |
encoding = 'utf-8' |
| 22 |
publisher = 'www.lapresse.ca' |
| 23 |
publication_type = 'newspaper' |
| 24 |
category = 'News, finance, economy, politics' |
| 25 |
ignore_duplicate_articles = {'title', 'url'} |
| 26 |
oldest_article = 1.0 |
| 27 |
max_articles_per_feed = 100 |
| 28 |
min_articles_per_feed = 0 |
| 29 |
auto_cleanup = False |
| 30 |
remove_empty_feeds = True |
| 31 |
use_embedded_content = False |
| 32 |
needs_subscription = False |
| 33 |
remove_javascript = True |
| 34 |
compress_news_images = True |
| 35 |
scale_news_images_to_device = True |
| 36 |
compress_news_images_auto_size = 4 |
| 37 |
|
| 38 |
no_stylesheets = True |
| 39 |
extra_css = ''' |
| 40 |
a { text-decoration: none; } |
| 41 |
a.badge { font-size: 80%; } |
| 42 |
div.capsuleModule { border-style: solid; margin:0% 8%; padding:0% 2%; } |
| 43 |
div.quote { border-style: none none none solid; } |
| 44 |
h2.textModule--type-chapter { font-weight: bold; font-size: 110%; } |
| 45 |
p { font-size: 100%; } |
| 46 |
p.chapter { font-weight: bold; } |
| 47 |
p.credit { font-size: 80% } |
| 48 |
p.description { font-size: 80% } |
| 49 |
p.lead { font-weight: bold; font-size: 120%; } |
| 50 |
p.quoteSource { padding-left:7%; font-size: 110%; } |
| 51 |
p.quoteText { padding-left:5%; font-weight: bold; font-style: italic; font-size: 110%; } |
| 52 |
p.teaser { font-weight: bold; font-size: 120%; } |
| 53 |
small.suptitle { display: block; font-size: 50%; } |
| 54 |
span.authorModule__name { display: block; font-size: 80%; } |
| 55 |
span.authorModule__organisation { display: block; font-style: italic; font-size: 80%; } |
| 56 |
span.title { display: block; padding-top:2%; font-weight: bold; font-style: italic; } |
| 57 |
time.publicationsDate--type-publication { display: block; font-size: 80%; } |
| 58 |
time.publicationsDate--type-update { display: block; font-size: 80%; } |
| 59 |
div.complementaryInformation { border-style: solid; margin:0% 8%; padding:0% 2%; } |
| 60 |
div.complementaryInformation__title { font-weight: bold; font-size: 120%; } |
| 61 |
dt { font-weight: bold; font-size: 100%; } |
| 62 |
dd { font-size: 100%; } |
| 63 |
div.source { font-size: 80%; } |
| 64 |
''' |
| 65 |
|
| 66 |
keep_only_tags = dict(name='article', class_='mainStory') |
| 67 |
|
| 68 |
remove_attributes = ['href'] |
| 69 |
|
| 70 |
# Clean up some of the extraneous/interactives inside the article boundaries |
| 71 |
preprocess_regexps = [ |
| 72 |
(re.compile(r'</small>.*?<span>', re.DOTALL | re.IGNORECASE), lambda match: '</small><p> </p><span>'), |
| 73 |
(re.compile(r'<div id="socialShare_.*?</div>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 74 |
(re.compile(r'<a class="linkModule ACT".*?</a>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 75 |
(re.compile(r'<span class="linkModule__content">.*?</span>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 76 |
(re.compile(r'<ul class="buttons ">.*?</ul>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 77 |
(re.compile(r'<div class="visual__title.*?">.*?</div>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 78 |
(re.compile(r'<div class="photoGalleryModule__wrapper">.*?</div>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 79 |
(re.compile(r'<ul class="photoGalleryModule__navigation">.*?</ul>', re.DOTALL | re.IGNORECASE), lambda match: ''), |
| 80 |
] |
| 81 |
|
| 82 |
feeds = [ |
| 83 |
# Actualités - Reporting |
| 84 |
('Politique', 'https://www.lapresse.ca/actualites/politique/rss'), |
| 85 |
('National', 'https://www.lapresse.ca/actualites/national/rss'), |
| 86 |
('Analyses', 'https://www.lapresse.ca/actualites/analyses/rss'), |
| 87 |
('Grand Montréal', 'https://www.lapresse.ca/actualites/grand-montreal/rss'), |
| 88 |
('Régional', 'https://www.lapresse.ca/actualites/regional/rss'), |
| 89 |
('Justice et faits divers', 'https://www.lapresse.ca/actualites/justice-et-faits-divers/rss'), |
| 90 |
('Santé', 'https://www.lapresse.ca/actualites/sante/rss'), |
| 91 |
('Éducation', 'https://www.lapresse.ca/actualites/education/rss'), |
| 92 |
('Environnement', 'https://www.lapresse.ca/actualites/environnement/rss'), |
| 93 |
('Sciences', 'https://www.lapresse.ca/actualites/sciences/rss'), |
| 94 |
# Actualités - Opinions |
| 95 |
('Chroniques', 'https://www.lapresse.ca/actualites/chroniques/rss'), |
| 96 |
('Caricatures', 'https://www.lapresse.ca/actualites/caricatures/rss'), |
| 97 |
('Éditoriaux', 'https://www.lapresse.ca/actualites/editoriaux/rss'), |
| 98 |
('Manchettes - Actualités', 'http://www.lapresse.ca/actualites/rss'), |
| 99 |
# International - Reporting |
| 100 |
('États-Unis', 'https://www.lapresse.ca/international/etats-unis/rss'), |
| 101 |
('Europe', 'https://www.lapresse.ca/international/europe/rss'), |
| 102 |
('Moyen-Orient', 'https://www.lapresse.ca/international/moyen-orient/rss'), |
| 103 |
('Caraïbes', 'https://www.lapresse.ca/international/caraibes/rss'), |
| 104 |
('Amérique latine', 'https://www.lapresse.ca/international/amerique-latine/rss'), |
| 105 |
('Asie et Océanie', 'https://www.lapresse.ca/international/asie-et-oceanie/rss'), |
| 106 |
('Afrique', 'https://www.lapresse.ca/international/afrique/rss'), |
| 107 |
('Manchettes - International', 'http://www.lapresse.ca/international/rss'), |
| 108 |
# International - Opinions |
| 109 |
('Chroniques', 'https://www.lapresse.ca/international/chroniques/rss'), |
| 110 |
# Dialogue |
| 111 |
('Chroniques', 'https://www.lapresse.ca/dialogue/chroniques/rss'), |
| 112 |
('Opinions', 'https://www.lapresse.ca/dialogue/opinions/rss'), |
| 113 |
('Courrier des lecteurs', 'https://www.lapresse.ca/dialogue/courrier-des-lecteurs/rss'), |
| 114 |
('Témoignages', 'https://www.lapresse.ca/dialogue/temoignages/rss'), |
| 115 |
# Contexte |
| 116 |
('Chroniques', 'https://www.lapresse.ca/contexte/chroniques/rss'), |
| 117 |
# En vrac / In bulk ... |
| 118 |
('Affaires', 'https://www.lapresse.ca/affaires/rss'), |
| 119 |
('Sports', 'https://www.lapresse.ca/sports/rss'), |
| 120 |
('Auto', 'https://www.lapresse.ca/auto/rss'), |
| 121 |
('Arts', 'https://www.lapresse.ca/arts/rss'), |
| 122 |
('Cinéma', 'https://www.lapresse.ca/cinema/rss'), |
| 123 |
('Société', 'https://www.lapresse.ca/societe/rss'), |
| 124 |
('Gourmand', 'https://www.lapresse.ca/gourmand/rss'), |
| 125 |
('Voyage', 'https://www.lapresse.ca/voyage/rss'), |
| 126 |
('Maison', 'https://www.lapresse.ca/maison/rss'), |
| 127 |
] |