1
0
personal-data/personal_data/__main__.py

48 lines
1.3 KiB
Python
Raw Normal View History

2024-04-16 21:23:27 +00:00
import argparse
2024-04-16 22:45:15 +00:00
import logging
2024-04-16 21:23:27 +00:00
2024-04-23 20:58:25 +00:00
import personal_data.main
2024-06-02 21:14:19 +00:00
from personal_data.notification import NotificationType
2024-04-23 20:58:25 +00:00
2024-04-16 21:23:27 +00:00
def parse_arguments():
2024-04-28 21:45:47 +00:00
available_scraper_names = personal_data.main.available_scraper_names()
2024-04-16 21:23:27 +00:00
parser = argparse.ArgumentParser()
2024-05-09 14:59:56 +00:00
parser.add_argument(
'fetchers',
metavar='FETCHER',
type=str,
nargs='+',
choices=available_scraper_names,
)
2024-04-23 20:58:25 +00:00
parser.add_argument('--cookiejar', action='store_true')
2024-05-09 14:59:56 +00:00
parser.add_argument('--email', action='store_true', dest='send_email_notification')
2024-06-02 21:16:11 +00:00
parser.add_argument(
'--loud-sound', action='store_true', dest='trigger_loud_and_annoying_sound',
)
2024-04-16 21:23:27 +00:00
return parser.parse_args()
2024-04-23 20:58:25 +00:00
2024-04-16 21:23:27 +00:00
def main():
2024-04-16 22:45:15 +00:00
logging.basicConfig()
logging.getLogger('personal_data').setLevel('INFO')
2024-04-16 21:23:27 +00:00
args = parse_arguments()
scraper_filter = frozenset(args.fetchers)
2024-06-02 21:14:19 +00:00
# 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)
2024-05-09 14:59:56 +00:00
personal_data.main.main(
scraper_filter,
use_cookiejar=args.cookiejar,
2024-06-02 21:16:11 +00:00
notification_types=frozenset(notification_types),
2024-05-09 14:59:56 +00:00
)
2024-04-23 20:58:25 +00:00
2024-03-31 22:55:55 +00:00
2023-12-10 23:27:56 +00:00
if __name__ == '__main__':
2024-04-16 21:23:27 +00:00
main()