diff --git a/recipes/scmp.recipe b/recipes/scmp.recipe index de4545aa18..e41c669545 100644 --- a/recipes/scmp.recipe +++ b/recipes/scmp.recipe @@ -72,6 +72,27 @@ class SCMP(BasicNewsRecipe): ("Style", "https://www.scmp.com/rss/72/feed"), ] + masthead_url = 'https://upload.wikimedia.org/wikipedia/commons/c/c3/SCMP_logo.svg' + + def get_cover_url(self): + from datetime import date + cover = 'https://img.kiosko.net/' + str( + date.today().year + ) + '/' + date.today().strftime('%m') + '/' + date.today( + ).strftime('%d') + '/cn/scmp.750.jpg' + br = BasicNewsRecipe.get_browser(self) + try: + br.open(cover) + except: + index = 'https://es.kiosko.net/cn/np/scmp.html' + soup = self.index_to_soup(index) + for image in soup.findAll('img', src=True): + if image['src'].endswith('750.jpg'): + return 'https:' + image['src'] + self.log("\nCover unavailable") + cover = None + return cover + def _extract_child_nodes(self, children, ele, soup, level=1): if not children: return @@ -167,6 +188,10 @@ class SCMP(BasicNewsRecipe): date_published_loc = date_published.astimezone( timezone(offset=timedelta(hours=8)) # HK time ) + try: + df = date_published_loc.strftime('%-I:%M%p, %-d %b, %Y') + except Exception: + df = '' html_output = f"""