Skip to content

Commit

Permalink
fix: serialize subtitles for api response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli authored and dreulavelle committed Oct 11, 2024
1 parent 197713a commit 0dd561a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/program/media/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def to_extended_dict(self, abbreviated_children=False, with_streams=True):
dict["file"] = self.file if hasattr(self, "file") else None
dict["folder"] = self.folder if hasattr(self, "folder") else None
dict["symlink_path"] = self.symlink_path if hasattr(self, "symlink_path") else None
dict["subtitles"] = getattr(self, "subtitles", [])
dict["subtitles"] = [subtitle.to_dict() for subtitle in self.subtitles] if hasattr(self, "subtitles") else []
return dict

def __iter__(self):
Expand Down
10 changes: 9 additions & 1 deletion src/program/media/subtitle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ def remove(self):
if self.file and Path(self.file).exists():
Path(self.file).unlink()
self.file = None
return self
return self

def to_dict(self):
return {
"id": str(self._id),
"language": self.language,
"file": self.file,
"parent_id": self.parent_id
}

0 comments on commit 0dd561a

Please sign in to comment.