mirror of
https://github.com/Viren070/MediaFusion.git
synced 2025-12-01 23:21:11 +01:00
Ensure file_name uses basename and replace quote_plus with quote
This update ensures that the `file_name` always uses its basename for consistency and correctness. Additionally, `quote_plus` was replaced with `quote` to simplify URL encoding
This commit is contained in:
@@ -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(
|
||||
|
||||
+6
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user