add imdb full import mode
This commit is contained in:
parent
b5cb22822e
commit
7dd10f8bc3
17 changed files with 721 additions and 109 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
from dataclasses import asdict, dataclass, field, fields, is_dataclass
|
||||
from dataclasses import asdict, dataclass, field, fields
|
||||
from datetime import datetime, timezone
|
||||
from typing import Any, ClassVar, Optional, Type, Union, get_args, get_origin
|
||||
|
||||
|
|
@ -25,6 +25,12 @@ def optional_type(tp: Type):
|
|||
return args[0]
|
||||
|
||||
|
||||
def optional_fields(o):
|
||||
for f in fields(o):
|
||||
if is_optional(f.type):
|
||||
yield f
|
||||
|
||||
|
||||
def asplain(o) -> dict[str, Any]:
|
||||
validate(o)
|
||||
|
||||
|
|
@ -56,9 +62,6 @@ def asplain(o) -> dict[str, Any]:
|
|||
|
||||
|
||||
def fromplain(cls, d: dict[str, Any]):
|
||||
# if not is_dataclass(cls):
|
||||
# raise TypeError(f'Not a dataclass: {type(cls)}')
|
||||
|
||||
dd = {}
|
||||
for f in fields(cls):
|
||||
|
||||
|
|
@ -107,11 +110,14 @@ class Movie:
|
|||
_table: ClassVar[str] = "movies"
|
||||
|
||||
id: ULID = field(default_factory=ULID)
|
||||
title: str = None # canonical title
|
||||
title: str = None # canonical title (usually English)
|
||||
original_title: Optional[
|
||||
str
|
||||
] = None # original title (usually transscribed to latin script)
|
||||
release_year: int = None # canonical release date
|
||||
media_type: Optional[str] = None
|
||||
media_type: str = None
|
||||
imdb_id: str = None
|
||||
score: int = None # range: [0,100]
|
||||
score: Optional[int] = None # range: [0,100]
|
||||
runtime: Optional[int] = None # minutes
|
||||
genres: set[str] = None
|
||||
updated: datetime = field(default_factory=utcnow)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue