From 7d23a914e631af4be0a2b9cbf81f21ccd622b634 Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 14 Jan 2022 16:13:17 -0700 Subject: [PATCH] Info_json may not yet be a MediaPath. --- modules/videos/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/videos/models.py b/modules/videos/models.py index 0e70f1d1..d2d5a05c 100644 --- a/modules/videos/models.py +++ b/modules/videos/models.py @@ -1,4 +1,5 @@ import json +import pathlib from datetime import datetime from pathlib import Path from typing import Optional @@ -129,7 +130,11 @@ class Video(ModelHelper, Base): If this Video has an info_json file, return it's contents. Otherwise, return None. """ try: - if self.info_json_path: + if isinstance(self.info_json_path, pathlib.Path): + with open(self.info_json_path, 'rb') as fh: + contents = json.load(fh) + return contents + elif self.info_json_path: with open(self.info_json_path.path, 'rb') as fh: contents = json.load(fh) return contents