Skip to content

Commit

Permalink
fix: keep old uploads playing
Browse files Browse the repository at this point in the history
  • Loading branch information
purzelrakete committed Jan 29, 2024
1 parent 19577e0 commit 44b8384
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 11 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,17 @@ def media(

t = stub.transcriptions[transcription_id]
path = t.uploaded_file
content_type = t.upload.content_type

# RK(XXX): I moved the path from track to transcript. This caused the
# old transcript.track.path attribute stored in the modal distributed
# dictionary to be dropped. the following is a fix for those old files
# and it should be removed at some point soon.
if not path:
t.path = common.MEDIA_PATH / transcription_id
stub.transcriptions[transcription_id] = t
path = t.path

content_type = t.content_type or "video/mp4"
total = path.stat().st_size

try:
Expand Down
14 changes: 7 additions & 7 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class Track:
comment: str = None
date: str = None
duration: float = None
path: str = None

def from_probe(probe):
tags = probe.get("format", {}).get("tags", {})
Expand Down Expand Up @@ -92,14 +91,9 @@ class Transcription:
def transcribed(self):
return self.transcript is not None

@property
def track_path(self):
"""Deprecated. Old files include the path on self.track"""
return self.track.path if self.track else None

@property
def uploaded_file(self):
return Path(self.path or self.track_path)
return Path(self.path) if self.path else None

@property
def transcoded_file(self):
Expand All @@ -109,6 +103,12 @@ def transcoded_file(self):
def transcribed_file(self):
return self.uploaded_file.with_suffix('.json')

@property
def content_type(self):
# RK(XXX )supports old uploads. remove as soon as possible.
if hasattr(self, 'upload'):
if self.upload:
return self.upload.content_type


# Modal abstractions
Expand Down

0 comments on commit 44b8384

Please sign in to comment.