#!/usr/pkg/bin/python3.13
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe


class AdvancedUserRecipe(BasicNewsRecipe):
    title          = 'Macrobusiness'
    language       = 'en_AU'
    __author__     = '2018robert'
    oldest_article = 1
    max_articles_per_feed = 100
    auto_cleanup   = True
    needs_subscription = 'optional'

    feeds          = [
        ('Macrobusiness', 'https://www.macrobusiness.com.au/feed'),
    ]

    def get_browser(self):
        br = BasicNewsRecipe.get_browser(self)
        if self.username is not None and self.password is not None:
            br.open('https://www.macrobusiness.com.au/my-account/')
            br.select_form(class_=lambda x: 'login' in x)
            br['username']   = self.username
            br['password'] = self.password
            br.submit()
        return br
