Skip to content

Commit

Permalink
Fix video format check: was failing on files with valid path but no C…
Browse files Browse the repository at this point in the history
…ontent-Disposition.
  • Loading branch information
rewbs committed Nov 10, 2023
1 parent f910d7b commit 4aa75fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/deforum_helpers/video_audio_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ def is_vid_path_valid(video_path):
# vid path is actually a URL, check it
if video_path.startswith('http://') or video_path.startswith('https://'):
response = requests.head(video_path, allow_redirects=True)
extension = video_path.rsplit('?', 1)[0] # remove query string before checking file format extension.
extension = extension.rsplit('?', 1)[0] # remove query string before checking file format extension.
content_disposition = response.headers.get('Content-Disposition')
if content_disposition:
# Attempt to extract the filename from the Content-Disposition header
if content_disposition and extension not in file_formats:
# Filename doesn't look valid, but perhaps the content disposition will say otherwise?
match = re.search(r'filename="?(?P<filename>[^"]+)"?', content_disposition)
if match:
extension = match.group('filename').rsplit('.', 1)[-1].lower()
Expand Down

0 comments on commit 4aa75fd

Please sign in to comment.