[lifeevents] Add metadata dataclasses
This commit is contained in:
@ -2,7 +2,7 @@ from django.apps import apps
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
import pendulum
|
import pendulum
|
||||||
from lifeevents.dataclasses import LifeEventMetadata
|
from scrobbles.dataclasses import LifeEventMetadata
|
||||||
from scrobbles.mixins import ScrobblableMixin
|
from scrobbles.mixins import ScrobblableMixin
|
||||||
|
|
||||||
BNULL = {"blank": True, "null": True}
|
BNULL = {"blank": True, "null": True}
|
||||||
|
|||||||
57
vrobbler/apps/scrobbles/dataclasses.py
Normal file
57
vrobbler/apps/scrobbles/dataclasses.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import json
|
||||||
|
from dataclasses import dataclass, asdict
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
class JSONMetadata(object):
|
||||||
|
@property
|
||||||
|
def asdict(self):
|
||||||
|
return asdict(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def json(self):
|
||||||
|
return json.dumps(self.asdict)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class BoardGameScore(JSONMetadata):
|
||||||
|
user_id: int
|
||||||
|
score: Optional[int]
|
||||||
|
win: Optional[bool]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class BoardGameMetadata(JSONMetadata):
|
||||||
|
players: Optional[list[BoardGameScore]]
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class LifeEventMetadata(JSONMetadata):
|
||||||
|
location: Optional[str]
|
||||||
|
geo_location_id: Optional[int]
|
||||||
|
participant_user_ids: Optional[list[int]]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def __dict__(self):
|
||||||
|
return asdict(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def json(self):
|
||||||
|
return json.dumps(self.__dict__)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class VideoMetadata(JSONMetadata):
|
||||||
|
title: str
|
||||||
|
video_type: str
|
||||||
|
run_time_seconds: int
|
||||||
|
kind: str
|
||||||
|
year: Optional[int]
|
||||||
|
episode_number: Optional[int]
|
||||||
|
source_url: Optional[str]
|
||||||
|
imdbID: Optional[str]
|
||||||
|
season_number: Optional[int]
|
||||||
|
cover_url = Optional[str]
|
||||||
|
next_imdb_id: Optional[int]
|
||||||
|
tv_series_id: Optional[str]
|
||||||
Reference in New Issue
Block a user