ArturSierzant / OMPD

O!MPD is free, opensource MPD client based on PHP and mySQL.
http://ompd.pl
GNU General Public License v3.0
40 stars 13 forks source link

misc_tracks_misc_artists_folder - array support #147

Open tomchiverton opened 2 years ago

tomchiverton commented 2 years ago

For "reasons" I have, under a single folder ('/exports/mp3')

Albums - contains a folder per album Summer - contains files by different artists Spring - contains files by different artists

The trouble is that this makes single tracks show up in the library as album tracks

$cfg['misc_tracks_misc_artists_folder'] would solve this, but I think it only works for one folder name under $cfg['media_dir']

If it was an array, my library would import much cleaner

tomchiverton commented 2 years ago

This terrible, terrible hack in update.php gives me what I want. I can probably put together a merge request that does it right ?

In if ($isUpdateRequired) { just before $row=mysqli_fetch_assoc($result);

$_tc_bn = basename($dir);
if( $_tc_bn == 'Summer_good' || $_tc_bn == 'Spring_start' ){
        $artist = 'Various Artists';
        $artist_alphabetic      = $artist;
        $aGenre = '';
        $year = NULL;
        $album = basename($dir);
}

Screenshot_20211119_154328

tomchiverton commented 2 years ago

Another way would be to say "my albums are all in folder X, folder's Y,Z are all singles"

ArturSierzant commented 2 years ago

I think your idea to make $cfg['misc_tracks_misc_artists_folder'] an array would be a good solution. It would also be good if update could take covers from those folders - so each of your folder (spring, summer, etc.) could have different covers.

I'll add this feature to TODO list, but if you solve this issue, feel free to create pull request.

tomchiverton commented 4 months ago

If I set this

$cfg['misc_tracks_misc_artists_folder'] = 'Summer_good,Spring_start,Winter_bad,Autumn_end';

Based on some debugging, it looks like it picks a random (first ?) file from each folder, and that files metadata is used for the album at that path.

So I can do

843a844,860
> 
>               // misc_tracks_misc_artists_folder might also be a CSV
>               $miscs = explode( ',',$cfg['misc_tracks_misc_artists_folder'] );
>               if( count($miscs) > 1 ){
>                       $is_misc = false;
>                       foreach($miscs as $misc){
>                               if( basename($dir) == $misc ){
>                                       $is_misc = true;
> 
>                                       $artist = 'Various Artists';
>                                               $artist_alphabetic      = $artist;
>                                       $aGenre = '';
>                                       $year = NULL;
>                                       $album = basename($dir);
>                               }
>                   

Then have to do a full "force update of ALL files" and it worked.

A track entry, with an album_id entry for the track.album_id :

album_id path album_add_time updated
gvyx3lr0mp /exports/mp3/Summer_good/ 1635694644 1

and in album it's listed as 'various artists', shows up when I search for "Summer_good" in the web site etc

Is this enough for you to merge in or do you want a fuller MR, or maybe a different approach

tomchiverton commented 2 months ago

I'd also be useful for it to set the album created for each $cfg['misc_tracks_misc_artists_folder'] to be last updated by the most recent file, so it'd pop to the front of "new albums" when a file is added ?

I can't see how to do that, but it'd be the same place that sets the picture from (the most recent?) file ?