Commit Graph

914 Commits

Author SHA1 Message Date
Bob Swift
d0f512f79f Additional tests to ensure that changes don't break other functions 2022-01-07 09:30:58 -07:00
Bob Swift
49c6c0f2ec Remove underscore from clean_multi for consistency with other functions 2022-01-07 08:56:45 -07:00
Bob Swift
63fa1633f1 Allow empty strings in multi-value variables
- Keep empty strings in multi-value lists
- Add scripting function to remove empty strings from multi-value
- Update tests
2022-01-06 10:43:47 -07:00
Laurent Monin
53ec0e066f Add test for = encoding
Suggested by phw
2022-01-06 16:07:50 +01:00
Laurent Monin
8b787482ff _query_data(): Use urllib.parse.urlencode() instead of QUrl/QUrlQuery
Note: previously spaces weren't encoded, with this change they are (as plus) which is more conform to expected format for application/x-www-form-urlencoded
Actually this was a bug in previous version, as addQueryItem() didn't encode spaces as they should
See https://doc.qt.io/qt-5/qurlquery.html#addQueryItem
"This method does not treat spaces (ASCII 0x20) and plus ("+") signs as the same, like HTML forms do. If you need spaces to be represented as plus signs, use actual plus signs."

It wasn't an issue because none of passed data should contain spaces in our current code
2022-01-06 14:41:09 +01:00
Laurent Monin
d1de2a7208 _query_data(): skip empty key and add a test 2022-01-06 14:16:11 +01:00
Laurent Monin
820551d513 Move FILE_INFO_TAGS to File class and reduce code redundancy
- add a test for File._copy_file_info_tags()
2022-01-04 12:00:19 +01:00
Philipp Wolfer
1e9c61fcfb Ensure rating submission XML is valid
Properly encode provided data
2022-01-02 17:29:34 +01:00
Laurent Monin
728b110bac Get rid of _static_encode_acoustid_args()
- modify _encode_acoustid_args() accordingly
- modify tests to reflect changes
2021-12-28 19:23:04 +01:00
Laurent Monin
c6044fbdf5 Rework AcoustIdAPIHelper and add few tests 2021-12-28 15:10:00 +01:00
Laurent Monin
6ac0501f55 Simplify & test MBAPIHelper._collection_request()
- add batch size as parameter
- use range() step and do not modify passed releases argument
- add test
2021-12-27 17:33:46 +01:00
Laurent Monin
f14922ccc4 Move part of code to _xml_ratings() and test it 2021-12-27 11:50:52 +01:00
Philipp Wolfer
7b9bec2dd8 Fix set_genre_inc_params accepting config object 2021-12-26 12:32:42 +01:00
Laurent Monin
416a55dbc0 Use set+tuple for inc, and tuple for path_list, instead of lists 2021-12-26 12:20:17 +01:00
Bob Swift
9d5597f9ff Make $slice() 'end' parameter optional 2021-12-22 12:23:27 +01:00
Philipp Wolfer
a25a6fd0aa Fixed headers with fix-header.py 2021-12-21 08:38:20 +01:00
Philipp Wolfer
d1a7063c56 PICARD-2361: Fix clustering using removed files 2021-12-14 12:29:37 +01:00
Laurent Monin
d64c8c859b Merge pull request #1983 from zas/cleanup3
Add more tests and optimize similarity2()
2021-12-04 20:12:40 +01:00
Philipp Wolfer
a4e5c7ed42 PICARD-2346: Fix ID3v2.3 files showing changes with identical tags
Fixes a regression introduced in a5fcde to optimize display of format specific metadata
2021-12-04 17:05:31 +01:00
Laurent Monin
0765da5d7e similarity2(): test few more cases 2021-12-04 16:21:41 +01:00
Philipp Wolfer
2b8ea202b5 Merge pull request #1979 from phw/refactor-webservice-queue
Refactor webservice queue
2021-11-28 20:16:01 +01:00
Philipp Wolfer
54f7ad5f44 Extract queuing code from WebService into RequestPriorityQueue class
Eases testing and reduces the webservice class complexity.
2021-11-28 17:19:28 +01:00
Laurent Monin
ac57f95d92 Introduce _node_skip_empty_iter() to reduce code redundancy 2021-11-27 19:54:18 +01:00
Philipp Wolfer
1c566ca08c PICARD-2342: Fix saving MP4 and ASF files with "clear tags" and "preserve images"
Saving MP4 or ASF files failed if the files do not have existing embedded cover art and both "clear existing tags" and "keep embedded images when clearing tags" are active.
2021-11-27 15:06:39 +01:00
Laurent Monin
7f00f523ad Improve coverage 2021-11-26 15:21:38 +01:00
Laurent Monin
bd773b56a9 Reformat test json files
Fix spacing, end of lines, overall indentation
With the help of `python3.9 -m json.tool --no-ensure-ascii`
2021-11-26 15:03:14 +01:00
Laurent Monin
208fd09a03 Merge branch 'master' into genres_counters 2021-11-26 11:33:41 +01:00
Philipp Wolfer
543709eab2 Various minor code cleanups
- Use generator comprehension where possible
- Prefer dict comprehension over dict([...])
- General code cleanup
2021-11-26 08:00:43 +01:00
Laurent Monin
8d87135684 TagGenreFilter.filter(): make it a generator taking a Counter as input
Suggested by @phw
2021-11-25 17:17:52 +01:00
Laurent Monin
2be33ef810 Move part of code to static method _genres_to_metadata() and add tests for it 2021-11-25 14:59:13 +01:00
Laurent Monin
4f04772d43 Drop DataObject.merge_genres(), use Counter() instead 2021-11-25 11:33:53 +01:00
Philipp Wolfer
76975ae108 Have album_artist_from_path strip the Windows drive letter 2021-11-23 19:24:10 +01:00
Philipp Wolfer
b4ccb1618d PICARD-2340: Use configured Various Artists name for clusters without artist 2021-11-23 15:31:58 +01:00
Philipp Wolfer
2aefcd051a PICARD-2339: Ensure clustering uses most common spelling of the same artist
This restores previous behavior, where a cluster primary artist is based on the tokenized artist name, but then the most common real spelling is being used.
2021-11-23 15:17:07 +01:00
Philipp Wolfer
bb48705357 PICARD-2339: Simplify clustering algorithm
The existing code was using the Levenshtein distance to calculate similarity, which caused a O(n^2) performance. But since only exactly similar matches where used (similarity threshold 1.0) this was not necessary.

This new implementation uses simple comparison for string equality and performs in O(n).
2021-11-23 15:16:59 +01:00
Philipp Wolfer
0ff35391be Added tests for clustering algorithm
Co-authored-by: Laurent Monin <github@norz.org>
2021-11-23 15:11:15 +01:00
Laurent Monin
02ca1e641b Fix typo: threshhold -> threshold 2021-11-21 19:16:47 +01:00
Laurent Monin
7a143c1a02 Merge pull request #1954 from rdswift/unique_title_naming
Add functions for creating unique numbered script/profile titles
2021-11-20 18:37:26 +01:00
Laurent Monin
7c3171619f Add tests for _regex_numbered_title_fmt() 2021-11-20 14:15:15 +01:00
Laurent Monin
66b63968cd Introduce new class ABExtractor in order to get extractor dynamically
- use a cache to prevent useless version & sha calculations
- based cache key on stat.st_mtime_ns + path
- declare ab_extractor as a property of tagger class
- pass tagger to all methods that needs it
2021-11-18 18:48:16 +01:00
Bob Swift
3f81eca819 Build regex in get_base_title_with_suffix() based on format provided 2021-11-17 16:44:54 -07:00
Laurent Monin
81833c8cd9 unique_numbered_title(): make format configurable, and i18n-friendly 2021-11-17 22:12:26 +01:00
Laurent Monin
55eae2d5a4 find_best_match(): use max() instead of sort_by_similarity()
- drop unused `num_results` from `BestMatch` namedtuple
- use `max()` along its `key` and `default` arguments, it is much simpler and faster
2021-11-16 21:37:48 +01:00
Bob Swift
bb57f02486 Add functions for creating unique numbered script/profile titles:
- Add utility function unique_numbered_title() -- submitted by zas
- Add utility function to extract base title to allow creating unique
numbered title for titles that have been copied.
2021-11-16 09:12:11 -07:00
Philipp Wolfer
2ea94a4d21 cdrom: Always test generic implementation 2021-11-11 09:13:09 +01:00
Philipp Wolfer
5e4cac7184 Add generic tests for util.cdrom 2021-11-11 09:12:29 +01:00
Philipp Wolfer
5a292078b7 Refactor cdrom device reading on Linux
Simplify code, add tests, get rid of Qt dependency
2021-11-11 09:12:22 +01:00
Laurent Monin
14ce07756e Update Copyright headers, with the help of fix-headers.py script 2021-11-10 21:38:54 +01:00
Laurent Monin
5b396ea766 Move part of File.update() code to a new generator File._tags_to_update()
- test it separately
- override File.supports_tag() for all tests, it ensures consistency
2021-11-10 18:06:01 +01:00
Laurent Monin
ca6cee6096 Simplify tests 2021-11-10 16:03:46 +01:00