Skip to content

Adding most popular matching track when no track matches duration is a bad idea... #20

@lorenzolamasse

Description

@lorenzolamasse

Hi,

Made a slight modif in my local base to avoid adding a random matching track when there is no track matching the exact duration. It's mostly the case with remixes and extended versions that are not (yet) available on Spotify. I personally prefer skipping these tracks instead of adding a random version of them:

def best_of_multiple_matches(source_track, found_tracks):
    counter = 1
    duration_matches = [
        0,
    ]
    for track in found_tracks:
        print("\t\t\t[+] Match {}: {}".format(counter, track["id"]))
        if do_durations_match(source_track["duration_ms"], track["duration_ms"]):
            duration_matches[0] += 1
            duration_matches.append(track)
        counter += 1
    if duration_matches[0] == 1:
        best_track = duration_matches.pop()["id"]
        print(
            "\t\t\t[+] Only one exact match with matching duration, going with that one: {}".format(
                best_track
            )
        )
        return best_track
    else:
        if duration_matches[0] == 0:
            print("No track with matching duration, ignoring track !")
        else:
            
            # TODO: Popularity does not always yield the correct result
            best_track = most_popular_track(found_tracks)
            print(
                "\t\t\t[+] Multiple exact matches with matching durations, going with the most popular one: {}".format(
                best_track
                )
                )
            return best_track

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions