nmv: ignore new tracks when chosing candidates
This commit is contained in:
parent
4319b53cdb
commit
071a6aa4a6
13
nmv.py
13
nmv.py
@ -28,7 +28,18 @@ def main() -> None:
|
||||
|
||||
current_song = current_song_response[0]
|
||||
|
||||
search_result = shared.get_media_by_metadata(current_song.artist, current_song.track_name, conn)
|
||||
search_results = shared.get_media_by_metadata(current_song.artist, current_song.track_name, conn)
|
||||
search_results.remove(current_song)
|
||||
if len(search_results) == 1:
|
||||
search_result = search_results[0]
|
||||
|
||||
elif len(search_results) > 1:
|
||||
print(f"Found more than one match for {current_song}. Skipping")
|
||||
continue
|
||||
|
||||
else:
|
||||
continue
|
||||
|
||||
if search_result is not None:
|
||||
interaction = input(f'Do you want to move these files {str(search_result.path)!r} --> {str(file_path)!r} (Y/n)?')
|
||||
if interaction.lower() in ('', 'y', 'yes'):
|
||||
|
11
shared.py
11
shared.py
@ -11,7 +11,7 @@ class Song:
|
||||
path: Path
|
||||
|
||||
|
||||
def get_media_by_metadata(artist: str, track_name: str, conn: sqlite3.Connection) -> Song | None:
|
||||
def get_media_by_metadata(artist: str, track_name: str, conn: sqlite3.Connection) -> list[Song]:
|
||||
r = conn.execute(
|
||||
'select id, title, artist, path from media_file where lower(title) = lower(?) and lower(artist) = lower(?);',
|
||||
(track_name, artist)).fetchall()
|
||||
@ -19,14 +19,7 @@ def get_media_by_metadata(artist: str, track_name: str, conn: sqlite3.Connection
|
||||
for res in r:
|
||||
results.append(Song(*res))
|
||||
|
||||
if len(results) == 0:
|
||||
return None
|
||||
|
||||
elif len(results) == 1:
|
||||
return results[0]
|
||||
|
||||
else:
|
||||
raise RuntimeError("Found multiple matches for search criteria" + str(results))
|
||||
return results
|
||||
|
||||
|
||||
def path_clause(path: str):
|
||||
|
Loading…
x
Reference in New Issue
Block a user