Fix sorting of sections in India Today

This commit is contained in:
Kovid Goyal 2022-05-29 15:03:29 +05:30
parent b815560dd1
commit 337cb2189f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -54,25 +54,14 @@ class IndiaToday(BasicNewsRecipe):
'title': title,
'url': url})
feeds = []
def sort_key(x):
section = x[0]
try:
return ('EDITOR\'S NOTE', 'Cover Story', 'The Big Story', 'Upfront', 'NATION', 'INTERVIEW').index(section)
except Exception:
return 99999999
# Insert feeds in specified order, if available
feedSort = ['EDITOR\'S NOTE', 'Cover Story', 'The Big Story', 'Upfront', 'NATION', 'INTERVIEW']
for i in feedSort:
if i in sections:
feeds.append((i, sections[i]))
# Done with the sorted feeds
for i in feedSort:
del sections[i]
# Append what is left over...
for i in sections:
feeds.append((i, sections[i]))
return feeds
return sorted(sections.items(), key=sort_key)
def preprocess_raw_html(self, raw_html, url):
from calibre.ebooks.BeautifulSoup import BeautifulSoup