mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
bcaebe54eb
@ -81,6 +81,19 @@ class TheAtlantic(BasicNewsRecipe):
|
||||
language = 'en'
|
||||
encoding = 'utf-8'
|
||||
|
||||
recipe_specific_options = {
|
||||
'date': {
|
||||
'short': 'The date of the edition to download (YYYY/MM format)',
|
||||
'long': 'For example, 2024/05'
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
BasicNewsRecipe.__init__(self, *args, **kwargs)
|
||||
d = self.recipe_specific_options.get('date')
|
||||
if d and isinstance(d, str):
|
||||
self.INDEX = 'https://www.theatlantic.com/magazine/toc/' + d + '/'
|
||||
|
||||
keep_only_tags = [
|
||||
dict(itemprop=['headline']),
|
||||
classes(
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
import json
|
||||
from urllib.parse import quote, urlparse
|
||||
|
||||
@ -118,6 +120,13 @@ class CaravanMagazine(BasicNewsRecipe):
|
||||
return br
|
||||
return br
|
||||
|
||||
recipe_specific_options = {
|
||||
'date': {
|
||||
'short': 'The date of the edition to download (MM-YYYY format)',
|
||||
'long': 'For example, 07-2024'
|
||||
}
|
||||
}
|
||||
|
||||
def parse_index(self):
|
||||
self.log(
|
||||
'\n***\nif this recipe fails, report it on: '
|
||||
@ -125,9 +134,11 @@ class CaravanMagazine(BasicNewsRecipe):
|
||||
)
|
||||
|
||||
api = 'https://api.caravanmagazine.in/api/trpc/magazines.getLatestIssue'
|
||||
# for past editions
|
||||
# inp = json.dumps({"0":{"json":{"month":6,"year":2023}}})
|
||||
# api = 'https://api.caravanmagazine.in/api/trpc/magazines.getForMonthAndYear?batch=1&input=' + quote(inp, safe='')
|
||||
d = self.recipe_specific_options.get('date')
|
||||
if d and isinstance(d, str):
|
||||
x = d.split('-')
|
||||
inp = json.dumps({"0":{"json":{"month":int(x[0]),"year":int(x[1])}}})
|
||||
api = 'https://api.caravanmagazine.in/api/trpc/magazines.getForMonthAndYear?batch=1&input=' + quote(inp, safe='')
|
||||
|
||||
raw = json.loads(self.index_to_soup(api, raw=True))
|
||||
if isinstance(raw, list):
|
||||
|
@ -127,6 +127,13 @@ class ForeignAffairsRecipe(BasicNewsRecipe):
|
||||
|
||||
INDEX = 'https://www.foreignaffairs.com/magazine'
|
||||
|
||||
recipe_specific_options = {
|
||||
'issue': {
|
||||
'short': 'Enter the Issue Number you want to download ',
|
||||
'long': 'For example, 2024/103/1'
|
||||
}
|
||||
}
|
||||
|
||||
keep_only_tags = [
|
||||
classes('article-header article-body article-lead-image article-body-text'),
|
||||
]
|
||||
@ -140,6 +147,10 @@ class ForeignAffairsRecipe(BasicNewsRecipe):
|
||||
remove_empty_feeds = True
|
||||
|
||||
def parse_index(self):
|
||||
d = self.recipe_specific_options.get('issue')
|
||||
if d and isinstance(d, str):
|
||||
self.INDEX = 'https://www.foreignaffairs.com/issues/' + d
|
||||
|
||||
soup = self.index_to_soup(self.INDEX)
|
||||
# get dates
|
||||
date = re.split(r'\s\|\s', self.tag_to_string(
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8
|
||||
from collections import defaultdict
|
||||
|
||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||
@ -53,8 +55,20 @@ class Frontline(BasicNewsRecipe):
|
||||
src.extract()
|
||||
return soup
|
||||
|
||||
recipe_specific_options = {
|
||||
'issue': {
|
||||
'short': 'Enter the Issue Number you want to download\n(Volume-Issue format)',
|
||||
'long': 'For example, 41-12'
|
||||
}
|
||||
}
|
||||
|
||||
def parse_index(self):
|
||||
soup = self.index_to_soup('https://frontline.thehindu.com/current-issue/')
|
||||
issue_url = 'https://frontline.thehindu.com/current-issue/'
|
||||
d = self.recipe_specific_options.get('issue')
|
||||
if d and isinstance(d, str):
|
||||
issue_url = 'https://frontline.thehindu.com/magazine/issue/vol' + d
|
||||
|
||||
soup = self.index_to_soup(issue_url)
|
||||
|
||||
if cover := soup.find('div', attrs={'class':'magazine'}):
|
||||
self.cover_url = cover.find(**classes('sptar-image')).img['data-original'].replace('_320', '_1200')
|
||||
@ -82,4 +96,4 @@ class Frontline(BasicNewsRecipe):
|
||||
continue
|
||||
self.log(section, '\n\t', title, '\n\t', desc, '\n\t\t', url)
|
||||
feeds_dict[section].append({"title": title, "url": url, "description": desc})
|
||||
return [(section, articles) for section, articles in feeds_dict.items()]
|
||||
return [(section, articles) for section, articles in feeds_dict.items()]
|
||||
|
@ -72,7 +72,7 @@ class Harpers(BasicNewsRecipe):
|
||||
edition = self.recipe_specific_options.get('date')
|
||||
if edition and isinstance(edition, str):
|
||||
url = 'https://harpers.org/archive/' + edition
|
||||
self.timefmt = ' [' +edition + ']'
|
||||
self.timefmt = ' [' + edition + ']'
|
||||
|
||||
soup = self.index_to_soup(url)
|
||||
cov_div = soup.find('div', attrs={'class':'issue-cover'})
|
||||
|
@ -39,8 +39,6 @@ class TheHindufeeds(BasicNewsRecipe):
|
||||
d = self.recipe_specific_options.get('days')
|
||||
if d and isinstance(d, str):
|
||||
self.oldest_article = float(d)
|
||||
if self.output_profile.short_name.startswith('kindle'):
|
||||
self.title = 'The Hindu (Feeds) ' + date.today().strftime('%b %d, %Y')
|
||||
|
||||
ignore_duplicate_articles = {'url'}
|
||||
|
||||
|
@ -57,7 +57,6 @@ class ht(BasicNewsRecipe):
|
||||
|
||||
self.timefmt = ' [%s]' % today
|
||||
|
||||
day, month, year = (int(x) for x in today.split('/'))
|
||||
today = today.replace('/', '%2F')
|
||||
|
||||
get_edition = index + '/Home/GetEditionSupplementHierarchy?EditionDate=' + today
|
||||
|
Loading…
x
Reference in New Issue
Block a user