blastbeng / spotisub

Spotify to subsonic Playlist Generator and Importer
MIT License
105 stars 6 forks source link

Improve Exclusion Logic: Only Exclude Tracks with Exact Word Matches in Titles #36

Closed ramoneiggy closed 2 months ago

ramoneiggy commented 2 months ago

Hi, I love your project and find it extremely useful!

I noticed one issue: currently, if an excluded word appears anywhere in the title, the track is skipped entirely. Could I suggest modifying this to only exclude tracks if the exact word matches? This way, tracks like the following won't be excluded:

2024-09-18 13:18:58 INFO Searching Blind Guardian - Deliver Us From Evil in your music library 2024-09-18 13:18:58 WARNING Found excluded word: live. Skipping...

I've also encountered this issue with the word "demo," where it excludes titles like "demon," which can be problematic for us metal fans :)

blastbeng commented 2 months ago

Hi, I love your project and find it extremely useful!

I noticed one issue: currently, if an excluded word appears anywhere in the title, the track is skipped entirely. Could I suggest modifying this to only exclude tracks if the exact word matches? This way, tracks like the following won't be excluded:

2024-09-18 13:18:58 INFO Searching Blind Guardian - Deliver Us From Evil in your music library 2024-09-18 13:18:58 WARNING Found excluded word: live. Skipping...

I've also encountered this issue with the word "demo," where it excludes titles like "demon," which can be problematic for us metal fans :)

I am also a metal fan and i tried to find a workaround about that, actually in the development branch I have:

in subsonic_helper.py

utils.compare_string_to_exclusion(song["title"], excluded_words)
utils.compare_string_to_exclusion(song["album"], excluded_words)

in utils.py

def compare_string_to_exclusion(a, stringb):
    return compare_exclusions(a.split(), stringb)

def compare_exact_word(stringsa, stringsb, log_excluded=False):
    for stringa in stringsa:
        for stringb in stringsb:
            if stringa == stringb:
                if log_excluded is True:
                    logging.warning("Found excluded word: %s. Skipping...", stringb)
                return True    
    return False

Still need to test and improve it but using this method it will skip only if the EXACT word is found This is planned for Release 0.2.2

blastbeng commented 2 months ago

Released in 0.2.2

blastbeng commented 2 months ago

@ramoneiggy I am implementing and documenting searches by ISRC on musicbrainz database. If your music library have musicBrainzId tag in almost all the songs, the comparison will be 100% accurate and things like "demon" won't be skipped anymore

Take a look at the readme in the development branch:

Sections: