Skip to content

Commit

Permalink
Refactor YouTubeDLPDownloadResult class to use 'data' attribute inste…
Browse files Browse the repository at this point in the history
…ad of 'dumped_json'
  • Loading branch information
MU-Software committed Jan 21, 2024
1 parent 0ff7d86 commit d6ab5cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/util/ext_api/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class YouTubeDLPDownloadResult(pydantic.BaseModel):

@pydantic.computed_field # type: ignore[misc]
@functools.cached_property
def dumped_json(self) -> dict[str, typing.Any]:
def data(self) -> dict[str, typing.Any]:
return json.loads(self.stdout.splitlines()[0])

@pydantic.computed_field # type: ignore[misc]
Expand All @@ -183,17 +183,17 @@ def file_path(self) -> pt.Path:
@pydantic.computed_field # type: ignore[misc]
@functools.cached_property
def id(self) -> str:
return self.dumped_json["id"]
return self.data["id"]

@pydantic.computed_field # type: ignore[misc]
@functools.cached_property
def title(self) -> str:
return self.dumped_json["title"]
return self.data["title"]

@pydantic.computed_field # type: ignore[misc]
@functools.cached_property
def quality(self) -> str:
return self.dumped_json["format"]
return self.data["format"]

@pydantic.model_validator(mode="after")
def validate(self) -> typing.Self:
Expand Down

0 comments on commit d6ab5cd

Please sign in to comment.