Creating Channel.info_json_path property to avoid redefining channel's info json path.

This commit is contained in:
Roland 2024-12-24 14:41:51 -07:00
parent 808f46be5b
commit e49ffc8a6c
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 27 additions and 1 deletions

View file

@ -556,6 +556,15 @@ class Channel(ModelHelper, Base):
def location(self) -> str:
return f'/videos/channel/{self.id}/video'
@property
def info_json_path(self) -> pathlib.Path:
if self.directory:
if not self.directory.exists():
self.directory.mkdir(parents=True)
return self.directory / f'{self.name}.info.json'
raise FileNotFoundError(f'Cannot create Channel info json because directory is not defined: {self}')
def delete_with_videos(self):
"""Delete all Video records (but not video files) related to this Channel. Then delete the Channel."""
session = Session.object_session(self)