-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
convert: New feature "Write m3u playlist to destination folder" #4399
Conversation
Usage examplesSimple exampleUsing a beets query to save a playlist of all files of an artist sorted chronologically:
More advanced exampleAn existing playlist (eg. generated with the "smartplaylist" plugin) should be exported to the export folder: Required config:
Certainly any playlist file could be exported, no matter if it was created with a beets plugin or manually, as long as it's using media files existing in the beets db already. It's intended that the playlist file is saved alongside the media files, in this case the path provided by the |
Seems like a neat feature! I have a couple of high-level questions about the way the playlist file is generated here:
|
yes there will most probably be an issue with threading I guess. Actually I wanted to ask you for advice on that topic :-) Thanks for the early review I'll think about your ideas and will hopefully get back to this next week and probably have more questions. |
Sounds good! I wonder if there's a way to "batch up" all the new paths and then write them out all at once… |
670b067
to
6b3299e
Compare
This is stalling. There is summer/vacations/other projects need finishing but most of all because I don't get the unittest to work. Anyway, I have 5 minutes and ask for help. I'm currently trying to write a unittest that checks whether the playlist.m3u8 file was written and is existing. I'm feeling bad already for asking Adrian all the time, he probably has a lot on the plate with this project already. @arsaboo I'm not sure if you're officially a maintainer of the project but you seem highly motivated lately and since you have quite some experience with your Spotify and Plex stuff going on you might be able to help: I'm trying to check if a file was created, but the file doesn't seem to be there: 147e018
I think I misunderstand something pretty basic here. Maybe you have an idea to further debug this. Thanks so much in advance! |
Hmm… my best guess here is that the code currently tries to write the playlist file (i.e., does |
Hi, thanks so much @sampsyo, it's working now, some progress is to note and some new questions arise:
PS: Also added some checkboxes to the inital post for some things I consider essential. |
Well, awesome! I'm glad this seems to be working. It's a good question about Windows. I'm not a Windows expert either… I think the best route here would probably be to just assume that everything's fine on that platform (as long as we're correctly using And sure! Starting with a special-purpose M3U-writing utility, and expanding its functionality on demand, seems like a perfectly good plan to me. |
@JOJ0 sorry....was out for a conference and could not respond. I am not a maintainer....just an active user of beets and trying to add features that I care about. In any case, looks like the issue was resolved. I hope to see this feature in beets soon. I would like to use parts of it to covert playlists. |
4c26db1
to
d45649f
Compare
It's currently untested when this feature is used together with |
32c182c
to
57ebd6e
Compare
Interesting, now I'm getting exactly the error I was kind of hoping for. Something is different on Windows but atm I don't know how to proceed: Testfile was created on macOS Catalina, which I guess uses unicode. Windows can't read the path correctly from the file, even though I use syspath() for reading the entry.
|
bd472dc
to
bcac5a7
Compare
Hi @sampsyo , I think this PR finally is ready for the final review. I tried to make sure that unicode files reading and writing is working on Windows by adding some Windows specific unittests. I'm still not 100% sure if I understood syspath() entirely (I don't understand why adding \\?\ makes sense and what it's purpose is). I disabled the prefix when adding file paths to the playlist. I'm not sure if syspath() would be required at all when reading in media file paths from an m3u playlist file but I did it anyway (https://github.com/beetbox/beets/pull/4399/files#diff-f20a2ab41ac3a3c83575cac2b871653999b0e4d28c27336a1f3897a004f5d6daR49) Please specifically review the Windows tests (and the corresponding fixture files) and tell me whether you think they make sense like that: |
Okay, okay, I did some homework and finally read the msdn article that's linked within the syspath() function (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx) and some stackoverflow answers. I think I get it now. It enables Windows to handle paths longer than the maximum of 260 characters. Using syspath() always adds the prefix of \\?\ to paths, because it can't hurt, even when paths are shorter. Still I'm unsure if it's correct to apply it when loading an m3u playlist's entry (https://github.com/beetbox/beets/pull/4399/files#diff-f20a2ab41ac3a3c83575cac2b871653999b0e4d28c27336a1f3897a004f5d6daR49) and when adding one (https://github.com/beetbox/beets/pull/4399/files#diff-ac0584bc04d691dc3bb362557c68b83e7e71f491b7e4e0b42013e3a73cf30dd3R488). Isn't adding this prefix the responsibility of an application that wants to read an m3u file's entry? Thus I should not use syspath() (with prefix=True) when adding to the list? (https://github.com/beetbox/beets/pull/4399/files#diff-ac0584bc04d691dc3bb362557c68b83e7e71f491b7e4e0b42013e3a73cf30dd3R488) |
I don't want to leave all the clutter of the last 2 messages standing as the final messages here. All this is probably esoteric at the moment and as always there might be room for improvement. A final review and merge could be a sensible next step. Thanks a lot in advance. |
in m3u module and testsuite.
Fix "inline empasis start string without endstring" error in docs.
loading as well.
Learn what's happening in syspath().
This reverts commit 8a7519e.
into fixture file for the Windows unittest.
in load method when loading media files to content list.
Needs to be put including (double) backslash!
Add test_playlist_write_and_read_unicode_windows: Writes 2 media file paths containing unicode characters, reads them in using M3UFile class again and tests if the contents is correct.
Fixes FileNotFoundError when for example a tilde (~) characteris used for a --dest path.
The M3UFile.write() method now creates potential parent directories in a passed playlist path. util.mkdirall() handles errors nicely already and would exit the mainprogram before potential subsequent failures could happen (it raises util.FilesystemError).
operations of a playlist in M3UFile class, by catching any "OSError" and raising util.FilesystemError.
Make sure we stay with the beets standard of handling everything internally as bytes. - M3UFile.write() method writes in wb mode. - Playlist contents and EXTM3U header is handled as bytes. - item.destination() gives us unicode string paths, we tranlate to bytes using util.bytestring_path(). - Fix test_playlist*write* tests to encode UTF-8 assert strings as bytes using bytestring_path() before comparision.
- M3UFile.read() method reads in rb mode. - M3UFile.read() method handles removal of (platform specific) line endings. - Playlist contents and EXTM3U header is handled as bytes. - Fix test_playlist*read* tests to encode playlist UTF-8 assert strings to bytes using bytestring_path() before comparision. - Fixture playlist_windows.m3u8 is now actually Windows formatted (\r\n + BOM)
Ensure entries in items_paths are generated with a path relative to the location of the playlist file.
- Remove initial comment around playlist entry condition (which is better suited for user docs anyway, and stated there already) - Add explanation above the items_paths playlist contents creation list comprehension.
I think this is finally ready to go. There is error handling, unittests for Posix and Windows, The |
Whoops, reminder to myself: A markdown hyperlink is not a rst hyperlink. Quickfix this in master ;-) |
Description
playlist
feature can be used.To Do
docs/
to describe it.)docs/changelog.rst
near the top of the document.)I'm not considering this a problem with my implementation here. Let's see what happens on that forum post, but for now I check this task as done.
Ensure cross-platform compatibilityEnsure compatibility of playlists generated on an OS for an OS. For example, lists generated on Windows should work on Windows.