Fix bug with tv and movie paths

This commit is contained in:
Matthew Welch 2021-11-08 20:18:09 -08:00
parent 51e75e9f0f
commit 881dffefe6
2 changed files with 9 additions and 5 deletions

View File

@ -116,9 +116,9 @@ def get_tv_shows():
def get_games():
with app.app_context():
i = inotify.adapters.Inotify()
i.add_watch(func.GAMES_DIRECTORY)
for directory in os.listdir(str(func.GAMES_DIRECTORY)):
path = pathlib.Path(func.GAMES_DIRECTORY, directory)
i.add_watch(str(func.GAMES_DIRECTORY))
for directory in func.GAMES_DIRECTORY.iterdir():
path = func.GAMES_DIRECTORY / directory
if path.is_dir():
i.add_watch(str(path))

View File

@ -168,7 +168,9 @@ def get_movie(tmdb_id):
directors_cut = request.args.get("directors_cut", default=False, type=bool)
res_4k = request.args.get("res_4k", default=False, type=bool)
movie_data = database.db_get_movie_by_tmdb_id(tmdb_id, extended=extended, directors_cut=directors_cut)
filename = movie_data.path.replace(str(func.MOVIES_DIRECTORY), "")
filename: str = movie_data.path.replace(str(func.MOVIES_DIRECTORY), "")
if filename.startswith("/"):
filename = filename[1:]
if res_4k:
filename = filename.replace(f"({movie_data.year})", f"({movie_data.year})(4K)")
response = make_response(send_from_directory(func.MOVIES_DIRECTORY, filename))
@ -180,7 +182,9 @@ def get_movie(tmdb_id):
@login_required
def get_episode(tmdb_id):
episode_data = database.db_get_episode_by_tmdb_id(tmdb_id)
filename = episode_data.path.replace(str(func.TV_SHOWS_DIRECTORY), "")
filename: str = episode_data.path.replace(str(func.TV_SHOWS_DIRECTORY), "")
if filename.startswith("/"):
filename = filename[1:]
response = make_response(send_from_directory(func.TV_SHOWS_DIRECTORY, filename))
response.headers["content-type"] = "video/webm"
return response