Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File extension determination is wrong #304

Closed
exislow opened this issue Nov 14, 2024 · 1 comment
Closed

File extension determination is wrong #304

exislow opened this issue Nov 14, 2024 · 1 comment

Comments

@exislow
Copy link
Contributor

exislow commented Nov 14, 2024

I did some research and found out that this behavior is wrong:

def get_file_extension(stream_url: str, stream_codec: Optional[str] = None) -> str:
if AudioExtensions.FLAC in stream_url:
result: str = AudioExtensions.FLAC
elif AudioExtensions.MP4 in stream_url:
if stream_codec:
if Codec.AC4 is stream_codec:
result: str = AudioExtensions.MP4
elif Codec.FLAC is stream_codec:
result: str = AudioExtensions.FLAC
else:
result: str = AudioExtensions.M4A
else:
result: str = AudioExtensions.MP4
elif VideoExtensions.TS in stream_url:
result: str = VideoExtensions.TS
else:
result: str = AudioExtensions.M4A
return result

We need to separate the used codec and the file extension. Since, if a file is returned as MP4 it still can have a FLAC encoded audio channel, but the container is indeed an MP4 container.

What happens here is, if stream has ".mp4" in it's file name, the lines above try to check the used codec and wrongly adapt the file extension. To overcome this problem problem I propose solely rely on the extension within the URL. I have a problem which is related to this exislow/tidal-dl-ng#232

A lot of debugging led me to this conclusion. I will propose a solution with a PR.

@exislow
Copy link
Contributor Author

exislow commented Nov 14, 2024

Here you go: #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant