Repository navigation
fix: derive $VIDEO_NAME from the path of URL inputs - #582
Open
qwist1233-cpu wants to merge 1 commit into
Open
qwist1233-cpu wants to merge 1 commit into
qwist1233-cpu wants to merge 1 commit into
Conversation
For a URL input, `get_file_name()` took `os.path.basename()` of the whole URL, so the query string and fragment leaked into `$VIDEO_NAME`. With `https://host/clip.mp4?token=1.2` the default `list-scenes` output became `clip.mp4?token=1-Scenes.csv`, which is an invalid file name on Windows (OSError: Invalid argument), and a URL with no path produced an empty name (`-Scenes.csv`). URLs now use the last non-empty segment of the path component, so `https://host/clip.mp4?token=1.2` -> `clip`. A URL with no path falls back to the host (plus `_port` when present) and never includes credentials. The CLI warns when no name could be derived at all. Closes Breakthrough#197
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #197
What
get_file_name()now parses URL inputs ("://"in the path) withurllib.parseand uses the last non-empty path segment, ignoring the query string and fragment. A URL with no path falls back to the host (192.168.0.1_554forrtsp://192.168.0.1:554), never the credentials. The CLI logs a warning if no name could be derived at all. All three backends go through this helper, so$VIDEO_NAMEis fixed foropencv,pyavandmoviepy.Why
os.path.basename()of a whole URL keeps the query string, so$VIDEO_NAMEforhttps://host/clip.mp4?token=1.2wasclip.mp4?token=1and the defaultlist-scenesoutput name becameclip.mp4?token=1-Scenes.csv, which fails on Windows. A URL with no path gave an empty name (-Scenes.csv).How verified
tests/resources/goldeneye.mp4over a localhttp.serverand ranscenedetect -i "http://127.0.0.1:18765/goldeneye.mp4?token=1.2" -b opencv time -e 3s list-sceneson Windows. Before:OSError: [Errno 22] Invalid argument: 'goldeneye.mp4?token=1-Scenes.csv'. After:goldeneye-Scenes.csvis written.tests/test_platform.py(19 pass),ruff check/ruff format --checkclean, and the rest of the suite passes except the moviepy-only tests, which are skipped here because moviepy is not installed.I picked option (c) from the discussion on the issue: derive the name from the URL path and only warn when nothing usable is left. Happy to switch to erroring out if you prefer that.