Repository navigation
Conversation
loadPlaylistFromFile() read playlist files with the locale encoding. .m3u8 files are UTF-8 by definition, so on Windows loading an .m3u8 playlist with non-ASCII file names raised UnicodeDecodeError or loaded garbled paths, and a UTF-8 byte order mark ended up in the first entry. Read playlist files as UTF-8 (with or without a BOM) and save them as UTF-8. Playlists saved by older versions in the locale encoding still load through a fallback.
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.
SyncplayPlaylist.loadPlaylistFromFile()reads playlist files with the locale encoding..m3u8files are UTF-8 by definition, and the "Load playlist from file" dialog offers*.txt *.m3u8. On Windows the locale encoding is usually not UTF-8, so loading an.m3u8playlist with non-ASCII file names raisesUnicodeDecodeError(or, depending on the code page, loads garbled paths that cannot be found). If the file starts with a UTF-8 byte order mark, the BOM ends up in front of#EXTM3U, so that line is not skipped and becomes a playlist entry.This PR:
.txtplaylists saved by older versions of Syncplay still load,Reproduction
Korean Windows (locale encoding cp949), an
.m3u8file saved as UTF-8:Calling
loadPlaylistFromFile()on it:Tests
The repository has no test suite, so I did not add a test file. I checked the change with a local pytest script that makes
open()default to cp1252 for text mode (so it fails on any OS without the fix) and covers:.m3u8file in UTF-8, and one with a BOM,.txtplaylist written in the locale encoding (the fallback).Before the fix: 3 failed, 1 passed (the old locale-encoded file). After the fix: 4 passed.