Commit graph

12502 commits

Author SHA1 Message Date
Nicholas Boyd Isacsson
8e0558b804 Apply substitute rules in sequence 2024-10-16 16:36:36 +02:00
Nicholas Boyd Isacsson
19eb729db3 Refactor tests to make 2024-10-16 16:35:39 +02:00
Nicholas Boyd Isacsson
617509262e Fix test helper reordering plugin configuration 2024-10-16 16:21:32 +02:00
Šarūnas Nejus
6f41872a26
Remove unused logic from beets.test and exclude it from coverage
Fun fact: it was the coverage data that revealed that this logic is not
used.
2024-10-16 12:38:21 +01:00
Šarūnas Nejus
41907a96a6
Remove _common.album and use Album instead 2024-10-16 12:37:22 +01:00
Šarūnas Nejus
d161111342
test helpers: remove redundant _get_item_count
It always returns 1.
2024-10-16 12:33:17 +01:00
Šarūnas Nejus
2681c83c5b
Remove redundant generate_album_info and generate_track_info functions
These functions were used to generate mock data for tests but have been
replaced with direct instantiation of AlbumInfo and TrackInfo objects.
This change simplifies the test code and removes unnecessary helper
functions.
2024-10-16 06:39:30 +01:00
Nicholas Boyd Isacsson
ffdc3f73ab Revert configuration format changes 2024-10-14 22:54:38 +02:00
RollingStar
97b785e31c
ARM install instructions 2024-10-13 12:31:37 -04:00
Šarūnas Nejus
65d78cb65d
Lyrics: Fetch lyrics directly from Tekstowo (#5457)
Fixes #5456.

This pull request updates the `tekstowo` backend in the `lyrics` plugin
to fetch lyrics directly from the Tekstowo.pl website. Recent updates to
their website made the previous search-based approach unworkable.

## Changes
1. **Refactor Backend Classes:**
- Introduced a new `DirectBackend` class for backends that fetch lyrics
directly.
- Updated `MusiXmatch` and `Tekstowo` classes to inherit from
`DirectBackend`.

2. **Encoding and URL Building:**
- Added `encode` and `build_url` methods to `DirectBackend` for URL
encoding and construction.
   - Replaced our custom encoding functionality with `unidecode`.

3. **Tekstowo Backend:**
- Added encoding logic, which converts artist and title to the format
used by tekstowo.
- Removed the search functionality (`parse_search_results`), its test
and related search html files.
   - Updated `artist` and `title` checks from `extract_lyrics`.
2024-10-12 22:52:50 +01:00
Nicholas Boyd Isacsson
48c7435780 Fix code-blocks 2024-10-12 16:20:25 +02:00
Nicholas Boyd Isacsson
195644fc46 Refactor according to review comments 2024-10-12 15:34:05 +02:00
Šarūnas Nejus
d3955bac65
Update Tekstowo backend to fetch lyrics directly
- Refactored Tekstowo backend to fetch lyrics directly from song pages.
- Added `encode` method to convert artist and title to their URL format,
  where non-alphanumeric characters are replaced with underscores.
- Removed the now redundant search functionality and associated tests.
- Simplified `extract_lyrics` method to directly parse lyrics without
  any checks.
2024-10-12 02:14:18 +01:00
Šarūnas Nejus
9d2b34d457
Create DirectBackend interface for MusiXmatch and Tekstowo
And replace some of the encoding logic by unidecode.
2024-10-12 01:29:55 +01:00
Nicholas Boyd Isacsson
9bc586d7ea Replace Py3.10+ pattern matching with isinstance 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
913d51af5c Preserve rule order in substitute configuration 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
876dcb9bee Fix substitute test formatting 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
16ac231f7f Refactor substitute tests 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
81b79a08c1 Add test cases for substitute plugin 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
65096c425a Update changelog and documentation 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
9680d8f3f5 Rename variables 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
7b5d818603 Use a regex substitution in substitute 2024-10-05 15:51:41 +02:00
Nicholas Boyd Isacsson
e613a57ca4 Use case insensitive regex for substitute 2024-10-05 15:51:41 +02:00
Šarūnas Nejus
03f1205629
ftintitle: Fix false positives in "feat. X" detection in title (#5442)
Fixes #5441 

This small change explicitly passes the `for_artist` keyword to the
`plugins.feat_tokens` function that constructs the regex for matching
existing "feat. X" parts in song titles.
Previously, it was not passed and set to the default (`True`), which
caused using the pattern intended for the artist field to also be used
for the title field.
This caused some false positives as shown in #5441
2024-10-02 00:19:38 +01:00
Karl Besser
37879d0b18 Remove redundant unit tests for ftintitle plugin
Remove redundant unit tests for the `ftintitle.cotains_feat` function
2024-10-01 15:55:38 -05:00
Karl Besser
669307c91c Update ftintitle.contains_feat unit tests
Since the `for_artist` keyword has been removed from
`ftintitle.contains_feat`, the unit tests need to be updated.
This includes the deletion of the test cases that test the
`for_artist=True` delimiters.
2024-09-30 10:28:23 -05:00
Karl Besser
ed627c031c Hardcode for_artist keyword in ftintitle plugin
Remove the optional `for_artist` keyword in the
`ftintitle.contains_feat` function and hardcode it to False, since it is
always used like this in the ftintitle plugin.
2024-09-30 10:24:09 -05:00
Karl Besser
71b5a9651c Add reference to ftintitle plugin in changelog
Add references to the ftintitle plugin for the bug fixes #5441 and #5436
that are related to this plugin.
2024-09-30 10:20:29 -05:00
Karl-Ludwig Besser
ab86b2d1e8
Merge branch 'beetbox:master' into fix_false_positive_ftintitle 2024-09-30 10:17:19 -05:00
Andrew Rogl
04ee04150a
Reworked #4709 after latest release (#5447)
Fixes #4709 SQL use of Double Quoted Strings.
2024-09-30 10:28:15 +01:00
Karl Besser
85fc8e50cf Add changelog about fixing false positives in "feat. X" detection 2024-09-26 17:24:47 -04:00
Karl Besser
6cb2e5926b Add unit tests for separate "feat. X" detection
The unit tests for the `ftintitle.contains_feat` function are now split
up for artist and title matching.
2024-09-26 17:22:25 -04:00
Karl Besser
c66eb10445 Fix false positives in "feat. X" detection in ftintitle
The old version of the `ftintitle.contains_feat` function could lead to
false positives by matching words like "and" and "with" in the title,
even if there was no "feat. X" part.
With this commit, the `for_artist` keyword is explicitly passed to the
`plugins.feat_tokens` function to disable these matches when matching a
title (and not an artist).
2024-09-26 17:20:12 -04:00
J0J0 Todos
1a59368dbf
Add detection of "feat. X" parts in parentheses; Fix #5436 (#5437) 2024-09-23 22:37:49 +02:00
Karl Besser
5aa96aad17 Add changelog entry about new "feat. X" matching 2024-09-23 12:31:02 -04:00
Karl Besser
3942753a63 Delete unnecessary comma in feat detection regex 2024-09-23 12:26:51 -04:00
Karl Besser
6c8bd424e8 Add unit tests to test new feat. X detection regex
The previous version of the `plugins.feat_tokens` regular expression
only matched "feat. X" parts if preceded by a space. This caused missed
detections in the `ftintitle.contains_feat` function.
This commit adds unit tests for the updated regex that also matches
"feat. X" parts within parentheses and brackets
2024-09-22 18:30:28 -04:00
Karl Besser
8c60d2b960 Add parentheses as delimiters for feat. detection
When checking whether a title or artist contains a feature, it now also
detects them when they are in parentheses or brackets, i.e., "Song Name
(feat. XYZ)" will return true.
2024-09-22 18:21:08 -04:00
Šarūnas Nejus
88d3f040e1
Migrate from isort/Black/Flake8 to Ruff for Code Formatting and Linting (#5424)
#### Context
I noticed one of recently merged PRs used `unittest` assertions that we
are migrating from. Thus, I thought it would be a good idea to configure
our linting to catch such issues in the future. Since I was here, I
replaced our multiple linting and formatting tools with a single tool,
Ruff, to simplify and speed up our development workflow.

#### Summary
This PR migrates the codebase from using isort, Black and Flake8 to Ruff
for code formatting and linting. The changes include updates to the
GitHub Actions workflow, pre-commit configuration, and documentation to
reflect the new tooling.

#### Changes
1. **GitHub Actions Workflow**
- Updated `.github/workflows/lint.yml` to use `poetry install
--only=lint` and `poe lint --output-format=github`.

2. **Pre-commit Configuration**
   - Replaced Black and Isort with Ruff in `.pre-commit-config.yaml`.

3. **Documentation**
- Updated `CONTRIBUTING.rst` to reflect the use of Ruff for formatting
and linting.
- Modified instructions for running tests and handling external API
requests.

4. **Poetry Configuration**
- Removed Black, Isort, Flake8, and related dependencies from
`poetry.lock` and `pyproject.toml`.
   - Added Ruff as the new linter and formatter in `pyproject.toml`.

5. **Setup Configuration**
   - Removed Flake8 configuration from `setup.cfg`.

6. **Git blame**
- Introduced `.git-blame-ignore-revs` file to keep git blame clean from
formatting
changes. Configure your local `beets` repository to use this file by
running:
   ```fish
   $ git config --local blame.ignoreRevsFile .git-blame-ignore-revs
   ```

#### Benefits
- **Performance**: Ruff is known for its speed and efficiency, which
should improve the developer experience.
- **Consolidation**: Using a single tool for both formatting and linting
simplifies the development workflow.

#### How to Test
1. **Linting and Formatting**
   - Run `poe check-format` to check for formatting issues.
   - Run `poe format` to format the codebase.
   - Run `poe lint` to check for linting issues.

2. **Pre-commit Hooks**
- Ensure pre-commit hooks are working correctly by running `pre-commit
run --all-files`.

3. **CI Pipeline**
   - Verify that the GitHub Actions workflow completes successfully.

#### Notes
- Contributions migrating existing tests from `unittest` to `pytest` are
welcome.
- External API requests should be mocked using `requests_mock` and
tested weekly in the integration test suite.

#### References
- [Ruff Documentation](https://docs.astral.sh/ruff/)
- [Pre-commit Hooks](https://pre-commit.com/hooks.html)

---

This PR aims to streamline our development process by adopting Ruff, a
modern and efficient tool for Python code formatting and linting.
2024-09-21 13:35:14 +01:00
Šarūnas Nejus
11fa6c7b3f
Introduce integration_test marker and update testing docs 2024-09-21 13:26:05 +01:00
Šarūnas Nejus
edeb430842
Fix coverage task docs 2024-09-21 13:26:05 +01:00
Šarūnas Nejus
962c128510
Add .git-blame-ignore-revs file to ignore specific commits in git blame
This commit introduces a `.git-blame-ignore-revs` file to the
repository. The purpose of this file is to list specific commit hashes
that should be ignored when using the `git blame` command. This is
useful for ignoring commits that involve large-scale formatting changes,
refactoring, or other non-functional changes that would otherwise
clutter the blame history.

I added a couple of previous commit hashes which reformatted the code.

Configure this repository to use this file:

  git config --local blame.ignoreRevsFile .git-blame-ignore-revs
2024-09-21 13:26:05 +01:00
Šarūnas Nejus
fe4d4921c1
Replace OrderedEnum with a builtin IntEnum
The variable in `test_ordered_enum` was flagged for naming issues, and
I noticed that `OrderedEnum` is essentially `enum.IntEnum`.

I guess `OrderedEnum` exists because it was created before
`enum.IntEnum` was made available in Python 3.4. We do not need it
anymore though, so it's now gone.
2024-09-21 11:59:19 +01:00
Šarūnas Nejus
5f78d1b82b
Remove some lint exclusions and fix the issues
* Replace `noqa` comments in `assert...` method definitions with
  a configuration option to ignore these names.
* Use the `__all__` variable to specify importable items from the
  module, replacing `*` imports and `noqa` comments for unused imports.
* Address issues with poorly named variables and methods by renaming
  them appropriately.
2024-09-21 11:59:19 +01:00
Šarūnas Nejus
f36bc497c8
Fix lint issues
- Fix imports
- Fix pytest issues
- Do not assign lambda as variable
- Use isinstance instead of type to check type
- Rename ambiguously named variables
- Name custom errors with Error suffix
2024-09-21 11:59:18 +01:00
Šarūnas Nejus
85a17ee503
Reformat the codebase 2024-09-21 11:57:48 +01:00
Šarūnas Nejus
06a5ecaf80
Replace isort and black by ruff format 2024-09-21 11:29:24 +01:00
Šarūnas Nejus
f8ef22348b
Replace flake8 by ruff 2024-09-21 11:28:43 +01:00
J0J0 Todos
9f29c36439
Fix missing keep_in_artist option in ftintitle plugin (introduced in #5356) (#5433) 2024-09-21 09:38:07 +02:00
Karl Besser
218cda0401 Fix missing keep_in_artist option in ftintitle
The newly introduced option to keep the feat. artist in the artist field
when importing with the ftintitle plugin was not passed in one function.
2024-09-20 20:47:10 -04:00