Commit graph

12502 commits

Author SHA1 Message Date
Arav K.
cd360b6a99 [beets/library] Simplify directory logic 2024-09-20 23:27:36 +02:00
Arav K.
d3bc27a58f [changelog] Note 'platformdirs' integration 2024-09-20 23:27:36 +02:00
Arav K.
24e51e90f4 [beets/library] Use 'platformdirs' for the default music dir 2024-09-20 23:27:36 +02:00
Arav K.
87cd81d481 Add dependency on 'platformdirs' 2024-09-20 23:27:36 +02:00
Konstantin
796c9addfb
Fixes TypeError in the Discogs plugin (#5415)
Handles the case when discogs return `None` for format descriptions.

---------

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-09-19 21:27:16 +01:00
Šarūnas Nejus
d3c62968d5
Fix most types in beets.util.__init__ (#5223)
This PR is Part 1 of the work #5215 that fixes typing issues in
`beets.util.__init__` module.

It addresses simple-to-fix / most of the issues in this module.
2024-09-18 13:40:11 +01:00
Šarūnas Nejus
c13f0f2f6e
Deezer: Improve requests error handling (#5421)
This PR adds gracefully handling requests error in teh Deezer plugin.
2024-09-17 18:52:42 +01:00
Alok Saboo
7f74d3db4c
Update beetsplug/deezer.py
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-09-17 13:23:11 -04:00
Šarūnas Nejus
5785522170
fetchart: defer file removal config option evaluation (#5244)
Defer the evaluation of the source file removal options (`import.delete`
and `import.move`) to the point where the fetchart plugin is actually
called instead of only evaluating those configuration options on plugin
initialization.
This is to allow other plugins (such as the
[ytimport](https://github.com/mgoltzsche/beets-ytimport/blob/v1.8.1/beetsplug/ytimport/__init__.py#L194)
plugin) to invoke the import directly (within the same python process;
implicitly invoking the fetchart plugin) with temporarily overwritten
configuration options.

Addresses
https://github.com/beetbox/beets/issues/5167#issuecomment-2106465172
2024-09-16 11:44:46 +01:00
Alok Saboo
afe43dc360 Fix lint errors 2024-09-15 11:36:16 -04:00
Alok Saboo
f57dc66444 Deezer: Improve requests error handling
## Description

This PR adds gracefully handling requests error in teh Deezer plugin. Right now, it errors out when it receives error:

```bash
Traceback (most recent call last):
  File "/home/arsaboo/.local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/ui/commands.py", line 1395, in import_func
    import_files(lib, paths, query)
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/ui/commands.py", line 1326, in import_files
    session.run()
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/util/pipeline.py", line 447, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/util/pipeline.py", line 195, in coro
    func(*(args + (task,)))
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/importer.py", line 1497, in lookup_candidates
    task.lookup_candidates()
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/importer.py", line 688, in lookup_candidates
    artist, album, prop = autotag.tag_album(
                          ^^^^^^^^^^^^^^^^^^
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/autotag/match.py", line 548, in tag_album
    for matched_candidate in hooks.album_candidates(
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/plugins.py", line 593, in decorated
    for v in generator(*args, **kwargs):
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/autotag/hooks.py", line 759, in album_candidates
    yield from plugins.candidates(items, artist, album, va_likely, extra_tags)
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/plugins.py", line 390, in candidates
    yield from plugin.candidates(
               ^^^^^^^^^^^^^^^^^^
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beets/plugins.py", line 772, in candidates
    results = self._search_api(query_type="album", filters=query_filters)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/arsaboo/.local/lib/python3.12/site-packages/beetsplug/deezer.py", line 282, in _search_api
    response.raise_for_status()
  File "/home/arsaboo/.local/lib/python3.12/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.deezer.com/search/album?q=album%3A%22Y+Hate+%3F%22+artist%3A%22Parmish+Verma%22
```

## To Do

- [ ] Documentation. (If you've added a new command-line flag, for example, find the appropriate page under `docs/` to describe it.)
- [x] Changelog. (Add an entry to `docs/changelog.rst` to the bottom of one of the lists near the top of the document.)
- [ ] Tests. (Very much encouraged but not strictly required.)
2024-09-15 11:34:29 -04:00
Šarūnas Nejus
860daa9e92
Tidy up types given we have annotations from the future 2024-09-13 23:06:08 +01:00
Šarūnas Nejus
5d7a69dfe5
Fix types in beets.util.__init__ 2024-09-13 23:06:08 +01:00
Max Goltzsche
00add272ce
fetchart: apply review remarks
simplifying config access

Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-09-13 23:09:49 +02:00
Arav K.
0a985fdfb4 [doc/reference/config] Re-write explanation for 'overwrite_null'
See: <https://github.com/beetbox/beets/pull/5373#discussion_r1702848037>
2024-09-12 14:26:50 +02:00
Arav K.
c668dfae71 Document 'overwrite_null'
Solves #5314.
2024-09-12 14:26:50 +02:00
Šarūnas Nejus
54b2435c72
Update dependencies and do not install reflink on Windows for tests (#5407)
See my comment under #5406 for context

> The build on win32 is failing to install reflink because it's [only
supported until Python
3.7](https://gitlab.com/rubdos/pyreflink/-/blob/master/setup.py?ref_type=heads).
>
> I will address this in a separate PR and rebase this one accordingly
once the fix is merged.
>
> Note: this issue popped up now because I added a new requests-mock
dependency which invalidated cached dependencies.
2024-09-08 12:31:02 +01:00
J0J0 Todos
98f4a88923
ftintitle: New customization option to keep feature in artist field (#5356) 2024-09-06 13:41:15 +02:00
Serene
5f14d216e2
Create a new template function: capitalize (#5409)
## Description

This creates a new template function that capitalizes the text (make the
first character have upper case and the rest lower case). Example:
```console
beet list -f '%capitalize{$title}'
```

This does not do the same as the *%title* function.

(...)

## To Do

<!--
- If you believe one of below checkpoints is not required for the change
you
are submitting, cross it out and check the box nonetheless to let us
know.
  For example: - [x] ~Changelog~
- Regarding the changelog, often it makes sense to add your entry only
once
reviewing is finished. That way you might prevent conflicts from other
PR's in
that file, as well as keep the chance high your description fits with
the
  latest revision of your feature/fix.
- Regarding documentation, bugfixes often don't require additions to the
docs.
- Please remove the descriptive sentences in braces from the enumeration
below,
  which helps to unclutter your PR description.
-->

- [x] Documentation.
- [x] Changelog.
- [x] Tests.
2024-09-06 15:48:29 +10:00
Tânio Scherer
0b067e9f5b Create a new template function: capitalize
Update documentation

Update changelog
2024-09-05 23:00:50 -03:00
Karl-Ludwig Besser
39acba5200
Merge branch 'master' into ftintitle_keep_artist 2024-09-05 12:32:20 +02:00
Karl Besser
15d652dbae Update log message for keeping artist in ftintitle
Update the log message when the artist is kept unchanged due to setting
the keep_in_artist option to true.
2024-09-05 12:28:51 +02:00
Karl Besser
aa891d21d4 Add example use case of keep_artist option to docs
Update the documentation of the new `keep_in_artist` option, adding an
example use case.
2024-09-05 12:15:53 +02:00
Šarūnas Nejus
851699ab76
Clarify test_unsuccessful_reflink error message 2024-09-05 04:32:13 +01:00
Šarūnas Nejus
fee959c500
Handle missing reflink dependency in the business logic 2024-09-04 20:34:00 +01:00
Šarūnas Nejus
255ac4bc2f
Update dependencies 2024-09-04 19:06:55 +01:00
Šarūnas Nejus
c2d9bcf767
Update dead link in reflink docs 2024-09-04 19:06:55 +01:00
Šarūnas Nejus
4f3b0faba5
Handle missing reflink dependency in tests 2024-09-04 19:06:55 +01:00
Šarūnas Nejus
06ca500ff2
Do not install reflink for tests on Windows 2024-09-04 18:56:19 +01:00
Šarūnas Nejus
b2360461d0
fix(import): don't throw away album flexible fields (#5388)
I believe this fixes #4785, but I might be misunderstanding the
description and it might already be fixed.

Tagging @JOJ0 since they created both the bug linked above, and
5bf4e3d92f which mentions it.
2024-08-27 13:34:49 +01:00
Šarūnas Nejus
cd9347686a
Improved NamedTuple declaration (#5393)
Utilize a [new way of declaring
NamedTuples](https://docs.python.org/3/library/typing.html#typing.NamedTuple),
which allows for typechecking as well. Maybe the latter is now redundant
in other places, but I'm not that familiar with the codebase yet, so I
just changed the declarations (and hopefully used the correct types).
While I was at it, I also ran `poetry update`, but I'll revert
poetry.lock in case I wasn't supposed to do that. This is my first
commit here, so I hope I didn't do anything wrong...
2024-08-27 13:30:13 +01:00
Konstantin
2a77758ebe make comment consistent 2024-08-27 10:13:45 +00:00
Konstantin
3d937e037b fix formatting 2024-08-27 09:45:47 +00:00
Konstantin
f3bfd8a47a use new kind of type annotations 2024-08-27 09:40:26 +00:00
Konstantin
56232864ce fix 2024-08-27 08:15:51 +00:00
Konstantin
f51d5249d2 Revert "fixed + improved typing in some places"
This reverts commit 647d6ab29a.
2024-08-27 06:51:42 +00:00
Konstantin
647d6ab29a fixed + improved typing in some places 2024-08-27 00:16:30 +02:00
ThinkChaos
bf32d9a1be
refactor(autotag/mb): reduce repeated code for external link parsing
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-08-26 13:06:28 -04:00
ThinkChaos
65f2285dd3
fix(import): don't throw away album flexible fields
As noted by 5bf4e3d92f, MusicBrainz
external IDs (`*_album_id`) were only saved for items and not albums.
This commit addresses that by copying `AlbumInfo` fields to the `Album`,
i.e. what's saved in the DB.
This is similar to how `TrackInfo` fields are copied to `Item` instances
except the copying is done at a different time since we only get an
`Album` much later in the import flow.
2024-08-26 13:06:28 -04:00
Šarūnas Nejus
4416b9857f
Fix autobpm and improve its docs (#5389)
Fixes #5289 and #5185

Tried using the `autobpm` plugin and found a couple of issues:

1. #5185 `librosa` dependency was missing in `pyproject.toml`
2. Simply including the plugin in the configuration made `beet` take
over 4 seconds to start up.
3. BPM detection failed due to another missing dependency, `resampy`
4. #5289 Librosa `beat_track` function returned unexpected type which
made the plugin and the entire import process fail.

Addressed each of the above, slightly refactored the plugin and added
tests.
2024-08-26 17:18:48 +01:00
Konstantin
e04f3e5597 Use typing.Dict instead of dict 2024-08-26 16:34:53 +02:00
Konstantin
b84912db5f This should do… 2024-08-25 19:18:15 +02:00
Konstantin
5d1da3e438 Didn't mean to do that... 2024-08-25 16:37:36 +02:00
Konstantin
ccda7405b9 Utilize new way of declaring a NamedTuple 2024-08-25 16:26:19 +02:00
Šarūnas Nejus
111686e563
autobpm: add tests 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
591e04a894
Add Item.filepath property to simplify path handling
Additionally, fix DefaultTemplateFunctions._func_names definition.
2024-08-19 22:44:17 +01:00
Šarūnas Nejus
8f02020db4
autobpm: handle errors in beat.beat_track as well 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
3c51128d9b
autobpm: do not call get on boolean config options 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
ee2f114342
autobpm: add types 2024-08-19 22:44:17 +01:00
Šarūnas Nejus
e3776f1910
autobpm: Do not import 'beat' subpackage immediately to improve startup time 2024-08-19 22:44:16 +01:00