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
d231b9f8e4
@ -11,23 +11,6 @@ def absurl(url):
|
|||||||
url = 'https://www.thehindu.com' + url
|
url = 'https://www.thehindu.com' + url
|
||||||
return url
|
return url
|
||||||
|
|
||||||
# Chennai is default edition, for other editions use 'th_hyderabad', 'th_bangalore', 'th_delhi', 'th_kolkata' etc
|
|
||||||
local_edition = None
|
|
||||||
|
|
||||||
# For past editions, set date to, for example, '2023-01-28'
|
|
||||||
past_edition = None
|
|
||||||
|
|
||||||
is_monday = date.today().weekday() == 0
|
|
||||||
is_friday = date.today().weekday() == 4
|
|
||||||
is_saturday = date.today().weekday() == 5
|
|
||||||
is_sunday = date.today().weekday() == 6
|
|
||||||
|
|
||||||
if past_edition:
|
|
||||||
year, month, day = (int(x) for x in past_edition.split('-'))
|
|
||||||
dt = date(year, month, day)
|
|
||||||
is_monday = dt.weekday() == 0
|
|
||||||
is_saturday = dt.weekday() == 5
|
|
||||||
is_sunday = dt.weekday() == 6
|
|
||||||
|
|
||||||
class TheHindu(BasicNewsRecipe):
|
class TheHindu(BasicNewsRecipe):
|
||||||
title = 'The Hindu'
|
title = 'The Hindu'
|
||||||
@ -46,6 +29,17 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
.italic, .sub-title {font-style:italic; color:#202020;}
|
.italic, .sub-title {font-style:italic; color:#202020;}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
recipe_specific_options = {
|
||||||
|
'location': {
|
||||||
|
'short': 'The name of the local edition',
|
||||||
|
'long': 'If The Hindu is available in your local town/city,\nset this to your location, for example, hyderabad'
|
||||||
|
},
|
||||||
|
'date': {
|
||||||
|
'short': 'The date of the edition to download (YYYY-MM-DD format)',
|
||||||
|
'long': 'For example, 2023-01-28'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
@ -65,17 +59,24 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
h3.name = 'p'
|
h3.name = 'p'
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
BasicNewsRecipe.__init__(self, *args, **kwargs)
|
|
||||||
if self.output_profile.short_name.startswith('kindle'):
|
|
||||||
if not past_edition:
|
|
||||||
self.title = 'The Hindu ' + date.today().strftime('%b %d, %Y')
|
|
||||||
else:
|
|
||||||
self.title = 'The Hindu ' + dt.strftime('%b %d, %Y')
|
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
mag_url = None
|
mag_url = None
|
||||||
global local_edition
|
local_edition = self.recipe_specific_options.get('location')
|
||||||
|
if local_edition:
|
||||||
|
local_edition = 'th_' + local_edition
|
||||||
|
past_edition = self.recipe_specific_options.get('date')
|
||||||
|
|
||||||
|
dt = date.today()
|
||||||
|
if past_edition:
|
||||||
|
year, month, day = (int(x) for x in past_edition.split('-'))
|
||||||
|
dt = date(year, month, day)
|
||||||
|
|
||||||
|
is_monday = dt.weekday() == 0
|
||||||
|
is_friday = dt.weekday() == 4
|
||||||
|
is_saturday = dt.weekday() == 5
|
||||||
|
is_sunday = dt.weekday() == 6
|
||||||
|
|
||||||
|
|
||||||
if local_edition or past_edition:
|
if local_edition or past_edition:
|
||||||
if local_edition is None:
|
if local_edition is None:
|
||||||
local_edition = 'th_chennai'
|
local_edition = 'th_chennai'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user