Skip to content

Commit 4aa75fd

Browse files
committed
Fix video format check: was failing on files with valid path but no Content-Disposition.
1 parent f910d7b commit 4aa75fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/deforum_helpers/video_audio_utilities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ def is_vid_path_valid(video_path):
157157
# vid path is actually a URL, check it
158158
if video_path.startswith('http://') or video_path.startswith('https://'):
159159
response = requests.head(video_path, allow_redirects=True)
160-
extension = video_path.rsplit('?', 1)[0] # remove query string before checking file format extension.
160+
extension = extension.rsplit('?', 1)[0] # remove query string before checking file format extension.
161161
content_disposition = response.headers.get('Content-Disposition')
162-
if content_disposition:
163-
# Attempt to extract the filename from the Content-Disposition header
162+
if content_disposition and extension not in file_formats:
163+
# Filename doesn't look valid, but perhaps the content disposition will say otherwise?
164164
match = re.search(r'filename="?(?P<filename>[^"]+)"?', content_disposition)
165165
if match:
166166
extension = match.group('filename').rsplit('.', 1)[-1].lower()

0 commit comments

Comments
 (0)