Info_json may not yet be a MediaPath.

This commit is contained in:
Roland 2022-01-14 16:13:17 -07:00
parent f9a1f736ca
commit 7d23a914e6
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -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