Distrowatch by yodha8

Merge branch 'master' of https://github.com/yodha8/calibre
This commit is contained in:
Kovid Goyal 2022-06-21 07:39:40 +05:30
commit 52ce0ace59
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

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