From 5b0c506b07af7e47fffc10f906e9386160794ca6 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Wed, 17 May 2023 23:55:41 +0530 Subject: [PATCH] ... Cover for Irish Times & other small changes. --- recipes/hindu.recipe | 2 +- recipes/icons/livemint.png | Bin 612 -> 343 bytes recipes/irish_times.recipe | 17 +++++++++++++++++ recipes/irish_times_free.recipe | 9 +++++++++ recipes/livemint.recipe | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/recipes/hindu.recipe b/recipes/hindu.recipe index c5e0c07801..9c82b8dd03 100644 --- a/recipes/hindu.recipe +++ b/recipes/hindu.recipe @@ -27,7 +27,7 @@ class TheHindu(BasicNewsRecipe): extra_css = ''' .caption {font-size:small; text-align:center;} .author, .dateLine {font-size:small; font-weight:bold;} - .subhead, .subhead_lead {font-weight:bold;} + .subhead, .subhead_lead, .bold {font-weight:bold;} img {display:block; margin:0 auto;} .italic {font-style:italic; color:#202020;} ''' diff --git a/recipes/icons/livemint.png b/recipes/icons/livemint.png index 68f745e747673ce518e6d42b2fe8f2563108d52e..3d4457826c0a232736f920ef338a205e28dfd7b0 100644 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyP60k4u0ENCpC>V3qW}N@e_QMD z=gIz`CmX&lGx#!7;NOq;Ul%C+`*{Dy?u1|G`~SW^|9wlq@4M^etU9ZJrm>d<`2{l= zI21I@->>(;ECVRC*VDx@q~g}u$?ihU20X3@eRo`(bm#vn##)861Ip7XxlP>eCtqFW zBI#zjUBjFG+p0|2xdm@;u7BC2`FC30hNk@i5~~($|FMEgsWjwh;lGdxHEogwVI3FB zeR}?W;{9o>m*!JFr-Y+w2EWe&(LEF5?($Y7pDx^e_>kRs`$kRHiA*IQ&$G;V)?l9~ zW!bIyp-?WsON6WIE`z^|Mrmxq#Wimnt!8e`_sZICW6&e!<|h%A`Q~-=+ND>kckOxf btDZ6Hw|HSo(ycW>k1%+;`njxgN@xNAekPjm literal 612 zcmV-q0-ODbP)9oymEF^x2=nA`fJ*1RkYEX5~(%^1{EWuEo1%Oh}ziNjKVS9>qePs zW@yA-iJXv%8$=0Nm=XeM+4pQVrg(Pt?%8{u&-eL0&pBkXW>w0+N`-W}_<3W!RC~G& z_@0`W8#GwR;(?Pd5REbU|nf=zVR&Zev^*v{nh z)O(yLzKa5=tgVD>jZuqg>@tsCVn|Xt8G@l^I&NXGG}yv=_4LtEGH~U{#`~~e&4DZ{pYHH zury*i5Ht|f9W>B)CXqC9K>&ScDM?vHPA_Wi_TUFiCuxT`Vg y*_ZSmPK_B>b2Hl?U(G6)O2zylcBNdYJ^cr79Pj{ib+hCE0000LmmK diff --git a/recipes/irish_times.recipe b/recipes/irish_times.recipe index 5574f975b9..b868d152da 100644 --- a/recipes/irish_times.recipe +++ b/recipes/irish_times.recipe @@ -39,6 +39,23 @@ class IrishTimes(BasicNewsRecipe): classes('sm-promo-headline top-table-list-container single-divider interstitial-link'), ] remove_attributes = ['width', 'height'] + + def get_cover_url(self): + from datetime import date + cover = 'https://img.kiosko.net/' + date.today().strftime('%Y/%m/%d') + '/ie/irish_times.750.jpg' + br = BasicNewsRecipe.get_browser(self, verify_ssl_certificates=False) + try: + br.open(cover) + except: + index = 'https://en.kiosko.net/ie/np/irish_times.html' + soup = self.index_to_soup(index) + for image in soup.find('img', attrs={'src': lambda x: x and x.endswith('750.jpg')}): + if image['src'].startswith('/'): + return 'https:' + image['src'] + return image['src'] + self.log("\nCover unavailable") + cover = None + return cover def parse_index(self): soup = self.index_to_soup('https://www.irishtimes.com/') diff --git a/recipes/irish_times_free.recipe b/recipes/irish_times_free.recipe index 7e150dfbef..cf1d16ae69 100644 --- a/recipes/irish_times_free.recipe +++ b/recipes/irish_times_free.recipe @@ -66,6 +66,15 @@ class IrishTimes(BasicNewsRecipe): pt.close() return pt.name + def __init__(self, *args, **kwargs): + BasicNewsRecipe.__init__(self, *args, **kwargs) + if self.output_profile.short_name.startswith('kindle'): + # Reduce image sizes to get file size below amazon's email + # sending threshold + self.web2disk_options.compress_news_images = True + self.web2disk_options.compress_news_images_auto_size = 5 + self.log.warn('Kindle Output profile being used, reducing image quality to keep file size below amazon email threshold') + feeds = [] sections = [ diff --git a/recipes/livemint.recipe b/recipes/livemint.recipe index 4b990afd37..584b701843 100644 --- a/recipes/livemint.recipe +++ b/recipes/livemint.recipe @@ -129,6 +129,8 @@ class LiveMint(BasicNewsRecipe): return raw def preprocess_html(self, soup): + for h2 in soup.find('h2'): + h2.name = 'p' for span in soup.findAll('figcaption'): span['id'] = 'img-cap' for auth in soup.findAll('span', attrs={'class':['articleInfo pubtime','articleInfo author']}):