swingmx / swingmusic

Swing Music is a beautiful, self-hosted music player for your local audio files. Like a cooler Spotify ... but bring your own music.
https://swingmx.com
MIT License
731 stars 41 forks source link

Folders with similar names appearing inside each other, 🙀 #55

Closed cwilvx closed 2 years ago

cwilvx commented 2 years ago

Given the following folder structure:

├── The Police
│   ├── Sting - The Bridge (Deluxe) (2021) [24 Bit Hi-Res] FLAC
│   └── Sting & The Police - The Very Best Of (2002) [FLAC]

├── The Police - Remastered
│   ├── 1978 - Outlandos d'Amour [2003 Remaster]
│   │   └── 
│   ├── 1979 - Regatta de Blanc [2003 Remaster]
│   │   └── 
│   ├── 1981 - Ghost in the Machine [2003 Remaster]
│   │   └── 
│   └── 1983 - Synchronicity [2003 Remaster]
│       └── 

The paths inside The Police - Remastered appear inside The Police since The Police is common to both and they are on the same level.

I'll fix this ASAP.

cwilvx commented 2 years ago

If #57 goes through, this might not be a problem.

cwilvx commented 2 years ago

Apparently, #57 went through but this issue is partly solved. The folders no longer appear inside each other (because we are now reading the fiesystem) but the folder-track count is still an issue. The track counter function looks like this.

def get_folder_track_count(foldername: str) -> int:
    """
    Returns the number of files associated with a folder.
    """
    count = 0
    for track in api.TRACKS:
        if foldername in track.folder:
            count += 1
    return count
cwilvx commented 2 years ago

The above issue was fixed by implementing the counter with pymongo's count_documents().

cwilvx commented 2 years ago

Folders count is still wrong in cases described in the PR description. This is because counting documents return documents that match this regex rule:

'^path'

Since The Police is inside The Police - Brah brah brah, the track count will remain to be incorrect.

cwilvx commented 2 years ago

Partially fixed, no readily available fix (unless optionally disabling folder counting which means not being able to filter dirs with tracks using data in the database)