From 8170d4913bd96af994215faa3dbdf8d2387bea8c Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 12 Mar 2022 21:53:03 +0700 Subject: [PATCH] add fallback total video length if ffmpeg extraction failes --- tubearchivist/home/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 0587704..c53fe1f 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -183,6 +183,8 @@ class ArchivistResultsView(ArchivistViewConfig): if video["youtube_id"] in in_progress: played_sec = in_progress.get(video["youtube_id"]) total = video["player"]["duration"] + if not total: + total = played_sec * 2 video["player"]["progress"] = 100 * (played_sec / total) def get_in_progress(self, results): @@ -202,6 +204,8 @@ class ArchivistResultsView(ArchivistViewConfig): matched = [i for i in results if i["youtube_id"] == youtube_id] played_sec = matched[0]["position"] total = video["source"]["player"]["duration"] + if not total: + total = matched[0].get("position") * 2 video["source"]["player"]["progress"] = 100 * (played_sec / total) return videos