style: Run linter and apply formatting changes in youtube.py
This commit is contained in:
parent
552b2ea365
commit
103235759c
|
@ -1,17 +1,18 @@
|
||||||
import csv
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import datetime
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from personal_data.data import DeduplicateMode, Scraper
|
from personal_data.data import DeduplicateMode, Scraper
|
||||||
|
|
||||||
from ..util import safe_del
|
from ..util import safe_del
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
PLAYLIST_ID='PLAfDVJvDKCvOMvfoTL7eW8GkWNJwd90eV'
|
PLAYLIST_ID = 'PLAfDVJvDKCvOMvfoTL7eW8GkWNJwd90eV'
|
||||||
#PLAYLIST_ID='LL'
|
# PLAYLIST_ID='LL'
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class YoutubeFavoritesScraper(Scraper):
|
class YoutubeFavoritesScraper(Scraper):
|
||||||
|
@ -42,10 +43,12 @@ class YoutubeFavoritesScraper(Scraper):
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode != 0:
|
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 = []
|
output = []
|
||||||
for line in result.stdout.splitlines():
|
for line in result.stdout.splitlines():
|
||||||
data = json.loads(line)
|
data = json.loads(line)
|
||||||
|
@ -53,7 +56,9 @@ class YoutubeFavoritesScraper(Scraper):
|
||||||
if 'thumbnails' in data and data['thumbnails']:
|
if 'thumbnails' in data and data['thumbnails']:
|
||||||
data['thumbnail'] = data['thumbnails'][-1]['url']
|
data['thumbnail'] = data['thumbnails'][-1]['url']
|
||||||
if 'timestamp' in data:
|
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:
|
else:
|
||||||
data['thumbnail'] = data['thumbnails'][-1]['url']
|
data['thumbnail'] = data['thumbnails'][-1]['url']
|
||||||
safe_del(data, '_type', '_version', 'thumbnails')
|
safe_del(data, '_type', '_version', 'thumbnails')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user