parent
2fbf829eed
commit
780b053219
@ -66,15 +66,27 @@ def create_track_from_file(session, path, verbose=False):
|
||||
str = f"Importing {path}"
|
||||
INFO(str)
|
||||
INFO("-" * len(str))
|
||||
track = Tracks.get_or_create(session, path)
|
||||
if verbose:
|
||||
INFO("Get track info...")
|
||||
t = get_music_info(path)
|
||||
track.title = t['title']
|
||||
track.artist = t['artist']
|
||||
title = t['title']
|
||||
artist = t['artist']
|
||||
if verbose:
|
||||
INFO(f" Title: \"{track.title}\"")
|
||||
INFO(f" Artist: \"{track.artist}\"")
|
||||
INFO(f" Title: \"{title}\"")
|
||||
INFO(f" Artist: \"{artist}\"")
|
||||
# Check for duplicate
|
||||
tracks = Tracks.search_titles(session, title)
|
||||
if tracks:
|
||||
print("Found the following possible matches:")
|
||||
for track in tracks:
|
||||
print(f'"{track.title}" by {track.artist}')
|
||||
response = input("Continue [c] or abort [a]?")
|
||||
if not response:
|
||||
return
|
||||
if response[0].lower() not in ['c', 'y']:
|
||||
return
|
||||
track = Tracks.get_or_create(session, path)
|
||||
track.title = title
|
||||
track.artist = artist
|
||||
track.duration = int(round(
|
||||
t['duration'], Config.MILLISECOND_SIGFIGS) * 1000)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user