diff --git a/streaming_providers/routes.py b/streaming_providers/routes.py index 8293b90..50387e7 100644 --- a/streaming_providers/routes.py +++ b/streaming_providers/routes.py @@ -1,5 +1,6 @@ import logging from os import path +from os.path import basename from typing import Annotated from fastapi import ( @@ -100,6 +101,7 @@ async def get_or_create_video_url( episode_data = stream.get_episode(season, episode) if not filename: filename = episode_data.filename if episode_data else stream.filename + filename = basename(filename) if filename else None file_index = episode_data.file_index if episode_data else stream.file_index get_video_url = mapper.GET_VIDEO_URL_FUNCTIONS.get( diff --git a/utils/parser.py b/utils/parser.py index 8c58aed..d7a4a4b 100644 --- a/utils/parser.py +++ b/utils/parser.py @@ -6,7 +6,8 @@ import math import re from datetime import datetime, timezone from typing import Optional, List, Any -from urllib.parse import quote_plus +from os.path import basename +from urllib.parse import quote from thefuzz import fuzz @@ -259,6 +260,9 @@ async def parse_stream_data( file_name = stream_data.filename file_index = stream_data.file_index + # make sure file_name is basename + file_name = basename(file_name) if file_name else None + if show_full_torrent_name: torrent_name = ( f"{stream_data.torrent_name}/{episode_data.title or episode_data.filename or ''}" @@ -341,7 +345,7 @@ async def parse_stream_data( if episode_data: stream_details["url"] += f"/{season}/{episode}" if file_name: - stream_details["url"] += f"/{quote_plus(file_name)}" + stream_details["url"] += f"/{quote(file_name)}" stream_details["behaviorHints"]["notWebReady"] = True else: stream_details["infoHash"] = stream_data.id