Make API more narrow
This commit is contained in:
parent
b31a0e2760
commit
2b8ea5399a
@ -39,7 +39,7 @@ if __name__ == "__main__":
|
||||
logging.info("Library loaded")
|
||||
|
||||
logging.info("Finding duplicates (songs with identical title and artist)")
|
||||
duplicates = find_duplicates(library)
|
||||
duplicates = find_duplicates(library.songs)
|
||||
logging.info("Duplicates found")
|
||||
|
||||
logging.info("Finding exact duplicates (files are 100% identical)")
|
||||
|
@ -3,13 +3,12 @@ from collections.abc import Mapping, Sequence
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from karaokatalog.Library import Library
|
||||
from karaokatalog.Song import Artist, Song, Title
|
||||
|
||||
type TitleAndArtist = tuple[Title, Artist]
|
||||
|
||||
|
||||
def find_duplicates(l: Library) -> Mapping[TitleAndArtist, Sequence[Song]]:
|
||||
def find_duplicates(songs: Sequence[Song]) -> Mapping[TitleAndArtist, Sequence[Song]]:
|
||||
"""
|
||||
Find all song duplicates, i.e., all songs with the same title and same artist.
|
||||
|
||||
@ -24,7 +23,7 @@ def find_duplicates(l: Library) -> Mapping[TitleAndArtist, Sequence[Song]]:
|
||||
list
|
||||
)
|
||||
|
||||
for song in tqdm(l.songs, unit=" songs"):
|
||||
for song in tqdm(songs, unit=" songs"):
|
||||
songs_by_title_and_artist[(song.title, song.artist)].append(song)
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user