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')