use my_configuration for imdb/youtube

This commit is contained in:
Dima Gerasimov 2019-12-01 13:48:38 +00:00
parent 52db4e740a
commit 585206f72d
2 changed files with 20 additions and 11 deletions

View file

@ -4,15 +4,13 @@ import json
from datetime import datetime
from typing import Iterator, List, NamedTuple
from ..paths import BACKUPS
from ..common import get_files
# TODO eh. rename to my_cfg? easier to type
from my_configuration import paths
BDIR = BACKUPS / 'imdb'
def get_last():
# TODO wonder where did json come from..
return max(BDIR.glob('*.csv'))
def _get_last():
return max(get_files(paths.imdb.export_path, glob='*.csv'))
class Movie(NamedTuple):
@ -22,14 +20,14 @@ class Movie(NamedTuple):
def iter_movies() -> Iterator[Movie]:
last = get_last()
last = _get_last()
with last.open() as fo:
reader = csv.DictReader(fo)
for i, line in enumerate(reader):
# TODO extract directors??
title = line['Title']
rating = line['You rated']
rating = int(line['You rated'])
createds = line['created']
created = datetime.strptime(createds, '%a %b %d %H:%M:%S %Y')
# TODO const??

View file

@ -6,7 +6,17 @@ from pathlib import Path
from kython.ktakeout import TakeoutHTMLParser
from kython.kompress import open as kopen
BDIR = Path("/L/backups/takeout/karlicoss_gmail_com/")
from ..common import get_files
from my_configuration import paths
def _get_last_takeout():
# TODO FIXME might be a good idea to merge across multiple taekouts...
# perhaps even a special takeout module that deals with all of this automatically?
# e.g. accumulate, filter and maybe report useless takeouts?
return max(get_files(paths.google.takeout_path, glob='*.zip'))
class Watched(NamedTuple):
url: str
@ -17,8 +27,9 @@ class Watched(NamedTuple):
def eid(self) -> str:
return f'{self.url}-{self.when.isoformat()}'
def get_watched():
last = max(BDIR.glob('*.zip'))
last = _get_last_takeout()
watches: List[Watched] = []
def cb(dt, url, title):