mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix sorting of sections in India Today
This commit is contained in:
parent
b815560dd1
commit
337cb2189f
@ -54,25 +54,14 @@ class IndiaToday(BasicNewsRecipe):
|
|||||||
'title': title,
|
'title': title,
|
||||||
'url': url})
|
'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
|
return sorted(sections.items(), key=sort_key)
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def preprocess_raw_html(self, raw_html, url):
|
def preprocess_raw_html(self, raw_html, url):
|
||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user