Does Virtual Folders works?
How to?
I am new to PS3 and PMS.... So please explain to me how I can get this to work..
Thanks =)
chocolateboy wrote:Yes, but they're not documented. Try looking through this thread.
Index: net/pms/PMS.java
===================================================================
--- net/pms/PMS.java (revision 410)
+++ net/pms/PMS.java (working copy)
@@ -36,6 +36,7 @@
import java.net.NetworkInterface;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.Locale;
import java.util.StringTokenizer;
@@ -114,6 +115,7 @@
import net.pms.dlna.RealFile;
import java.net.URI;
import java.net.URLDecoder;
+import java.util.Comparator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -479,7 +481,16 @@
}
getRootFolder(renderer).browse(files);
-
+ VirtualFolder vfs [] = loadVirtualFoldersConf(configuration.getVirtualFolders());
+ if (files == null || files.length == 0) {
+
+ }
+ else {
+ for(VirtualFolder vf:vfs) {
+ getRootFolder(renderer).addChild(vf);
+ }
+ }
+
File webConf = new File("WEB.conf"); //$NON-NLS-1$
if (webConf.exists()) {
try {
@@ -944,6 +955,58 @@
f[j] = directories.get(j);
return f;
}
+
+ public VirtualFolder [] loadVirtualFoldersConf(String vfolders) throws IOException {
+ if (vfolders == null || vfolders.length() == 0)
+ return null;
+ ArrayList<VirtualFolder> directories = new ArrayList<VirtualFolder>();
+ Comparator<File> byDirThenAlpha = new DirAlphaComparator();
+ VirtualFolder vf;
+ StringTokenizer st = new StringTokenizer(vfolders, ";"); //$NON-NLS-1$
+ while (st.hasMoreTokens()) {
+ String line = st.nextToken();
+ String[] vfolder = line.split("\\|");
+ if (vfolder.length == 2)
+ {
+ vf = new VirtualFolder(vfolder[0],null);
+ }
+ else
+ {
+ PMS.error("Error Parsing Virtual Folder: " + vfolder[0], null);
+ continue;
+ }
+ ArrayList<File> folderFiles = new ArrayList<File>();
+ StringTokenizer stF = new StringTokenizer(vfolder[1], ",");
+ while (stF.hasMoreTokens()) {
+ String path = stF.nextToken();
+ File file = new File(path);
+ if (file.exists()) {
+ if (file.isDirectory()) {
+ //directories.add(file);
+ //vf.addChild(new RealFile(file));
+ File files [] = file.listFiles();
+ for(File f:files) {
+ //vf.addChild(new RealFile(f));
+ folderFiles.add(f);
+ }
+ } else
+ PMS.error("File " + path + " is not a directory!", null); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ PMS.error("File " + path + " does not exists!", null); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ Collections.sort(folderFiles, byDirThenAlpha);
+ for(File f:folderFiles)
+ {
+ vf.addChild(new RealFile(f));
+ }
+ directories.add(vf);
+ }
+ VirtualFolder f [] = new VirtualFolder[directories.size()];
+ for(int j=0;j<f.length;j++)
+ f[j] = directories.get(j);
+ return f;
+ }
public void reset() throws IOException {
@@ -1200,3 +1263,22 @@
}
}
+
+class DirAlphaComparator implements Comparator<File> {
+
+ // Comparator interface requires defining compare method.
+ public int compare(File filea, File fileb) {
+ //... Sort directories before files,
+ // otherwise alphabetical ignoring case.
+ if (filea.isDirectory() && !fileb.isDirectory()) {
+ return -1;
+
+ } else if (!filea.isDirectory() && fileb.isDirectory()) {
+ return 1;
+
+ } else {
+ return filea.getName().compareToIgnoreCase(fileb.getName());
+ }
+ }
+}
+
Index: net/pms/configuration/PmsConfiguration.java
===================================================================
--- net/pms/configuration/PmsConfiguration.java (revision 410)
+++ net/pms/configuration/PmsConfiguration.java (working copy)
@@ -145,6 +145,7 @@
private static final String CONFIGURATION_PATH_MAC = System.getProperty("user.home") + "/Library/Application Support/PS3 Media Server/";
private static final char LIST_SEPARATOR = ',';
private static final String KEY_FOLDERS = "folders";
+ private static final String KEY_VIRTUAL_FOLDERS = "virtual_folders";
private final PropertiesConfiguration configuration;
private final TempFolder tempFolder;
@@ -826,8 +827,16 @@
public void setFolders(String value) {
configuration.setProperty(KEY_FOLDERS, value);
- }
+ }
+ public String getVirtualFolders() {
+ return getString(KEY_VIRTUAL_FOLDERS, "");
+ }
+
+ public void setVirtualFolders(String value) {
+ configuration.setProperty(KEY_VIRTUAL_FOLDERS, value);
+ }
+
public String getNetworkInterface() {
return getString(KEY_NETWORK_INTERFACE, "");
}
chocolateboy wrote:take a look at pms-mlx
taconaut wrote:What's the question? I don't get what you're trying to do.
chocolateboy wrote:take a look at pms-mlx
Return to Additions and Plugins
Users browsing this forum: No registered users and 5 guests