[WORKAROUND] 2CD+ Folder Structure

Tutorials, tips and tricks.

Moderator: moderators

[WORKAROUND] 2CD+ Folder Structure

Postby Schnip » Fri Dec 12, 2014 2:30 am

Hey Guys,



I really love subsonic and it redefined how I listen to my music. One thing I was pretty annoyed about though was multiple CD albums.
I got the subsonic source code and wrote a little workaround which might not be perfect but satisfactorily solves the issue for me.



To Apply this workaround you have to have an understanding of how to make your own subsonic build. I could share the .war file too, but I'm not sure if this is allowed.
Please note that I have tested this only on my own machine which means I can't guarantee it will work for you! So don't blame me if your machine catches fire! This comes without warranty.


Subsonic identifies an album by checking if a directory includes media files. I basically simply added an exclusion for this rule to directories that match "CD 1" or "CD1" >EXACTLY<. If such a folder is encountered it gets scanned even though the parent directory does not include media files.


Ok now to the fun part:


You will have to apply this modification in this file

Code: Select all
/subsonic/subsonic-main/src/main/java/net/sourceforge/subsonic/service/MediaFileService.java


between the following 2 lines:

if (!isRoot(mediaFile)) {


Begin modification

Code: Select all
File[] children = FileUtil.listFiles(file);
                File firstChild = null;
                for (File child : filterMediaFiles(children)) {
                    if (FileUtil.isFile(child)) {
                        firstChild = child;
                        break;
                    }
                    else if(child.isDirectory() && child.getName().matches("^CD 1$") || child.getName().matches("^CD1$")) {
                      File[] children2 = FileUtil.listFiles(child);
                      for (File child2 : filterMediaFiles(children2)) {
                         if (FileUtil.isFile(child2)) {
                               firstChild = child2;
                               break;
                           }
                      }
                    }
                }


End modification

if (firstChild != null) {
Schnip
 
Posts: 22
Joined: Fri Dec 12, 2014 1:57 am

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest