Update LWN Weekly

Fix #809 (lwn weekly shows "Unknown feed" and "Undefined article title" for almost all TOC items)
This commit is contained in:
Kovid Goyal 2018-02-01 06:27:59 +05:30
parent 1c20f656d2
commit 7eea7600ae
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -83,7 +83,7 @@ class WeeklyLWN(BasicNewsRecipe):
articles = {} articles = {}
ans = [] ans = []
section = soup.title.string section = self.tag_to_string(soup.title)
subsection = None subsection = None
while True: while True:
@ -93,16 +93,16 @@ class WeeklyLWN(BasicNewsRecipe):
if curr is None: if curr is None:
break break
text = curr.contents[0].string text = self.tag_to_string(curr.contents[0])
if 'Cat2HL' in curr.attrMap['class']: if 'Cat2HL' in curr['class']:
subsection = text subsection = text
elif 'Cat1HL' in curr.attrMap['class']: elif 'Cat1HL' in curr['class']:
section = text section = text
subsection = None subsection = None
elif 'SummaryHL' in curr.attrMap['class']: elif 'SummaryHL' in curr['class']:
article_title = text article_title = text
if not article_title: if not article_title:
article_title = _('Undefined article title') article_title = _('Undefined article title')
@ -125,7 +125,7 @@ class WeeklyLWN(BasicNewsRecipe):
continue continue
else: else:
print >>sys.stderr, 'article_anchor is None for "%s"; skipping' % article_title self.log.warn('article_anchor is None for "%s"; skipping' % article_title)
article_url = None article_url = None
continue continue
@ -141,7 +141,7 @@ class WeeklyLWN(BasicNewsRecipe):
}) })
else: else:
print >>sys.stderr, "lwn_weekly.recipe: something bad happened; should not be able to reach this" self.log.error("lwn_weekly.recipe: something bad happened; should not be able to reach this")
ans = [(section2, articles[section2]) ans = [(section2, articles[section2])
for section2 in ans if section2 in articles] for section2 in ans if section2 in articles]