From 1c0796be450445322b7c13983e262cdc31d7d934 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 18 Feb 2022 07:16:39 +0530 Subject: [PATCH] Update Publico.PT Fixes #1961348 [Fix username/password on Publico recipe](https://bugs.launchpad.net/calibre/+bug/1961348) --- recipes/publico.recipe | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/recipes/publico.recipe b/recipes/publico.recipe index 7f72e93180..d79c9d28a2 100644 --- a/recipes/publico.recipe +++ b/recipes/publico.recipe @@ -9,6 +9,7 @@ publico.pt ''' from calibre.web.feeds.news import BasicNewsRecipe +from polyglot.urllib import urlencode def classes(classes): @@ -29,6 +30,7 @@ class PublicoPT(BasicNewsRecipe): language = 'pt' remove_empty_feeds = True extra_css = ' body{font-family: Arial,Helvetica,sans-serif } img{margin-bottom: 0.4em} ' + needs_subscription = True keep_only_tags = [ dict(id='story-content story-header'.split()), @@ -53,6 +55,23 @@ class PublicoPT(BasicNewsRecipe): (u'Tecnologia', u'http://feeds.feedburner.com/PublicoTecnologia') ] + def get_browser(self): + br = BasicNewsRecipe.get_browser(self) + if self.username is not None and self.password is not None: + postdata = urlencode({ + 'username': self.username, + 'password': self.password + }) + br.open( + 'https://www.publico.pt/api/user/login', + data=postdata, + timeout=self.timeout + ) + + br.set_handle_refresh(True) + + return br + def preprocess_html(self, soup): for img in soup.findAll('img', attrs={'data-media-viewer':True}): img['src'] = img['data-media-viewer']