Commit graph

11595 commits

Author SHA1 Message Date
J0J0 Todos
8705457d24
Merge pull request #4399 from JOJ0/convert_playlist
convert: New feature "Write m3u playlist to destination folder"
2023-04-03 07:21:06 +02:00
J0J0 Todos
94784c2c29 convert: playlist: Documentation overhaul 2023-04-02 21:14:50 +02:00
J0J0 Todos
86929eb6a0 convert: playlist: Adapt code comments
- 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.
2023-04-02 19:34:13 +02:00
elyang0214
09de7909ce Merge branch 'master' of https://github.com/elyang0214/beets 2023-04-02 11:14:52 -04:00
elyang0214
b3b26efe88 Updated documentation to be less redundant in docs/referece/cli.rst and more accurate in docs/changelog.rst. 2023-04-02 11:13:53 -04:00
elyang0214
fbd665a417
Merge branch 'beetbox:master' into master 2023-04-02 11:06:13 -04:00
J0J0 Todos
16e361baf3 convert: playlist: item_paths relative to playlist
Ensure entries in items_paths are generated with a path relative to the
location of the playlist file.
2023-04-02 13:10:14 +02:00
Adrian Sampson
1f290f532f
Merge pull request #4396 from arogl/archive_mtime
Preserve mtimes from archives #4392
2023-04-01 16:07:34 -07:00
Adrian Sampson
6777b49bcf
Appease flake8 2023-04-01 15:46:02 -07:00
Adrian Sampson
c4a62fc248
Merge branch 'master' into archive_mtime 2023-04-01 15:33:35 -07:00
J0J0 Todos
99231160a7 convert: playlist: M3U read as bytes
- 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)
2023-03-29 07:46:08 +02:00
J0J0 Todos
a4d03ef586 convert: playlist: M3U write + contents as bytes
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.
2023-03-29 07:46:08 +02:00
J0J0 Todos
0884e67d35 convert: playlist: Handle errors on read/write
operations of a playlist in M3UFile class, by catching any "OSError" and
raising util.FilesystemError.
2023-03-29 07:46:08 +02:00
J0J0 Todos
952aa0badd convert: playlist: Handle playlist path subdirs
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).
2023-03-29 07:46:08 +02:00
J0J0 Todos
46fb8fef91 convert: playlist: Fix typo in m3u module docstring 2023-03-29 07:46:08 +02:00
J0J0 Todos
20a0012f79 convert: playlist: Use normpath for playlist file
Fixes FileNotFoundError when for example a tilde (~) characteris used for a
--dest path.
2023-03-29 07:46:08 +02:00
J0J0 T
068208f71e convert: Fix copyright year in test_m3ufile.py 2023-03-29 07:46:08 +02:00
J0J0 T
d248063f96 convert: playlist: Improve --playlist help text 2023-03-29 07:46:08 +02:00
J0J0 T
c28eb95ef2 convert: playlist: Remove debug print winpath
in test.
2023-03-29 07:46:08 +02:00
J0J0 T
ff03ecaa27 convert: playlist: Add another Windows test
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.
2023-03-29 07:46:08 +02:00
J0J0 T
39efd23d06 convert: playlist: Fix winpath driveletter in test
Needs to be put including (double) backslash!
2023-03-29 07:46:08 +02:00
J0J0 T
a641fd151e convert: playlist: debug winpath in test 2023-03-29 07:46:08 +02:00
J0J0 T
54d22bea6e convert: playlist: Construct winpath before assert 2023-03-29 07:46:08 +02:00
J0J0 T
e4213714ba convert: playlist: Disable prefix in syspath on
in load method when loading media files to content list.
2023-03-29 07:46:08 +02:00
J0J0 T
31b9e7afeb convert: playlist: Construct Windows path programatically 2023-03-29 07:46:08 +02:00
J0J0 T
004d10a143 convert: playlist: Put actual Windows paths
into fixture file for the Windows unittest.
2023-03-29 07:46:08 +02:00
J0J0 T
b3d0c1cc1c Revert "convert: playlist: Debug commit: Learn syspath()"
This reverts commit 8a7519e5057e9c11a5f95c979b2fd5ac6c1fd9e2.
2023-03-29 07:46:08 +02:00
J0J0 T
bd5335f31f convert: playlist: Separate unicode test for Windows 2023-03-29 07:46:08 +02:00
J0J0 T
5f5be52a89 convert: playlist: Debug commit: Learn syspath()
Learn what's happening in syspath().
2023-03-29 07:46:08 +02:00
J0J0 T
da01be3d93 convert: playlist: Enforce utf-8 encoding on load()
and write().
2023-03-29 07:46:08 +02:00
J0J0 T
785ef1576c convert: playlist: Use syspath() for media files
loading as well.
2023-03-29 07:46:08 +02:00
J0J0 T
a1baf9e94b convert: playlist: Fix rst linter error in docs
Fix "inline empasis start string without endstring" error in docs.
2023-03-29 07:46:08 +02:00
J0J0 T
2c1163cbc5 convert: playlist: Linter and import fixes
in m3u module and testsuite.
2023-03-29 07:46:08 +02:00
J0J0 T
c1908d551a convert: playlist: Document the feature
leaving out the fact that #EXTM3U is added to the playlist file header
(that important?).
2023-03-29 07:46:08 +02:00
J0J0 T
cb630c45f6 convert: playlist: Also use syspath() for contents
of playlist. We want to have processed every entry in the media list we
pass to the M3UFile instance.
2023-03-29 07:46:08 +02:00
J0J0 T
8dc556d420 convert: playlist: Use syspath()
for file read and write operations.
2023-03-29 07:46:08 +02:00
J0J0 T
7d121c390b convert: playlist: Move M3UFile class to separate
module in util package.
2023-03-29 07:46:08 +02:00
J0J0 Todos
01b77f5602 convert: playlist: Add changelog entry 2023-03-29 07:45:51 +02:00
J0J0 T
39e4b90b5c convert: playlist: Add tests checking extm3u and
fix extm3u check in load method.
2023-03-29 07:21:27 +02:00
J0J0 T
68240f6e03 convert: playlist: Add EmptyPlaylistError and test
- Add and Exception class called EmptyPlaylistError ought to be raised
  when playlists without files are loaded or saved.
- Add a test for it in test_m3ufile
- Fix media_files vs. media_list attribute name.
2023-03-29 07:21:27 +02:00
J0J0 T
0cbf91e4d8 convert: playlist: Add test_m3ufile and fixtures
Add several tests checking loading and saving unicode and regular ascii
text playlist files.
2023-03-29 07:21:27 +02:00
J0J0 T
ba3740c8fe convert: playlist: Fix filename attr in load method 2023-03-29 07:21:27 +02:00
J0J0 T
55b386375a convert: playlist: Move m3u creation after conversions
- Move the creation of the playlist file to the very end, right after
  self._parallel_convert, in the convert plugin's main function.
- In the test code, the destination directory is created when the
  conversion happens, thus this fixes test_playlist and doesn't hurt the
  feature - The playlist creation can as well be the very last step in
  the process.
2023-03-29 07:21:27 +02:00
J0J0 T
e41525adbc convert: playlist: Remove clutter from test
- Remove comments in tearDown
- Don't test for converted.mp3, it's done in a separate test already, we
  only want to test for the playlist file here.
2023-03-29 07:21:27 +02:00
J0J0 T
9930a5da59 convert: playlist: Test playlist existence
Broken commit around writing a unittest that checks for existence of an
m3u file after convert has been called with --playlist option.
2023-03-29 07:21:27 +02:00
J0J0 T
5dfff50005 convert: playlist: Refactor m3u writing to class
and also implement a currently untested load() method.
2023-03-29 07:21:27 +02:00
J0J0 T
c251ed19c4 convert: playlist: Generate m3u file in one batch
to avoid any possible interference with the threaded file conversion
mechanism.
2023-03-29 07:21:27 +02:00
J0J0 T
d589e77ade convert: playlist: Fix redundant join path
It's done in _get_opts_and_config already.
2023-03-29 07:21:27 +02:00
J0J0 T
c0b1bc9867 convert: playlist feature: Better relative path gen
Use Item.destination method for generation of relative paths to media
files in playlist. The fragment keyword enables returning the path as
unicode instead of bytes, let's keep that in mind.
2023-03-29 07:21:27 +02:00
J0J0 T
16e25bb61b convert: playlist feature: Fix relative paths
pointing to media files in playlist. Also refine code comment and move
to a better fitting place.
2023-03-29 07:21:27 +02:00