'''
https://www.economist.com/the-world-in-brief
'''

from calibre.web.feeds.news import BasicNewsRecipe, classes

class Espresso(BasicNewsRecipe):
           
    title = 'The Economist Search1'

           
    language = 'en'
    __author__ = 'unkn0wn'
    description = (
        'Espresso is a rich, full-flavoured shot of daily global analysis'
        ' from the editors of The Economist to get you up to speed, fast.'
         'Maximise your understanding of the most significant business, '
         'economic, political and cultural developments globally.'
    )
    no_stylesheets = True
    remove_attributes = ['height', 'width', 'style']
    use_embedded_content = False

    extra_css = '''
        h1 { text-align:center; }
        ._main-image, ._description { text-align:center; font-size:small; }
        ._quote-container { font-size:x-large; font-style:italic; color:#202020; }
    '''

    keep_only_tags = [
        dict(name='main', attrs={'id':'content'})
    ]

    remove_tags = [
        classes('_podcast-promo _newsletter-promo-container _time-last-updated')
    ]

    def parse_index(self):
        return [
            ('Espresso',
                [
                    {
                        'title': 'ChatGPT',
                        'url': 'https://www.economist.com/search?q=chatgpt&sort=date',
                    },
                ]
            ),
        ]

    def preprocess_html(self, soup):
        for h3 in soup.findAll('h3'):
            h3.name = 'h1'
        return soup


calibre_most_common_ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36'