@@ -130,14 +130,24 @@ def process_ffmpeg_compose(data, job_id):
130130 new_filters = []
131131 for filter_obj in data ["filters" ]:
132132 filter_str = filter_obj ["filter" ]
133- def replace_subtitles_url (match ):
134- url = match .group (1 )
133+ def replace_url (match ):
134+ prefix = match .group (1 )
135+ filter_type = match .group (2 )
136+ quote = match .group (3 )
137+ url = match .group (4 )
138+ closing_quote = match .group (5 )
139+ trailing = match .group (6 ) or ''
140+ if not url or url .strip () == '' :
141+ print (f"[DEBUG] Skipping empty URL for filter: { match .group (0 )} " )
142+ return match .group (0 )
143+ print (f"[DEBUG] Parsed URL for filter: { url } " )
135144 local_path = download_file (url , LOCAL_STORAGE_PATH )
136145 subtitles_paths .append (local_path )
137146 fixed_path = local_path .replace ('\\ ' , '/' )
138- return f"subtitles='{ fixed_path } " # keep the opening quote
139- # Regex: subtitles='<url>' or subtitles="<url>"
140- filter_str = re .sub (r"subtitles=['\"]([^'\"]+)" , replace_subtitles_url , filter_str )
147+ return f"{ prefix } { filter_type } ={ quote } { fixed_path } { closing_quote } { trailing } "
148+ # Regex: (.*?)(subtitles|ass)=(['"])(https?://[^'\"]+)(['"])(.*)
149+ pattern = r"(.*?)(subtitles|ass)=([\'\"])(https?://[^'\"]+)([\'\"])(.*)"
150+ filter_str = re .sub (pattern , replace_url , filter_str )
141151 new_filters .append (filter_str )
142152 filter_complex = ";" .join (new_filters )
143153 command .extend (["-filter_complex" , filter_complex ])
0 commit comments