Tries to extract the filename from a URL.
If the URL cannot be parsed or does not contain a filename in the path,
it returns the provided default filename.
Resolves the final output path.
If output_arg is None, extracts filename from URL.
If output_arg is a directory, appends filename from URL.
If output_arg is a file path, uses it as is.