From 1bec410cf6e32b0b032e38ad0b7041f21ac5d5c5 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Sun, 27 Jul 2025 11:07:38 +0530 Subject: [PATCH] Update wsj_mag.recipe add cover --- recipes/wsj_mag.recipe | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/recipes/wsj_mag.recipe b/recipes/wsj_mag.recipe index 0337258914..30fc08c777 100644 --- a/recipes/wsj_mag.recipe +++ b/recipes/wsj_mag.recipe @@ -157,6 +157,28 @@ class WSJ(BasicNewsRecipe): pan.name = 'div' return soup + def _download_cover(self): + import os + from contextlib import closing + + from calibre.utils.img import save_cover_data_to + br = browser() + raw = br.open('https://wsjtodaysedition.cmail19.com/t/d-e-suujjg-thithlkhlr-r/') + soup = BeautifulSoup(raw.read()) + cu = soup.find( + 'img', + attrs={ + 'class': 'responsive-img', + 'src': lambda x: x and 'WSJMagazine' in x + } + )['src'] + self.report_progress(1, _('Downloading cover from %s')%cu) + with closing(br.open(cu, timeout=self.timeout)) as r: + cdata = r.read() + cpath = os.path.join(self.output_dir, 'cover.jpg') + save_cover_data_to(cdata, cpath) + self.cover_path = cpath + def get_browser(self, *args, **kw): br = BasicNewsRecipe.get_browser(self, *args, **kw) br.addheaders += [