Create recipe for DistroWatch Weekly

This commit is contained in:
yodha8 2022-06-20 12:00:35 -07:00 committed by GitHub
parent 06daad5c61
commit 324bb4b81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,59 @@
#!/usr/bin/env python
__license__ = "GPL v3"
"""DistroWatch Weekly"""
from calibre.web.feeds.news import BasicNewsRecipe
import datetime
class DistroWatchWeekly(BasicNewsRecipe):
title = "DistroWatch Weekly"
description = "Weekly news about Linux distributions"
category = "Linux, Technology, News"
oldest_article = 14
language = "en"
max_articles_per_feed = 50
no_stylesheets = True
use_embedded_content = False
timefmt = " [%A, %d %B, %Y]"
auto_cleanup = False
keep_only_tags = [
dict(
attrs={
"class":
lambda x: x and ("News1" in x)
}
)
]
def _get_mag_date(self):
"""Return date of latest weekly issue."""
d = datetime.date(2022, 6, 20)
t = datetime.date.today()
ld = None
while d <= t:
ld = d
d += datetime.timedelta(days=7)
return ld
def parse_index(self):
# Get URL of latest mag page
ld = self._get_mag_date()
url = ld.strftime("https://distrowatch.com/weekly.php?issue=%Y%m%d")
url = url.lower()
title = ld.strftime("DistroWatch Weekly for %Y-%m-%d")
# Get articles
stories = [{
"url": url,
"title": title,
},]
index = [
("Articles", stories),
]
return index