From 28e18fc1b42cd1fcff90924a24df8e44c7cb742b Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sun, 25 Aug 2024 22:15:13 +0200 Subject: [PATCH] Fixed title and description --- personal_data/fetchers/psnprofiles.py | 5 ++++- personal_data_calendar/__main__.py | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/personal_data/fetchers/psnprofiles.py b/personal_data/fetchers/psnprofiles.py index f191ae5..a3b2d7f 100644 --- a/personal_data/fetchers/psnprofiles.py +++ b/personal_data/fetchers/psnprofiles.py @@ -41,7 +41,10 @@ class PsnProfilesScraper(Scraper): games_rows = list(self._scrape_games_overview()) games_ids = {row['psnprofiles.game_id']: row['game.name'] for row in games_rows} - yield from games_rows + SCRAPE_FROM_OVERVIEW = False + if SCRAPE_FROM_OVERVIEW: + yield from games_rows + idx = 0 for game_id, game_name in games_ids.items(): yield from self._scrape_game_trophies(game_id, game_name) diff --git a/personal_data_calendar/__main__.py b/personal_data_calendar/__main__.py index 56171c1..a2b6a64 100644 --- a/personal_data_calendar/__main__.py +++ b/personal_data_calendar/__main__.py @@ -17,12 +17,13 @@ def parse_arguments(): def generate_calendar(rows: list[dict]) -> icalendar.Calendar: + max_title_parts = 2 + cal = icalendar.Calendar() cal.add('prodid', '-//personal_data_calendar//example.org//') cal.add('version', '2.0') for event_data in rows: - print(event_data) # Select data possible_time_keys = [ @@ -34,20 +35,20 @@ def generate_calendar(rows: list[dict]) -> icalendar.Calendar: ] date = event_data[possible_time_keys[0]] if possible_time_keys else None - title = event_data[possible_name_keys[0]] image = event_data[possible_image_keys[0]] if possible_image_keys else None if date is None: continue - description = '\n\n'.join(event_data[k] for k in possible_name_keys) + title = ': '.join(event_data[k] for k in possible_name_keys[:max_title_parts]) + description = '\n\n'.join(event_data[k] for k in possible_name_keys[max_title_parts:]) # Create event event = icalendar.Event() event.add('summary', title) event.add('description', description) event.add('dtstart', date) - event.add('dtend', date) + event.add('dtend', date + datetime.timedelta(minutes=30)) event.add('created', NOW) event.add('dtstamp', NOW) if image: @@ -62,7 +63,6 @@ def main(): args = parse_arguments() dicts = load_csv_file(args.data_folder + '/games_played_playstation.csv') - print(dicts) calendar = generate_calendar(dicts)