Commit Graph

96 Commits

Author SHA1 Message Date
Philipp Wolfer
9e740c11a4 Omit standard ports in URLs constructed by build_qurl 2022-01-31 07:49:21 +01:00
Philipp Wolfer
76975ae108 Have album_artist_from_path strip the Windows drive letter 2021-11-23 19:24:10 +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
Laurent Monin
14ce07756e Update Copyright headers, with the help of fix-headers.py script 2021-11-10 21:38:54 +01:00
Philipp Wolfer
a01f28d0c0 PICARD-2327: Detect hidden files on macOS 2021-11-10 08:02:50 +01:00
Philipp Wolfer
10caa13975 Add Windows specific unit test for util.is_hidden 2021-11-09 20:58:17 +01:00
Philipp Wolfer
cd559a1011 Extend wildcard to regex syntax with [...] set matching 2021-10-14 22:58:04 +02:00
Philipp Wolfer
f20da2d9aa Extend wildcard to regex syntax with ? and escape character 2021-10-14 22:58:03 +02:00
Bob Swift
e8aa0b3cd6 Add weighted script detector and multiple translation ignore options 2021-09-08 11:58:24 -06:00
Vladislav Karbovskii
7224961bc4 PICARD-157: Option to skip artist name translation for specific scripts
Add a dropdown to select a script for which artist translation will be skipped.

Co-authored-by: Laurent Monin <github@norz.org>
Co-authored-by: Bob Swift <bswift@rsds.ca>
2021-09-06 12:00:01 +02:00
Bob Swift
bfc0ac3ae5 Move make_filename_from_title to picard/util. Add tests. 2021-08-03 12:03:17 -06:00
Laurent Monin
ab54651438 Update headers 2021-06-03 13:20:42 +02:00
Laurent Monin
a4a6508b2f tracknum_and_title_from_filename(): return a named tuple 2021-06-03 13:02:46 +02:00
Philipp Wolfer
0209b5ed28 PICARD-2218: Support setting regex flags in $performer pattern 2021-06-02 23:18:45 +02:00
Philipp Wolfer
f94004763b Add picard.util.pattern_as_regex to parse string patterns as regular expressions
Replace the custom implementation of pattern parsing in TagGenreFilter with pattern_as_regex
2021-06-02 23:02:47 +02:00
Philipp Wolfer
ef62e311dd PICARD-1568: extended tests for tracknum_from_filename
Include most of the tests from test_tracknum.py. Changed a few tests as we got rid of the logic to choose the smallest of all numbers found.
2021-05-01 20:50:24 +02:00
Philipp Wolfer
19d973c36d PICARD-1568: Improve parsing track number from filenames
Avoid false positives, allow some common cases only instead of parsing all numbers.
2021-05-01 20:50:24 +02:00
Philipp Wolfer
ff58985305 PICARD-2171: Added tests for guessing tracknumber and title from filename 2021-04-28 10:51:58 +02:00
Philipp Wolfer
f845a10cac Use yield from syntax where appropriate 2021-01-15 19:21:08 +01:00
Philipp Wolfer
0d01615498 PICARD-2089: Support WebP for cover art images 2021-01-02 12:18:40 +01:00
Philipp Wolfer
c0e6243a13 PICARD-1926: Adjust test cases for new config structure 2020-12-25 12:37:15 +01:00
Philipp Wolfer
b805bcccb2 Move iter_files_from_objects to picard.util 2020-12-03 14:57:13 +01:00
Philipp Wolfer
bab8447c8e Add a tagger.iter_files_from_objects method
Similar to get_files_from_objects, but uses an iterator instead of creating a list.
2020-12-03 11:51:21 +01:00
Philipp Wolfer
6728c8c48a PICARD-2019: Fix os.path.isabs not detecting Windows share correctly
Works around the issue that os.path.isabs detects a path like \\server\share not as absolute.
This can break file naming on Windows shares and result in recursive sub folders.

See also https://bugs.python.org/issue22302
2020-11-25 15:43:54 +01:00
Laurent Monin
5e5535a21b Test for ID3 date format 2020-07-21 09:39:21 +02:00
Laurent Monin
219b734569 PICARD-1891: handle incorrect date parsing exceptions
- catch exceptions in extract_year_from_date() and log them to debug
- return None if year cannot be extracted
- check for None in metadata.compare_to_release_parts() before trying to compare years

This isn't perfect, the function is called a lot of time and it spams debug log (if enabled)

Note: I removed a very old comment in imports that doesn't make any sense (it was introduced 6 years ago in 323d12892c) and it was making isort unhappy.
2020-07-20 17:41:46 +02:00
Laurent Monin
6b5e852a60 Run fix-header on *.py 2020-02-24 10:25:09 +01:00
Laurent Monin
b5a97c9926 Merge pull request #1493 from zas/cov_cleanup
Coverage & cleanup
2020-02-24 00:34:49 +01:00
Laurent Monin
3585d40b0b PICARD-1762: fix broken PDF identification
In identify(), comparaison was done against `str` instead of `bytecode`, due to the lack of `b` prefix

ImageInfoTest: add missing test PDF file identification
2020-02-23 13:07:30 +00:00
Laurent Monin
ed351fbbd6 ImageInfoTest: remove useless ending comma 2020-02-22 21:04:32 +01:00
Laurent Monin
77a9d0110a AlbumArtistFromPathTest: add a bunch of missing tests 2020-02-22 21:04:32 +01:00
Laurent Monin
27f04356d5 TranslateArtistTest: ensure name is returned in latin-only case
The previous test wasn't that good as a reversed sortname could actually assert true
2020-02-22 21:04:32 +01:00
Laurent Monin
af5e9d647e TranslateArtistTest: improve coverage
Cases with non-latin and 3 or 4 chunks were missing
2020-02-22 21:04:32 +01:00
Laurent Monin
bd95736da4 TranslateArtistTest: u"" -> "" (Python3) 2020-02-22 21:04:32 +01:00
Laurent Monin
64bfb17733 TranslateArtistTest: remove useless assertNotEqual()
Since we assert a equals b, no need to assert a not equal c when b & c are different
Coverage is unchanged.
2020-02-22 21:04:32 +01:00
Laurent Monin
fd25dc987d PICARD-1748: limit number of countries displayed to 10 2020-02-19 20:11:58 +00:00
Laurent Monin
498c8eab1b Add mktmpdir method to PicardTestCase, and use it more widely 2020-02-08 18:04:39 +01:00
Philipp Wolfer
0855862c8c PICARD-321: Support backslash in filenames on non-Windows OS
With this change backslashes can be used in filenames on systems other than Windows. Only if Windows compatibility is activated backslashes will be replaced as before.
2019-12-14 01:03:46 +01:00
Laurent Monin
e529ee7d71 Test display_tag_name() when name contains multiple double dot separators 2019-12-09 12:48:24 +01:00
Philipp Wolfer
26d51865b4 PICARD-456: Do not remove empty standard directories
This protects standard directories like e.g. ~/Desktop being deleted if empty.
2019-09-13 16:25:51 +02:00
Philipp Wolfer
2e0afbae4d PICARD-1488: Display player position 0 as 0:00 instead of ?:?? 2019-08-13 17:42:34 +02:00
Philipp Wolfer
dc0ec84401 isort: Consistently use two blank lines after import 2019-04-04 08:35:23 +02:00
Philipp Wolfer
dd4da2aa47 Updated isort config to put test imports in separate section 2019-04-04 08:32:22 +02:00
Laurent Monin
b33e59428f Clean up various matching iterations, unify a bit
- use generators for candidates
- introduce picard.util.find_best_match() and sort_by_similarity() with tests
- partially revert change that removed sorted(), it was actually faster and cleaner
- use namedtuples to get rid of numeric indexes
- when no match, output max similarity, threshold and number of candidates to debug log
- make code easier to understand, using long names and namedtuple attributes, and simpler workflow
- use repr(best_match) for debug, as it provides all the needed info
- set values explicitly using namedtuple kw parameters
- use same prefix for namedtuples names, it eases searching through code

Typical debug output looks like:
```
D: 13:16:41,806 cluster._lookup_finished:223: BestMatch(similarity=0.79, result=SimMatchRelease(similarity=0.79, release={'id': '36b8f767-c4c0-4ba1-becd-f40a452303d5', 'score': 79, 'count': 1, 'title': 'Purple', 'status': 'Official', 'packaging': 'Jewel Case', 'text-representation': {'language': 'eng', 'script': 'Latn'}, 'artist-credit': [{'artist': {'id': '8c32bb01-58a3-453b-8050-8c0620edb0e5', 'name': 'Stone Temple Pilots', 'sort-name': 'Stone Temple Pilots'}}], 'release-group': {'id': '01d45519-54a6-3427-b0dc-222203fa5d57', 'type-id': 'f529b476-6e62-324f-b0aa-1f3e33d313fc', 'title': 'Purple', 'primary-type': 'Album'}, 'date': '1995-08-25', 'country': 'US', 'release-events': [{'date': '1995-08-25', 'area': {'id': '489ce91b-6658-3307-9877-795b68554c98', 'name': 'United States', 'sort-name': 'United States', 'iso-3166-1-codes': ['US']}}], 'track-count': 11, 'media': [{'format': 'CD', 'disc-count': 10, 'track-count': 11}]}), num_results=25) < threshold=0.800000
```
2019-03-23 16:29:44 +01:00
Philipp Wolfer
f0619614a3 PICARD-1485: Format track durations with hours
Durations of an hour or more will show the hours as HH:MM:SS
2019-03-08 10:24:12 +01:00
Laurent Monin
6388ef20f5 Use IS_WIN, IS_MACOS, IS_LINUX 2019-03-05 21:53:32 +01:00
Laurent Monin
1ca043dd90 Add tests for mbid_validate() 2019-03-04 19:35:05 +01:00
Philipp Wolfer
f93a44e00b compare_barcodes: Both None and '' are considered "no barcode" 2018-10-25 08:53:53 +02:00
Philipp Wolfer
e94e36eca0 PICARD-1383: Select release with matching barcode on disc ID lookup 2018-10-25 08:53:53 +02:00
Wieland Hoffmann
e624aa121c Make PicardTestCase the parent class of all tests
This brings the faketagger and, more importantly, settings reset to all of them.
2018-10-23 17:32:50 +02:00