56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
import argparse
|
|
import logging
|
|
|
|
import personal_data.main
|
|
from personal_data.notification import NotificationType
|
|
|
|
|
|
def parse_arguments():
|
|
available_scraper_names = personal_data.main.available_scraper_names()
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument(
|
|
'fetchers',
|
|
metavar='FETCHER',
|
|
type=str,
|
|
nargs='+',
|
|
choices=available_scraper_names,
|
|
)
|
|
parser.add_argument('--cookiejar', action='store_true')
|
|
parser.add_argument('--email', action='store_true', dest='send_email_notification')
|
|
parser.add_argument(
|
|
'--loud-sound',
|
|
action='store_true',
|
|
dest='trigger_loud_and_annoying_sound',
|
|
)
|
|
parser.add_argument(
|
|
'--ignore-cache',
|
|
action='store_true',
|
|
dest='ignore_cache',
|
|
)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main():
|
|
logging.basicConfig()
|
|
logging.getLogger('personal_data').setLevel('INFO')
|
|
args = parse_arguments()
|
|
scraper_filter = frozenset(args.fetchers)
|
|
|
|
# Determine notification sounds
|
|
notification_types = set()
|
|
if args.send_email_notification:
|
|
notification_types.add(NotificationType.EMAIL)
|
|
if args.trigger_loud_and_annoying_sound:
|
|
notification_types.add(NotificationType.LOUD_SOUND)
|
|
|
|
personal_data.main.main(
|
|
scraper_filter,
|
|
use_cookiejar=args.cookiejar,
|
|
notification_types=frozenset(notification_types),
|
|
ignore_cache=args.ignore_cache,
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|