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

[Bug] M3U8 File Can Not Be Created Due to Invalid Characters in Original Qobuz Playlist Name #35

Closed
congofather opened this issue Jun 3, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@congofather
Copy link

congofather commented Jun 3, 2023

🐞 Bug Report

Describe the bug

When I try to download a Qobuz playlist , it fails to create the playlist file with the filename .m3u8 in the playlist root folder. When the playlist name has illegal characters in its name, the file can not be created and it's thrown an exception by the operating system.

To remove the illegal characters in the filename, the following character replacement is recommended before writing contents with System.IO.File.WriteAllText call.

Please see--> https://stackoverflow.com/questions/7348768/the-given-paths-format-is-not-supported

string qobuzPlaylistName_IllegalCharactersRemoved = string.Concat(qobuzPlaylist.Name.Split(Path.GetInvalidFileNameChars()));
// or you can replace illegal characters with a special character like "_"
string qobuzPlaylistName_IllegalCharactersRemoved = string.Join("_", qobuzPlaylist.Name.Split(Path.GetInvalidFileNameChars()));

// Write m3u playlist to file, override if exists
string m3uPlaylistFile = Path.Combine(playlistBasePath, $"{qobuzPlaylistName_IllegalCharactersRemoved}.m3u8");
System.IO.File.WriteAllText(m3uPlaylistFile, PlaylistToTextHelper.ToText(m3uPlaylist), System.Text.Encoding.UTF8);

The stacktrace of the error is as follows(in Download_Errors.log);

Playlist Download Task ERROR.
System.NotSupportedException: The given path's format is not supported.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
at QobuzDownloaderX.Shared.DownloadManager.d__43.MoveNext()


Is this a regression?


To Reproduce

Try to download https://play.qobuz.com/playlist/4824548 to a network folder path..
The songs are downloaded successfully without any problem. But the m3ufile can not be created due to illegal characters in the filename.


Expected behaviour


Screenshots

The stacktrace of the error is as follows;

Playlist Download Task ERROR.
System.NotSupportedException: The given path's format is not supported.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost)
at System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
at QobuzDownloaderX.Shared.DownloadManager.d__43.MoveNext()


Additional context

@congofather congofather changed the title [Bug] [M3U8 File Can Not Be Created Due to Invalid Characters in Original Qobuz Playlist Name] Jun 3, 2023
@congofather congofather changed the title [M3U8 File Can Not Be Created Due to Invalid Characters in Original Qobuz Playlist Name] [Bug] M3U8 File Can Not Be Created Due to Invalid Characters in Original Qobuz Playlist Name Jun 3, 2023
@DJDoubleD DJDoubleD added the bug Something isn't working label Jun 8, 2023
@DJDoubleD DJDoubleD self-assigned this Jun 8, 2023
@DJDoubleD
Copy link
Owner

Thank you for the detailed bug description and suggested fix.
The StringTools helper class already contained all required methods, I just forgot to apply them to the name of the playlist file :-\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants