From 103235759c456e00e5b5e412fb07cbf9cd4c6a87 Mon Sep 17 00:00:00 2001 From: "Jon Michael Aanes (aider)" Date: Sat, 15 Mar 2025 22:26:20 +0100 Subject: [PATCH] style: Run linter and apply formatting changes in youtube.py --- personal_data/fetchers/youtube.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/personal_data/fetchers/youtube.py b/personal_data/fetchers/youtube.py index 41bcd2b..fe12fb7 100644 --- a/personal_data/fetchers/youtube.py +++ b/personal_data/fetchers/youtube.py @@ -1,17 +1,18 @@ -import csv +import datetime import json import logging import subprocess -import datetime from dataclasses import dataclass from personal_data.data import DeduplicateMode, Scraper + from ..util import safe_del logger = logging.getLogger(__name__) -PLAYLIST_ID='PLAfDVJvDKCvOMvfoTL7eW8GkWNJwd90eV' -#PLAYLIST_ID='LL' +PLAYLIST_ID = 'PLAfDVJvDKCvOMvfoTL7eW8GkWNJwd90eV' +# PLAYLIST_ID='LL' + @dataclass(frozen=True) class YoutubeFavoritesScraper(Scraper): @@ -42,10 +43,12 @@ class YoutubeFavoritesScraper(Scraper): capture_output=True, text=True, ) - + if result.returncode != 0: - raise RuntimeError(f'Non-zero returncode in command: {result.returncode}\n\n{result.stderr}') - + raise RuntimeError( + f'Non-zero returncode in command: {result.returncode}\n\n{result.stderr}', + ) + output = [] for line in result.stdout.splitlines(): data = json.loads(line) @@ -53,7 +56,9 @@ class YoutubeFavoritesScraper(Scraper): if 'thumbnails' in data and data['thumbnails']: data['thumbnail'] = data['thumbnails'][-1]['url'] if 'timestamp' in data: - data['watch_datetime'] = datetime.datetime.fromtimestamp(int(data['timestamp'])).isoformat() + data['watch_datetime'] = datetime.datetime.fromtimestamp( + int(data['timestamp']), + ).isoformat() else: data['thumbnail'] = data['thumbnails'][-1]['url'] safe_del(data, '_type', '_version', 'thumbnails')