mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Create recipe for DistroWatch Weekly
This commit is contained in:
parent
06daad5c61
commit
324bb4b81b
59
recipes/distrowatch_weekly.recipe
Normal file
59
recipes/distrowatch_weekly.recipe
Normal 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
|
Loading…
x
Reference in New Issue
Block a user