IEEE Spectrum Magazine by yodha8

Merge branch 'master' of https://github.com/yodha8/calibre
This commit is contained in:
Kovid Goyal 2022-05-01 21:16:19 +05:30
commit 3f9d52c32b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
# vim:fileencoding=utf-8
from calibre.web.feeds.news import BasicNewsRecipe
import datetime
class IEEESpectrumMagazine(BasicNewsRecipe):
title = "IEEE Spectrum Magazine"
lang = 'en'
__author__ = 'yodha8'
description = "Published on day 1 of every month."
oldest_article = 120 # Mag gathers articles published older than a month online. So we scan for 4 months in the feed.
max_articles_per_feed = 100
auto_cleanup = True
# RSS feed for the current month
now = datetime.datetime.now()
year_month = now.strftime("%Y/%B").lower()
month_feed_url = "https://spectrum.ieee.org/feeds/magazine/{}.rss".format(
year_month
)
feeds = [
('IEEE Spectrum Magazine', month_feed_url),
]
def get_cover_url(self):
"""Go to this month's URL and pull cover image from there."""
month_url = "https://spectrum.ieee.org/magazine/{}".format(self.year_month)
soup = self.index_to_soup(month_url)
img_meta = soup.find("meta", property="og:image")
img_url = img_meta["content"]
return img_url