├── .gitignore ├── .travis.yml ├── lib └── net │ ├── sf │ └── ffmpeg-java │ │ ├── maven-metadata.xml.md5 │ │ ├── maven-metadata.xml.sha1 │ │ ├── 20070916-0351 │ │ ├── ffmpeg-java-20070916-0351.jar.md5 │ │ ├── ffmpeg-java-20070916-0351.pom.md5 │ │ ├── ffmpeg-java-20070916-0351.jar.sha1 │ │ ├── ffmpeg-java-20070916-0351.pom.sha1 │ │ ├── ffmpeg-java-20070916-0351.jar │ │ └── ffmpeg-java-20070916-0351.pom │ │ └── maven-metadata.xml │ └── sourceforge │ └── lizzy │ ├── 1.1.1 │ ├── lizzy-1.1.1.jar.md5 │ ├── lizzy-1.1.1.pom.md5 │ ├── lizzy-1.1.1-sources.jar.md5 │ ├── lizzy-1.1.1.jar.sha1 │ ├── lizzy-1.1.1.pom.sha1 │ ├── lizzy-1.1.1-sources.jar.sha1 │ ├── lizzy-1.1.1.jar │ ├── lizzy-1.1.1-sources.jar │ └── lizzy-1.1.1.pom │ ├── maven-metadata.xml.md5 │ ├── maven-metadata.xml.sha1 │ └── maven-metadata.xml ├── .settings ├── org.eclipse.m2e.core.prefs ├── org.eclipse.jdt.ui.prefs ├── org.eclipse.core.resources.prefs ├── org.sonar.ide.eclipse.core.prefs └── org.eclipse.jdt.core.prefs ├── src ├── main │ ├── config │ │ └── license-templates │ │ │ └── APACHE-2.txt │ ├── resources │ │ ├── songbirdDbTools.bat │ │ ├── log4j.properties │ │ ├── checkstyle_checks.xml │ │ └── songbirdDbToolsFormatter.xml │ ├── java │ │ └── info │ │ │ └── schnatterer │ │ │ ├── java │ │ │ └── util │ │ │ │ ├── jar │ │ │ │ ├── package-info.java │ │ │ │ └── Jar.java │ │ │ │ └── Sets.java │ │ │ └── songbirdDbTools │ │ │ ├── cli │ │ │ ├── package-info.java │ │ │ ├── NoSplitter.java │ │ │ ├── SongbirdDatabaseToolsCli.java │ │ │ └── ComplexCli.java │ │ │ ├── Utils │ │ │ ├── package-info.java │ │ │ └── ResourceUtils.java │ │ │ ├── commands │ │ │ └── playlist │ │ │ │ ├── package-info.java │ │ │ │ ├── PlaylistExporter.java │ │ │ │ ├── PlaylistExporterException.java │ │ │ │ ├── PlaylistExporterImplLizzy.java │ │ │ │ └── ExportPlaylistsCommand.java │ │ │ ├── package-info.java │ │ │ └── SongbirdDatabaseTools.java │ └── assembly │ │ └── assembly.xml └── test │ └── java │ └── info │ └── schnatterer │ └── songbirdDbTools │ └── Utils │ └── ResourceUtilsTest.java ├── .checkstyle ├── .project ├── README.md ├── NOTICE.txt ├── .classpath ├── pom.xml └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | target -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 280202b83133ddc7f3ce375c270b69c1 -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.jar.md5: -------------------------------------------------------------------------------- 1 | 8291657e0879a8d34fe69483be09b1ad -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.pom.md5: -------------------------------------------------------------------------------- 1 | 7c6952525c1c101e8194ff481de73142 -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 6116f26e4f178c6576cd9f0676e63ad8 -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | c61c92d94b97bc02acf2cb675e86eb403bb10cd4 -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 22b293217b0b1351104b6329217616e8 -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.jar.sha1: -------------------------------------------------------------------------------- 1 | eb8fe5bd478386fb481dcb77eb50ed9fa62c2620 -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.pom.sha1: -------------------------------------------------------------------------------- 1 | 42ad5ba677013d8f7de257142efc0146b39c335e -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 88a5c42e6d0e4518b641af749e23d21abd278cdc -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.jar.md5: -------------------------------------------------------------------------------- 1 | 78d3c06497d83f05f89accb48b6c7c3a -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.pom.md5: -------------------------------------------------------------------------------- 1 | 26447e0d1a60e1b5be68c28a7621a7db -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | d8e63d05f6e2cb27aa3152fcc24524a506f6bc56 -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.jar.sha1: -------------------------------------------------------------------------------- 1 | 1455a4c4db671f73f1eaa09df822dcd7486daa22 -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.pom.sha1: -------------------------------------------------------------------------------- 1 | 2caa8897ac445a0ce55dea159e28f13181b673c3 -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | formatter_profile=_songbirdDbToolsFormatter 3 | formatter_settings_version=12 4 | -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schnatterer/songbirdDbTools/master/lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.jar -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schnatterer/songbirdDbTools/master/lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1-sources.jar -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/schnatterer/songbirdDbTools/master/lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.jar -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /.settings/org.sonar.ide.eclipse.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | extraProperties= 3 | lastAnalysisDate=1423855559782 4 | projectKey=info.schnatterer\:songbirdDbTools 5 | serverUrl=https\://sonar-schnatterergh.rhcloud.com 6 | version=2 7 | -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.sourceforge 4 | lizzy 5 | 6 | 1.1.1 7 | 8 | 1.1.1 9 | 10 | 20121014112058 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | net.sf 4 | ffmpeg-java 5 | 6 | 20070916-0351 7 | 8 | 20070916-0351 9 | 10 | 20121013182941 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/net/sf/ffmpeg-java/20070916-0351/ffmpeg-java-20070916-0351.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | net.sf 6 | ffmpeg-java 7 | 20070916-0351 8 | 9 | -------------------------------------------------------------------------------- /src/main/config/license-templates/APACHE-2.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) ${project.inceptionYear} ${owner} 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/songbirdDbTools.bat: -------------------------------------------------------------------------------- 1 | @REM 2 | @REM Copyright (C) 2015 Johannes Schnatterer 3 | @REM 4 | @REM Licensed under the Apache License, Version 2.0 (the "License"); 5 | @REM you may not use this file except in compliance with the License. 6 | @REM You may obtain a copy of the License at 7 | @REM 8 | @REM http://www.apache.org/licenses/LICENSE-2.0 9 | @REM 10 | @REM Unless required by applicable law or agreed to in writing, software 11 | @REM distributed under the License is distributed on an "AS IS" BASIS, 12 | @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @REM See the License for the specific language governing permissions and 14 | @REM limitations under the License. 15 | @REM 16 | 17 | @echo off 18 | java -jar %~dp0/songbirdDbTools.jar %* -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/java/util/jar/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains extensions of java.util.jar 18 | * 19 | * @author schnatterer 20 | */ 21 | package info.schnatterer.java.util.jar; -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/cli/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains the command line interface. 18 | * @author schnatterer 19 | * 20 | */ 21 | package info.schnatterer.songbirdDbTools.cli; 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/Utils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains general utility classes. 18 | * @author schnatterer 19 | * 20 | */ 21 | package info.schnatterer.songbirdDbTools.Utils; 22 | 23 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | songbirdDbTools 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | net.sf.eclipsecs.core.CheckstyleBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | 25 | org.sonar.ide.eclipse.core.sonarNature 26 | org.eclipse.jdt.core.javanature 27 | org.eclipse.m2e.core.maven2Nature 28 | net.sf.eclipsecs.core.CheckstyleNature 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/commands/playlist/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains commands related to playlists. 18 | * @author schnatterer 19 | * 20 | */ 21 | package info.schnatterer.songbirdDbTools.commands.playlist; 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * Contains all sub packages related to songbird database tools and the entry point classes. 18 | * @author schnatterer 19 | * 20 | */ 21 | package info.schnatterer.songbirdDbTools; 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # songbirdDbTools 2 | 3 | [![Build Status](https://travis-ci.org/schnatterer/songbirdDbTools.svg?branch=master)](https://travis-ci.org/schnatterer/songbirdDbTools) 4 | [![License](https://img.shields.io/github/license/schnatterer/songbirdDbTools.svg)](LICENSE) 5 | 6 | Command-line interface to [Songbird](http://www.getsongbird.com/)/[Nightingale](http://getnightingale.com/) databases. 7 | Allows for exporting playlists files from songbird databases. 8 | 9 | songbirdDbTools is a Java-based tool that can access SQLite files that are created by songbird/nightingale and aggregate information from there. 10 | 11 | Get the newest release from [here] (https://github.com/schnatterer/songbirdDbTools/releases/latest). 12 | 13 | Read the [wiki](https://github.com/schnatterer/songbirdDbTools/wiki) to find out how to use songbirdDbTools. 14 | 15 | Subscribe to the [blog] (http://schnatterer.github.com/songbirdDbTools/) in order to stay up to date. 16 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | SongbirdDbTools 2 | Copyright 2013 Johannes Schnatterer 3 | 4 | This product depends on the following libraries. 5 | 6 | Logging facade provided by SLF4j (published under MIT license) 7 | http://slf4j.org/ 8 | 9 | Logging implemented by Log4j (published under The Apache Software License, Version 2.0) 10 | http://logging.apache.org/log4j/ 11 | 12 | SQLite JDBC driver by Xerial (published under The Apache Software License, Version 2.0) 13 | http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC/ 14 | 15 | Command Line Interface by JCommander (published under The Apache Software License, Version 2.0) 16 | http://jcommander.org/ 17 | 18 | I/O Utilities by Apache Commons (published under The Apache Software License, Version 2.0) 19 | http://commons.apache.org/io/ 20 | 21 | Playlist creation by Lizzy (published under a BSD-like license) 22 | http://lizzy.sourceforge.net/ 23 | 24 | Unit testing by JUnit (published Common Public License - v 1.0) 25 | https://github.com/KentBeck/junit -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 Johannes Schnatterer 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | log4j.rootLogger=INFO, consoleLogger 18 | #log4j.rootLogger=DEBUG, consoleLogger, fileLogger 19 | log4j.logger.info.schnatterer.songbirddbapi4j=WARN 20 | 21 | log4j.appender.consoleLogger=org.apache.log4j.ConsoleAppender 22 | log4j.appender.consoleLogger.layout=org.apache.log4j.PatternLayout 23 | log4j.appender.consoleLogger.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c{1}: %m%n 24 | 25 | #log4j.appender.fileLogger=org.apache.log4j.FileAppender 26 | #log4j.appender.fileLogger.file=logs/songbirdPlaylistTools.log 27 | #log4j.appender.fileLogger.layout=org.apache.log4j.PatternLayout 28 | #log4j.appender.fileLogger.layout.ConversionPattern=%d{ISO8601} %-5p %m%n 29 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/cli/NoSplitter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.cli; 17 | 18 | import java.util.LinkedList; 19 | import java.util.List; 20 | 21 | import com.beust.jcommander.converters.IParameterSplitter; 22 | 23 | /** 24 | * jcommander parameter splitter that does not split parameters. 25 | * 26 | * @author schnatterer 27 | * 28 | */ 29 | public class NoSplitter implements IParameterSplitter { 30 | /* 31 | * (non-Javadoc) 32 | * 33 | * @see com.beust.jcommander.converters.IParameterSplitter#split(java.lang.String) 34 | */ 35 | @Override 36 | public List split(final String value) { 37 | List result = new LinkedList(); 38 | result.add(value); 39 | return result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/net/sourceforge/lizzy/1.1.1/lizzy-1.1.1.pom: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | net.sourceforge 7 | lizzy 8 | 1.1.1 9 | POM was created from install:install-file 10 | 11 | 12 | songbirdPlaylistExporterLocalRepo 13 | file://${basedir}/lib 14 | 15 | 16 | 17 | 18 | org.codehaus.castor 19 | castor-xml 20 | 1.3.3-rc1 21 | 22 | 23 | org.codehaus.castor 24 | castor-core 25 | 1.3.3-rc1 26 | 27 | 28 | commons-logging 29 | commons-logging 30 | 1.1.1 31 | 32 | 33 | com.sun.jna 34 | jna 35 | 3.0.9 36 | 37 | 38 | net.sf 39 | ffmpeg-java 40 | 20070916-0351 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/java/util/jar/Jar.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.java.util.jar; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.util.jar.Attributes; 21 | import java.util.jar.Manifest; 22 | 23 | /** 24 | * Basic abstraction from the jar file the code is contained in. 25 | * 26 | * @author schnatterer 27 | * 28 | */ 29 | public class Jar { 30 | 31 | /** 32 | * Tries to read an attribute build from the manifest of the 33 | * jar. 34 | * 35 | * @return the value of the build attribute or 36 | * null if not found or not even in a jar file 37 | * 38 | * @throws IOException 39 | * if an I/O error has occurred reading the manifest 40 | */ 41 | public static String getBuildNumberFromManifest() throws IOException { 42 | InputStream manifestStream = Thread.currentThread() 43 | .getContextClassLoader() 44 | .getResourceAsStream("META-INF/MANIFEST.MF"); 45 | if (manifestStream != null) { 46 | Manifest manifest = new Manifest(manifestStream); 47 | Attributes attributes = manifest.getMainAttributes(); 48 | return attributes.getValue("build"); 49 | } 50 | return null; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/assembly/assembly.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | bin 20 | 21 | zip 22 | 23 | 24 | 25 | 26 | false 27 | lib 28 | false 29 | 30 | 31 | 32 | 33 | 34 | 35 | ${project.basedir} 36 | / 37 | 38 | README* 39 | LICENSE* 40 | NOTICE* 41 | 42 | 43 | 44 | 45 | ${project.build.directory} 46 | / 47 | 48 | *.jar 49 | 50 | 51 | *javadoc.jar 52 | *sources.jar 53 | 54 | 55 | 56 | 57 | ${project.basedir}/src/main/resources/ 58 | / 59 | 60 | *.bat 61 | *.sh 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/commands/playlist/PlaylistExporter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.commands.playlist; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * @author schnatterer 22 | * 23 | */ 24 | public interface PlaylistExporter { 25 | 26 | /** 27 | * Export playlist from songbird database. In case of errors just logs the problem. 28 | * 29 | * @param playlistName 30 | * the name of the playlist (use this as file name) 31 | * @param absoluteMemberPaths 32 | * the absolute paths to the member files to be written to the playlist 33 | * @param destinationFolder 34 | * the folder to write the playlist to. Creates if it does not exist. 35 | * @param playlistFormat 36 | * desired format for the playlist (e.g. "m3u" or "pls") 37 | * @param useRelativePaths 38 | * if true tries to create relative paths from the playlist members to the playlist file 39 | * @param exportDynamicLists 40 | * true also exports dynamic playlists 41 | * @throws PlaylistExporterException 42 | * when the creation of the playlists fails (encapsulates any exception occurred). 43 | * @return a list of files that could not be written to the playlist because they did not exist. 44 | */ 45 | List export(final String playlistName, final List absoluteMemberPaths, String destinationFolder, 46 | String playlistFormat, boolean useRelativePaths, boolean exportDynamicLists) 47 | throws PlaylistExporterException; 48 | } -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/commands/playlist/PlaylistExporterException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.commands.playlist; 17 | 18 | /** 19 | * A checked exception type encapsulating any exception occurred during playlist creation. 20 | * 21 | * @author schnatterer 22 | * 23 | */ 24 | public class PlaylistExporterException extends Exception { 25 | /** Default serial version ID. */ 26 | private static final long serialVersionUID = 1L; 27 | 28 | /** 29 | * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently 30 | * be initialized by a call to {@link Throwable#initCause(Throwable)}. 31 | * 32 | * @param message 33 | * the detail message. The detail message is saved for later retrieval by the Throwable.getMessage() 34 | * method. 35 | * @param cause 36 | * the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). (A null 37 | * value is permitted, and indicates that the cause is nonexistent or unknown.) 38 | */ 39 | public PlaylistExporterException(final String message, final Throwable cause) { 40 | super(message, cause); 41 | } 42 | 43 | /** 44 | * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently 45 | * be initialized by a call to {@link Throwable#initCause(Throwable)}. 46 | * 47 | * @param message 48 | * the detail message. The detail message is saved for later retrieval by the Throwable.getMessage() 49 | * method. 50 | */ 51 | public PlaylistExporterException(final String message) { 52 | super(message); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/java/util/Sets.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.java.util; 17 | 18 | import java.util.Collection; 19 | import java.util.HashSet; 20 | import java.util.function.Function; 21 | import java.util.stream.Stream; 22 | 23 | /** 24 | * Implementation of basic set (in a mathematical sense) operations. 25 | * 26 | * @author schnatterer 27 | * 28 | */ 29 | public class Sets { 30 | 31 | /** 32 | * Returns the intersection of two sets, as stream. The streams might have different types. The result might contain 33 | * duplicates. 34 | * 35 | * @param a 36 | * set a, of type T 37 | * @param b 38 | * set b, of other type S. Recommendation: Use a {@link HashSet} here, as a lot of 39 | * {@link Collection#contains(Object)} is called 40 | * @param convertAtoB 41 | * converts elements of a to be comparable with type b 42 | * @param 43 | * type of set a 44 | * @param 45 | * type of set b 46 | * @return a new instance that contains the intersection between a and bb 47 | */ 48 | public static Stream intersection(Collection a, Collection b, Function convertAtoB) { 49 | return a.stream().filter(aMember -> b.contains(convertAtoB.apply(aMember))); 50 | } 51 | 52 | /** 53 | * Returns the relative complement of b in a ("a without b"). The streams might have different types. The result 54 | * might contain duplicates. 55 | * 56 | * @param a 57 | * set a, of type T 58 | * @param b 59 | * set b, of other type S. Recommendation: Use a {@link HashSet} here, as a lot of 60 | * {@link Collection#contains(Object)} is called 61 | * @param convertAtoB 62 | * converts elements of a to be comparable with type b 63 | * @param 64 | * type of set a (the one b is removed from) 65 | * @param 66 | * type of set b (the one that is removed from a ) 67 | * 68 | * @return a new instance that contains the elements of a that are not in bb 69 | */ 70 | public static Stream relativeComplement(Collection a, Collection b, Function convertAtoB) { 71 | return a.stream().filter(aMember -> !b.contains(convertAtoB.apply(aMember))); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/java/info/schnatterer/songbirdDbTools/Utils/ResourceUtilsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.Utils; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | import static org.junit.Assert.fail; 20 | 21 | import org.junit.Test; 22 | 23 | import info.schnatterer.songbirdDbTools.Utils.ResourceUtils.PathResolutionException; 24 | 25 | public class ResourceUtilsTest { 26 | @Test 27 | public void testGetRelativePathsUnix() { 28 | assertEquals("stuff/xyz.dat", ResourceUtils.getRelativePath( 29 | "/var/data/", "/var/data/stuff/xyz.dat", "/")); 30 | assertEquals("../../b/c", 31 | ResourceUtils.getRelativePath("/a/x/y/", "/a/b/c", "/")); 32 | assertEquals("../../b/c", ResourceUtils.getRelativePath( 33 | "/m/n/o/a/x/y/", "/m/n/o/a/b/c", "/")); 34 | } 35 | 36 | @Test 37 | public void testGetRelativePathFileToFile() { 38 | String target = "C:\\Windows\\Boot\\Fonts\\chs_boot.ttf"; 39 | String base = "C:\\Windows\\Speech\\Common\\sapisvr.exe"; 40 | 41 | String relPath = ResourceUtils.getRelativePath(base, target, "\\"); 42 | assertEquals("..\\..\\Boot\\Fonts\\chs_boot.ttf", relPath); 43 | } 44 | 45 | @Test 46 | public void testGetRelativePathDirectoryToFile() { 47 | String target = "C:\\Windows\\Boot\\Fonts\\chs_boot.ttf"; 48 | String base = "C:\\Windows\\Speech\\Common\\"; 49 | 50 | String relPath = ResourceUtils.getRelativePath(base, target, "\\"); 51 | assertEquals("..\\..\\Boot\\Fonts\\chs_boot.ttf", relPath); 52 | } 53 | 54 | @Test 55 | public void testGetRelativePathFileToDirectory() { 56 | String target = "C:\\Windows\\Boot\\Fonts"; 57 | String base = "C:\\Windows\\Speech\\Common\\foo.txt"; 58 | 59 | String relPath = ResourceUtils.getRelativePath(base, target, "\\"); 60 | assertEquals("..\\..\\Boot\\Fonts", relPath); 61 | } 62 | 63 | @Test 64 | public void testGetRelativePathDirectoryToDirectory() { 65 | String target = "C:\\Windows\\Boot\\"; 66 | String base = "C:\\Windows\\Speech\\Common\\"; 67 | String expected = "..\\..\\Boot"; 68 | 69 | String relPath = ResourceUtils.getRelativePath(base, target, "\\"); 70 | assertEquals(expected, relPath); 71 | } 72 | 73 | @Test 74 | public void testGetRelativePathDifferentDriveLetters() { 75 | String target = "D:\\sources\\recovery\\RecEnv.exe"; 76 | String base = "C:\\Java\\workspace\\AcceptanceTests\\Standard test data\\geo\\"; 77 | 78 | try { 79 | ResourceUtils.getRelativePath(base, target, "\\"); 80 | fail(); 81 | 82 | } catch (PathResolutionException ex) { 83 | // expected exception 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/SongbirdDatabaseTools.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools; 17 | 18 | import info.schnatterer.java.util.jar.Jar; 19 | import info.schnatterer.songbirdDbTools.cli.SongbirdDatabaseToolsCli; 20 | import info.schnatterer.songbirdDbTools.cli.SongbirdDatabaseToolsCli.ExportPlaylists; 21 | import info.schnatterer.songbirdDbTools.commands.playlist.ExportPlaylistsCommand; 22 | import info.schnatterer.songbirddbapi4.SongbirdDb; 23 | 24 | import java.io.IOException; 25 | 26 | import org.slf4j.Logger; 27 | import org.slf4j.LoggerFactory; 28 | 29 | import com.beust.jcommander.ParameterException; 30 | 31 | /** 32 | * Entry point for {@link SongbirdDatabaseTools}. Reads parameters from command line and passes them to the services. 33 | * 34 | * @author schnatterer 35 | * 36 | */ 37 | public class SongbirdDatabaseTools { 38 | /** SLF4J-Logger. */ 39 | private final Logger logger = LoggerFactory.getLogger(SongbirdDatabaseTools.class); 40 | 41 | /** 42 | * Entry point of the application. 43 | * 44 | * @param args 45 | * command line parameters 46 | */ 47 | public static void main(final String[] args) { 48 | SongbirdDatabaseTools songbirdDatabaseTools = new SongbirdDatabaseTools(); 49 | try { 50 | if (!songbirdDatabaseTools.evaluateParams(args)) { 51 | // Parameters not correct 52 | System.exit(-1); // NOSONAR: This is where the application ends in case of error 53 | } 54 | } catch (Exception e) { 55 | // Failure 56 | songbirdDatabaseTools.logger.error(e.getMessage(), e); 57 | System.exit(-1); // //NOSONAR: This is where the application ends in case of error 58 | } 59 | } 60 | 61 | /** 62 | * Reads parameters from command line and passes them to the command objects. 63 | * 64 | * @param args 65 | * command line parameters to be evaluated 66 | * @return false if there was an error relating to parameters (the error message has been logged). 67 | * true if the requested command was executed. 68 | */ 69 | static final String PROG_NAME = "songbirdDbTools"; 70 | 71 | private boolean evaluateParams(final String[] args) { 72 | logger.debug(PROG_NAME + " started..."); 73 | logger.debug("Reading command line arguments..."); 74 | 75 | /* Parse command line arguments/parameter (command line interface) */ 76 | Object commandParams = null; 77 | SongbirdDatabaseToolsCli applicationParams = new SongbirdDatabaseToolsCli(); 78 | 79 | printWelcomeMessage(); 80 | 81 | try { 82 | commandParams = applicationParams.readParams(args, PROG_NAME); 83 | } catch (ParameterException e) { // NOSONAR: Exception already logged 84 | return false; 85 | } 86 | 87 | if (commandParams != null) { 88 | String pathToDb = applicationParams.getSongbirdDB(); 89 | SongbirdDb db = new SongbirdDb(pathToDb); 90 | 91 | /* 92 | * Successfully read command line params, determine which command was called 93 | */ 94 | if (commandParams instanceof ExportPlaylists) { 95 | ExportPlaylists params = (ExportPlaylists) commandParams; 96 | new ExportPlaylistsCommand(db).exportPlaylists(params.getDestinationPath(), params.getFormat(), 97 | params.getPlaylists(), params.isRelativePaths(), params.isSkipDynamicPlaylists()); 98 | } 99 | // else if (cliParams instanceof SongbirdDatabaseToolsCli.??) { 100 | return true; 101 | } 102 | return false; 103 | } 104 | 105 | /** 106 | * Writes a welcome message to the log/console, including a build number, if available. 107 | */ 108 | private void printWelcomeMessage() { 109 | String welcomeMessage = "Welcome to " + PROG_NAME; 110 | String buildNumber; 111 | try { 112 | buildNumber = Jar.getBuildNumberFromManifest(); 113 | if (buildNumber != null) { 114 | welcomeMessage = welcomeMessage + " (" + buildNumber + ")"; 115 | } 116 | } catch (IOException e) { 117 | // If something fails we just don't print the build number 118 | } 119 | logger.info(welcomeMessage); 120 | } 121 | 122 | /** 123 | * @return the logger 124 | */ 125 | protected Logger getLogger() { 126 | return logger; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/cli/SongbirdDatabaseToolsCli.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.cli; 17 | 18 | import java.util.LinkedList; 19 | import java.util.List; 20 | 21 | import com.beust.jcommander.Parameter; 22 | import com.beust.jcommander.Parameters; 23 | 24 | /** 25 | * The SongbirdDatabaseTools command line interface takes care of parsing the arguments and printing out potential 26 | * errors. 27 | * 28 | * @author schnatterer 29 | * 30 | */ 31 | public class SongbirdDatabaseToolsCli extends ComplexCli { 32 | // private static final String DESC_HELP = "(optional) Show this message"; 33 | 34 | /** Description for parameter - command export playlist. */ 35 | private static final String DESC_COMMAND_EXPORT = "Exports playlists"; 36 | /** Description for parameter - path to songbird database. */ 37 | private static final String DESC_DB = "Path to songbird database file"; 38 | 39 | /** Definition of parameter - path to songbird database. */ 40 | @Parameter(names = { "-d", "-db" }, description = DESC_DB, required = true) 41 | private String songbirdDB; 42 | 43 | /** Definition of parameter - command export playlist (subclass). */ 44 | @Parameters(commandDescription = DESC_COMMAND_EXPORT) 45 | public class ExportPlaylists { 46 | /** Description for parameter - playlist format. */ 47 | private static final String DESC_FORMAT = "Playlist format."; 48 | /** Description for parameter - main parameter (destination folder). */ 49 | private static final String DESC_MAIN = "[destination folder to export playlists]"; 50 | /** Description for parameter - use relative paths? */ 51 | private static final String DESC_RELATIVE_PATHS = 52 | "Try to use paths relative to the playlist directory for members. "; 53 | /** Description for parameter - skip export dynamic playlists? */ 54 | private static final String DESC_DYNAMIC_LISTS = 55 | "Skip songbird's dynamic playlists (e.g. recently added, highest rated.)"; 56 | /** Description for parameter playlist names. */ 57 | private static final String DESC_PLAYLISTS = 58 | "Names of the playlists that should be exported. If not specified, all playlist are exported."; 59 | 60 | /** Definition of parameter - main parameter (destination folder). */ 61 | @Parameter(description = DESC_MAIN, required = true) 62 | private List mainParams; 63 | 64 | /** Definition of parameter - playlist format. */ 65 | @Parameter(names = { "-f", "--format" }, description = DESC_FORMAT) 66 | private String format = "m3u"; 67 | 68 | /** Definition of parameter - playlist names. */ 69 | @Parameter(names = { "-p", "--playlists" }, variableArity = true, splitter = NoSplitter.class, 70 | description = DESC_PLAYLISTS) 71 | private List playlistNames = new LinkedList<>(); 72 | 73 | /** Definition of parameter - use relative paths? */ 74 | @Parameter(names = { "-r", "--relative" }, description = DESC_RELATIVE_PATHS) 75 | private boolean relativePaths = false; 76 | 77 | /** Definition of parameter - skip dynamic playlists? */ 78 | @Parameter(names = { "-d", "--skipdynamic" }, description = DESC_DYNAMIC_LISTS) 79 | private boolean skipDynamicPlaylists = false; 80 | 81 | /** @return the value of the destination path parameter. */ 82 | public String getDestinationPath() { 83 | return mainParams.get(0); 84 | } 85 | 86 | /** @return the value of the playlist format parameter. */ 87 | public String getFormat() { 88 | return format; 89 | } 90 | 91 | /** @return the value of the "use relative paths" paramter. */ 92 | public boolean isRelativePaths() { 93 | return relativePaths; 94 | } 95 | 96 | /** 97 | * @return the value of the "skip export dynamic playlists" paramter. 98 | */ 99 | public boolean isSkipDynamicPlaylists() { 100 | return skipDynamicPlaylists; 101 | } 102 | 103 | /** 104 | * @return the playlist names that should be exported. 105 | */ 106 | public List getPlaylists() { 107 | return playlistNames; 108 | } 109 | } 110 | 111 | /** @return the value of the path to songbird database parameter. */ 112 | public String getSongbirdDB() { 113 | return songbirdDB; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/main/resources/checkstyle_checks.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/commands/playlist/PlaylistExporterImplLizzy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.commands.playlist; 17 | 18 | import info.schnatterer.songbirdDbTools.Utils.ResourceUtils; 19 | 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | import java.io.IOException; 23 | import java.io.OutputStream; 24 | import java.util.LinkedList; 25 | import java.util.List; 26 | 27 | import christophedelory.content.Content; 28 | import christophedelory.playlist.Media; 29 | import christophedelory.playlist.Playlist; 30 | import christophedelory.playlist.Sequence; 31 | import christophedelory.playlist.SpecificPlaylist; 32 | import christophedelory.playlist.SpecificPlaylistFactory; 33 | import christophedelory.playlist.SpecificPlaylistProvider; 34 | 35 | /** 36 | * Implementation of {@link PlaylistExporter}, that uses the Lizzy library.. 37 | * 38 | * @author schnatterer 39 | * 40 | */ 41 | public class PlaylistExporterImplLizzy implements PlaylistExporter { 42 | // /** SLF4J-Logger. */ 43 | // private static Logger logger = LoggerFactory.getLogger(PlaylistExporterImplLizzy.class); 44 | 45 | /* 46 | * (non-Javadoc) 47 | * 48 | * @see info.schnatterer.songbirdDbTools.commands.playlist.PlaylistExporter#export 49 | * (info.schnatterer.songbirdDbTools.backend.domain.SimpleMediaList, java.lang.String, java.lang.String, boolean) 50 | */ 51 | @Override 52 | public List export(final String playlistName, final List absoluteMemberPaths, 53 | final String destinationFolder, final String playlistFormat, final boolean useRelativePaths, 54 | final boolean exportDynamicLists) throws PlaylistExporterException { 55 | List omittedFiles = new LinkedList(); 56 | 57 | try { 58 | // Create destination directory if it does not exist 59 | new File(destinationFolder).mkdirs(); 60 | final File outputFile = 61 | new File(destinationFolder + File.separator + playlistName + "." + playlistFormat) 62 | .getCanonicalFile(); 63 | 64 | Playlist playlist = new Playlist(); 65 | 66 | for (String memberUrl : absoluteMemberPaths) { 67 | File member = new File(memberUrl); 68 | try { 69 | /* 70 | * Caution: the input string can also be an URL. Check it now. 71 | */ 72 | if (member.exists()) { 73 | /* 74 | * The file exists: begin the file/directory scan process. 75 | * 76 | * May throw SecurityException, IOException. 77 | */ 78 | addToPlaylist(playlist.getRootSequence(), member, true, outputFile, useRelativePaths); 79 | } else { 80 | // logger.info(playlistName + ": File doesn't exist: " + member.getAbsolutePath() 81 | // + ". Omitting file..."); 82 | omittedFiles.add(member.getAbsolutePath()); 83 | } 84 | } catch (Exception e) { 85 | throw new PlaylistExporterException(playlistName + ": Unable to add path to playlist: " 86 | + member.getAbsolutePath() + ": \"" + e.getMessage() + "\". Omitting file...", e); 87 | } 88 | } 89 | 90 | /* Write playlist file */ 91 | OutputStream out = null; 92 | try { 93 | out = new FileOutputStream(outputFile); 94 | SpecificPlaylistProvider provider = 95 | SpecificPlaylistFactory.getInstance().findProviderById(playlistFormat); 96 | 97 | SpecificPlaylist newSpecificPlaylist = provider.toSpecificPlaylist(playlist); 98 | newSpecificPlaylist.writeTo(out, null); 99 | } finally { 100 | if (out != null) { 101 | out.close(); 102 | } 103 | } 104 | } catch (Exception e) { 105 | throw new PlaylistExporterException("Unable to create playlist file in destination folder \"" 106 | + destinationFolder + "\", playlist name \"" + playlistName + "\" and format \"" + playlistFormat 107 | + "\": " + e.getMessage(), e); 108 | } 109 | return omittedFiles; 110 | } 111 | 112 | /** 113 | * Adds the specified file or directory, and optionally its sub-directories, to the input sequence. 114 | * 115 | * @param sequence 116 | * the playlist sequence to add to. Shall not be null. 117 | * @param member 118 | * a file or directory. Shall not be null. 119 | * @param recurse 120 | * specifies if the sub-directories of this directory shall be recursively scanned or not. 121 | * @param playlistFile 122 | * an optional file to exclude from the sequence. May be null. 123 | * @param useRelativePaths 124 | * if true, the file paths of the members are relativized to the playlist (if possible). 125 | * 126 | * @throws NullPointerException 127 | * if sequence is null. 128 | * @throws NullPointerException 129 | * if file is null. 130 | * @throws SecurityException 131 | * if a security manager exists and its {@link SecurityManager#checkRead(String)} method denies read 132 | * access to a file. 133 | * @throws IOException 134 | * if an I/O error occurs. 135 | */ 136 | private void addToPlaylist(final Sequence sequence, final File member, final boolean recurse, 137 | final File playlistFile, final boolean useRelativePaths) throws IOException, NullPointerException, 138 | SecurityException { 139 | boolean recursive = false; 140 | /* 141 | * Throws NullPointerException if file is null. May throw SecurityException. 142 | */ 143 | if (member.isDirectory()) { 144 | if (recurse) { 145 | /* May throw SecurityException. */ 146 | final File[] files = member.listFiles(); 147 | 148 | if (files != null) { 149 | for (File child : files) { 150 | /* 151 | * Throws NullPointerException if sequence is null. May throw SecurityException, IOException. 152 | */ 153 | addToPlaylist(sequence, child, recursive, playlistFile, useRelativePaths); 154 | } 155 | } 156 | } 157 | /* May throw SecurityException. */ 158 | } else if (member.isFile()) { 159 | boolean include = true; 160 | String filePath = member.getPath(); 161 | 162 | if (playlistFile != null) { 163 | // /* May throw IOException, SecurityException. */ 164 | final File canonicalMember = member.getCanonicalFile(); 165 | 166 | if (canonicalMember.equals(playlistFile)) { 167 | include = false; 168 | } else { 169 | /* 170 | * Try to make the playlist entry file name RELATIVE to the playlist file. 171 | */ 172 | 173 | if (useRelativePaths) { 174 | filePath = ResourceUtils.getRelativePath(playlistFile, member); 175 | } 176 | } 177 | } 178 | 179 | if (include) { 180 | final Media media = new Media(); 181 | final Content content = new Content(filePath); 182 | media.setSource(content); 183 | // Throws NullPointerException if sequence is null. 184 | sequence.addComponent(media); 185 | } 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/cli/ComplexCli.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.cli; 17 | 18 | import java.util.HashMap; 19 | import java.util.LinkedList; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import com.beust.jcommander.JCommander; 24 | import com.beust.jcommander.Parameter; 25 | import com.beust.jcommander.ParameterException; 26 | import com.beust.jcommander.Parameters; 27 | 28 | /** 29 | * Helper base class to complex Command Line Interfaces using {@link JCommander} A complex CLI is built like SVN or Git, 30 | * e.g. for calls like this: programName command [options]. 31 | * 32 | * This class allows for concrete classes to focus on declaring the command line interface. These concrete classes then 33 | * specify inner classes for each command whose instances are returned by {@link #readParams(String[], String)} when a 34 | * specific command is called. 35 | * 36 | * @author schnatterer 37 | * 38 | */ 39 | public abstract class ComplexCli { 40 | 41 | /** System-dependent end of line string. */ 42 | public static final String EOL = System.getProperty("line.separator"); 43 | 44 | /** Description for help parameter. */ 45 | private static final String DESC_HELP = "(optional) Show this message"; 46 | 47 | /** Help parameter. */ 48 | @Parameter(names = "--help", help = true, description = DESC_HELP) 49 | private boolean help; 50 | 51 | /** 52 | * Using the {@link JCommander} framework to parse parameters. 53 | * 54 | * See jcommander.org 55 | */ 56 | private JCommander commander = null; 57 | 58 | /** 59 | * Reads the command line parameters and prints error messages when something went wrong. 60 | * 61 | * @param argv 62 | * the command line parameters to be read 63 | * @param programmName 64 | * program name to be output in case of error 65 | * @return a concrete instance of the available commands when everything went OK 66 | * 67 | * @throws ParameterException 68 | * when something went wrong 69 | */ 70 | public Object readParams(final String[] argv, final String programmName) throws ParameterException { 71 | commander = new JCommander(this); 72 | commander.setProgramName(programmName); 73 | 74 | Map commandString2Instance = createCommands(); 75 | try { 76 | commander.parse(argv); 77 | } catch (ParameterException e) { // NOSONAR: Method call preserves exception! 78 | printErrorThrowException(e); 79 | } 80 | 81 | Object parsedCommandObject = null; 82 | if (help) { 83 | // Help parameter was issued 84 | commander.usage(); 85 | } else if (commander.getParsedCommand() == null) { 86 | // No command parameter was passed 87 | printErrorThrowException("Missing command parameter."); 88 | } else { 89 | // Determine the command object, which was passed to the CLI 90 | parsedCommandObject = commandString2Instance.get(commander.getParsedCommand().toLowerCase()); 91 | } 92 | return parsedCommandObject; 93 | } 94 | 95 | /** 96 | * Returns a list of all annotated command classes. 97 | * 98 | * @return a list of all command classes or an empty {@link List}, if none present 99 | */ 100 | public List> getCommandClasses() { 101 | List> commandClasses = new LinkedList>(); 102 | for (Class innerClass : SongbirdDatabaseToolsCli.class.getDeclaredClasses()) { 103 | if (innerClass.isAnnotationPresent(Parameters.class)) { 104 | commandClasses.add(innerClass); 105 | } 106 | } 107 | return commandClasses; 108 | } 109 | 110 | /** 111 | * Creates the command instances and adds them to {@link #commander}. 112 | * 113 | * @return a map mapping command string to command instance (command string in lower case letters) 114 | */ 115 | private Map createCommands() { 116 | 117 | Map commandString2Instance = new HashMap(); 118 | 119 | for (Class innerClass : getCommandClasses()) { 120 | if (innerClass.isAnnotationPresent(Parameters.class) && Object.class.isAssignableFrom(innerClass)) { 121 | Object command = null; 122 | try { 123 | /* 124 | * Create an instance of the inner class relating to this instance of the outer class 125 | */ 126 | command = 127 | innerClass.getDeclaredConstructor(new Class[] { this.getClass() }).newInstance( 128 | new Object[] { this }); 129 | 130 | } catch (Exception e) { // NOSONAR: Method call preserves exception! 131 | printErrorThrowException(e); 132 | } 133 | String commandStr = innerClass.getSimpleName(); 134 | String commandStrLower = commandStr.toLowerCase(); 135 | String commandStrUpper = commandStr.toUpperCase(); 136 | 137 | commandString2Instance.put(commandStrLower, command); 138 | // Add command, define lower and upper version as aliases 139 | commander.addCommand(commandStr, command, commandStrLower, commandStrUpper); 140 | } 141 | 142 | } 143 | return commandString2Instance; 144 | } 145 | 146 | /** 147 | * Prints out the error message contained in e and tries to append the usage info. 148 | * 149 | * @param msg 150 | * the error message 151 | */ 152 | private void printError(final String msg) { 153 | StringBuilder errStr = new StringBuilder(msg + EOL); 154 | if (commander != null) { 155 | // Append usage 156 | commander.usage(errStr, " "); 157 | } 158 | System.err.println(errStr.toString()); 159 | } 160 | 161 | /** 162 | * Just like {@link #printError(String)}, but in addition always throws a {@link ParameterException} 163 | * (containing e), so the main application knows something went wrong. 164 | * 165 | * @param e 166 | * the exception containing the error message. Is passed to the {@link ParameterException} as cause 167 | * @throws ParameterException 168 | * is thrown on each method call! 169 | */ 170 | private void printErrorThrowException(final Throwable e) throws ParameterException { 171 | printError(e.getMessage()); 172 | /* 173 | * Throw an Exception, so the main application knows something went wrong 174 | */ 175 | if (e instanceof ParameterException) { 176 | // Rethrow 177 | throw (ParameterException) e; 178 | } else { 179 | throw new ParameterException(e); 180 | } 181 | } 182 | 183 | /** 184 | * Convenience method for {@link #printErrorThrowException(Throwable)}. 185 | * 186 | * @param msg 187 | * the error message 188 | * @throws ParameterException 189 | * is thrown on each method call! 190 | */ 191 | private void printErrorThrowException(final String msg) throws ParameterException { 192 | printError(msg); 193 | /* 194 | * Throw an Exception, so the main application knows something went wrong 195 | */ 196 | throw new ParameterException(msg); 197 | } 198 | 199 | /** 200 | * @return the help 201 | */ 202 | protected boolean isHelp() { 203 | return help; 204 | } 205 | 206 | } 207 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 4.0.0 20 | info.schnatterer 21 | songbirdDbTools 22 | 0.3-SNAPSHOT 23 | Songbird Database Tools 24 | A collection of tools to access a songbird database file 25 | https://github.com/schnatterer/songbird2itunes 26 | 27 | 28 | 29 | Apache License, Version 2.0 30 | http://www.apache.org/licenses/LICENSE-2.0.txt 31 | 32 | 33 | 34 | 35 | scm:git:ssh://github.com/schnatterer/songbirdDbTools.git 36 | scm:git:ssh://git@github.com/schnatterer/songbirdDbTools.git 37 | http://schnatterer.github.io/songbirdDbTools/ 38 | HEAD 39 | 40 | 41 | 42 | UTF-8 43 | yyyyMMddHHmmss 44 | v.${project.version} build ${maven.build.timestamp} 45 | 46 | 1.7.12 47 | 2.11 48 | 49 | 50 | 51 | 52 | songbirdPlaylistExporterLocalRepo 53 | file://${basedir}/lib 54 | 55 | 56 | jitpack.io 57 | https://jitpack.io 58 | 59 | 60 | 61 | 62 | 63 | com.github.schnatterer 64 | songbirdDbApi4j 65 | v.1.0 66 | 67 | 68 | org.slf4j 69 | slf4j-api 70 | ${slf4j.version} 71 | 72 | 73 | org.slf4j 74 | slf4j-log4j12 75 | ${slf4j.version} 76 | 77 | 78 | log4j 79 | log4j 80 | 1.2.17 81 | 82 | 83 | org.xerial 84 | sqlite-jdbc 85 | 3.7.2 86 | 87 | 88 | com.beust 89 | jcommander 90 | 1.30 91 | 92 | 93 | commons-io 94 | commons-io 95 | 1.3.2 96 | 97 | 98 | net.sourceforge. 99 | lizzy 100 | 1.1.1 101 | 102 | 103 | junit 104 | junit 105 | 4.10 106 | test 107 | 108 | 109 | 110 | 111 | ${project.artifactId}-${project.version} 112 | 113 | 114 | org.apache.maven.plugins 115 | maven-compiler-plugin 116 | 3.3 117 | 118 | 1.8 119 | 1.8 120 | 121 | 122 | 123 | org.apache.maven.plugins 124 | maven-release-plugin 125 | 2.5.1 126 | 127 | -Prelease 128 | 129 | v.@{project.version} 130 | 131 | 132 | 133 | 134 | maven-deploy-plugin 135 | 2.8.1 136 | 137 | internal.repo::default::file://${project.build.directory}/release 138 | 139 | 140 | 141 | 142 | org.apache.maven.plugins 143 | maven-assembly-plugin 144 | 145 | 146 | 147 | 148 | src/main/assembly/assembly.xml 149 | 150 | 151 | 152 | 153 | 154 | install 155 | 156 | single 157 | 158 | 159 | 160 | 161 | 162 | 163 | org.apache.maven.plugins 164 | maven-jar-plugin 165 | 2.6 166 | 167 | 168 | ${project.artifactId} 169 | 170 | 171 | 172 | 173 | true 174 | 175 | lib/ 176 | info.schnatterer.songbirdDbTools.SongbirdDatabaseTools 177 | 178 | 179 | ${buildNumber} 180 | 181 | 182 | 183 | 184 | 185 | 187 | com.mycila 188 | license-maven-plugin 189 | ${license-maven-plugin.version} 190 | 191 |
src/main/config/license-templates/APACHE-2.txt
192 | 193 | 2015 194 | Johannes Schnatterer 195 | 196 | 197 | LICENSE.txt 198 | NOTICE.txt 199 | lib/** 200 | 201 |
202 | 203 | 204 | 205 | com.mycila 206 | license-maven-plugin-git 207 | 208 | ${license-maven-plugin.version} 209 | 210 | 211 | 212 | 213 | 214 | validate 215 | 216 | check 217 | 218 | 219 | 220 |
221 | 222 | 223 | org.jacoco 224 | jacoco-maven-plugin 225 | 0.7.5.201505241946 226 | 227 | 228 | initialize 229 | 230 | prepare-agent 231 | 232 | 233 | 234 | 235 |
236 |
237 |
238 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/Utils/ResourceUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.Utils; 17 | 18 | import java.io.File; 19 | import java.util.regex.Pattern; 20 | 21 | import org.apache.commons.io.FilenameUtils; 22 | 23 | /** 24 | * Utility class containing methods handling resources (files). 25 | * 26 | * @author schnatterer 27 | * 28 | */ 29 | public final class ResourceUtils { 30 | /** Don't instantiate utility classes! */ 31 | private ResourceUtils() { 32 | } 33 | 34 | /** 35 | * An array contains the most important characters that are not allowed in file names. 36 | */ 37 | public static final char[] ILLEGAL_FILE_NAME_CHARS = { '/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', 38 | '<', '>', '|', '\"', ':' }; 39 | /** 40 | * The hard-coded default-value which is used to replace illegal characters in file names. 41 | */ 42 | public static final char DEFAULT_REPLACEMENT_CHAR = '-'; 43 | 44 | /** 45 | * Convenience method for {@link ResourceUtils#getRelativePath(String, String, String)}, using {@link File} 46 | * parameters. 47 | * 48 | * @param base 49 | * basePath is calculated from this file 50 | * @param path 51 | * targetPath is calculated to this file 52 | * @return targetPath relativized to basePath 53 | */ 54 | public static String getRelativePath(final File base, final File path) { 55 | // return base.toURI().relativize(path.toURI()).getPath(); 56 | return getRelativePath(base.getAbsolutePath(), path.getAbsolutePath(), File.separator); 57 | } 58 | 59 | /** 60 | * Convenience method for {@link ResourceUtils#getRelativePath(String, String, String)}, which uses the 61 | * system-dependent default file separator {@link java.io.File#separator}. 62 | * 63 | * @param basePath 64 | * basePath is calculated from this file 65 | * @param targetPath 66 | * targetPath is calculated to this file 67 | * @return targetPath relativized to basePath 68 | */ 69 | public static String getRelativePath(final String basePath, final String targetPath) { 70 | return getRelativePath(basePath, targetPath, File.separator); 71 | } 72 | 73 | /** 74 | * Get the relative path from one file to another, specifying the directory separator. If one of the provided 75 | * resources does not exist, it is assumed to be a file unless it ends with '/' or '\'. 76 | * 77 | * @param targetPath 78 | * targetPath is calculated to this file 79 | * @param basePath 80 | * basePath is calculated from this file 81 | * @param pathSeparator 82 | * directory separator. The platform default is not assumed so that we can test Unix behavior when 83 | * running on Windows (for example) 84 | * @return targetPath relativized to basePath 85 | * 86 | * @author http://stackoverflow.com/questions/204784/how-to-construct-a-relative 87 | * -path-in-java-from-two-absolute-paths-or-urls 88 | */ 89 | public static String getRelativePath(final String basePath, final String targetPath, final String pathSeparator) { 90 | 91 | // Normalize the paths 92 | String normalizedTargetPath = FilenameUtils.normalizeNoEndSeparator(targetPath); 93 | String normalizedBasePath = FilenameUtils.normalizeNoEndSeparator(basePath); 94 | 95 | // Undo the changes to the separators made by normalization 96 | if (pathSeparator.equals("/")) { 97 | normalizedTargetPath = FilenameUtils.separatorsToUnix(normalizedTargetPath); 98 | normalizedBasePath = FilenameUtils.separatorsToUnix(normalizedBasePath); 99 | 100 | } else if (pathSeparator.equals("\\")) { 101 | normalizedTargetPath = FilenameUtils.separatorsToWindows(normalizedTargetPath); 102 | normalizedBasePath = FilenameUtils.separatorsToWindows(normalizedBasePath); 103 | 104 | } else { 105 | throw new IllegalArgumentException("Unrecognised dir separator '" + pathSeparator + "'"); 106 | } 107 | 108 | String[] base = normalizedBasePath.split(Pattern.quote(pathSeparator)); 109 | String[] target = normalizedTargetPath.split(Pattern.quote(pathSeparator)); 110 | 111 | // First get all the common elements. Store them as a string, 112 | // and also count how many of them there are. 113 | StringBuffer common = new StringBuffer(); 114 | 115 | int commonIndex = 0; 116 | while (commonIndex < target.length && commonIndex < base.length 117 | && target[commonIndex].equals(base[commonIndex])) { 118 | common.append(target[commonIndex] + pathSeparator); 119 | commonIndex++; 120 | } 121 | 122 | if (commonIndex == 0) { 123 | // No single common path element. This most 124 | // likely indicates differing drive letters, like C: and D:. 125 | // These paths cannot be relativized. 126 | throw new PathResolutionException("No common path element found for '" + normalizedTargetPath + "' and '" 127 | + normalizedBasePath + "'"); 128 | } 129 | 130 | // The number of directories we have to backtrack depends on whether the 131 | // base is a file or a dir 132 | // For example, the relative path from 133 | // 134 | // /foo/bar/baz/gg/ff to /foo/bar/baz 135 | // 136 | // ".." if ff is a file 137 | // "../.." if ff is a directory 138 | // 139 | // The following is a heuristic to figure out if the base refers to a 140 | // file or dir. It's not perfect, because 141 | // the resource referred to by this path may not actually exist, but 142 | // it's the best I can do 143 | boolean baseIsFile = true; 144 | 145 | File baseResource = new File(normalizedBasePath); 146 | 147 | if (baseResource.exists()) { 148 | baseIsFile = baseResource.isFile(); 149 | 150 | } else if (basePath.endsWith(pathSeparator)) { 151 | baseIsFile = false; 152 | } 153 | 154 | StringBuffer relative = new StringBuffer(); 155 | 156 | if (base.length != commonIndex) { 157 | 158 | int numDirsUp; 159 | if (baseIsFile) { 160 | numDirsUp = base.length - commonIndex - 1; 161 | } else { 162 | numDirsUp = base.length - commonIndex; 163 | } 164 | 165 | for (int i = 0; i < numDirsUp; i++) { 166 | relative.append(".." + pathSeparator); 167 | } 168 | } 169 | relative.append(normalizedTargetPath.substring(common.length())); 170 | return relative.toString(); 171 | } 172 | 173 | /** 174 | * Checks if a {@link String} would be a valid filename. Basing on the invalid characters in 175 | * {@link #ILLEGAL_FILE_NAME_CHARS}. 176 | * 177 | * @param potentialFileName 178 | * the string to validate. 179 | * @return true, if the {@link String} would be a valid file name, otherwise false. 180 | */ 181 | public static boolean isLegalFilename(final String potentialFileName) { 182 | for (char c : ILLEGAL_FILE_NAME_CHARS) { 183 | if (potentialFileName.indexOf(c) > -1) { 184 | return false; 185 | } 186 | } 187 | return true; 188 | } 189 | 190 | /** 191 | * Replaces all illegal characters ({@link #ILLEGAL_FILE_NAME_CHARS}) by {@link #DEFAULT_REPLACEMENT_CHAR}. 192 | * 193 | * @param potentialFileName 194 | * the file to be "legalized" 195 | * @return a completely legal file name 196 | */ 197 | public static String legalizeFileName(final String potentialFileName) { 198 | String legalFileName = potentialFileName; 199 | for (char c : ILLEGAL_FILE_NAME_CHARS) { 200 | int illegalIndex = potentialFileName.indexOf(c); 201 | if (illegalIndex > -1) { 202 | legalFileName = potentialFileName.replace(c, DEFAULT_REPLACEMENT_CHAR); 203 | } 204 | } 205 | return legalFileName; 206 | } 207 | 208 | /** 209 | * Exception thrown by {@link ResourceUtils#getRelativePath(String, String, String)}. 210 | * 211 | * 212 | * @author schnatterer 213 | * 214 | */ 215 | public static class PathResolutionException extends RuntimeException { 216 | /** serialVersionUID. */ 217 | private static final long serialVersionUID = 1121663230711844799L; 218 | 219 | /** 220 | * Creates a {@link PathResolutionException} containing a specific message. 221 | * 222 | * @param msg 223 | * the message to be transported by the exception 224 | */ 225 | PathResolutionException(final String msg) { 226 | super(msg); 227 | } 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /src/main/java/info/schnatterer/songbirdDbTools/commands/playlist/ExportPlaylistsCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2015 Johannes Schnatterer 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package info.schnatterer.songbirdDbTools.commands.playlist; 17 | 18 | import info.schnatterer.java.util.Sets; 19 | import info.schnatterer.songbirdDbTools.Utils.ResourceUtils; 20 | import info.schnatterer.songbirddbapi4.SongbirdDb; 21 | import info.schnatterer.songbirddbapi4j.domain.MediaItem; 22 | import info.schnatterer.songbirddbapi4j.domain.MemberMediaItem; 23 | import info.schnatterer.songbirddbapi4j.domain.Property; 24 | import info.schnatterer.songbirddbapi4j.domain.SimpleMediaList; 25 | 26 | import java.io.File; 27 | import java.net.URI; 28 | import java.nio.file.FileSystemException; 29 | import java.sql.SQLException; 30 | import java.util.Collection; 31 | import java.util.LinkedList; 32 | import java.util.List; 33 | import java.util.Set; 34 | import java.util.stream.Collectors; 35 | 36 | import org.apache.commons.lang.StringUtils; 37 | import org.slf4j.Logger; 38 | import org.slf4j.LoggerFactory; 39 | 40 | /** 41 | * Command that handles exporting Sonbgird playlists to playlist files. 42 | * 43 | * @author schnatterer 44 | * 45 | */ 46 | public final class ExportPlaylistsCommand { 47 | private final SongbirdDb songbirdDb; 48 | 49 | public ExportPlaylistsCommand(SongbirdDb songbirdDb) { 50 | this.songbirdDb = songbirdDb; 51 | } 52 | 53 | /** System-dependent End Of Line string. */ 54 | public static final String EOL = System.getProperty("line.separator"); 55 | 56 | /** SLF4J-Logger. */ 57 | private static Logger logger = LoggerFactory.getLogger(ExportPlaylistsCommand.class); 58 | 59 | /** 60 | * Playlist exporter implementation used by the command to write the actual playlist files. 61 | */ 62 | private static PlaylistExporter playlistExporter = new PlaylistExporterImplLizzy(); 63 | 64 | /** 65 | * Exports all songbird playlists in a specific format to a specified destination folder. 66 | * 67 | * @param destinationFolder 68 | * the folder to write the playlist to 69 | * @param playlistFormat 70 | * desired format for the playlist (e.g. "m3u" or "pls") if 71 | * @param requestedPlaylistNames 72 | * the names of the playlists to be exported. If null or empty, all playlists are exported. 73 | * @param useRelativePaths 74 | * true tries to create relative paths from the playlist members to the playlist file 75 | * @param skipDynamicLists 76 | * true skips dynamic playlists 77 | */ 78 | public void exportPlaylists(final String destinationFolder, final String playlistFormat, 79 | final List requestedPlaylistNames, final boolean useRelativePaths, final boolean skipDynamicLists) { 80 | 81 | // Check if playlist can be written to destination folder. 82 | try { 83 | checkDirectory(destinationFolder); 84 | } catch (Exception e) { 85 | logger.warn("Error writing playlist: " + e.getMessage(), e); 86 | return; 87 | } 88 | 89 | try { 90 | // Find playlists in songbird 91 | List playlistsToMigrate = 92 | songbirdDb 93 | .getPlayLists(true, true) 94 | .stream() 95 | .sorted((p1, p2) -> p1.getList().getProperty(Property.PROP_MEDIA_LIST_NAME) 96 | .compareTo(p2.getList().getProperty(Property.PROP_MEDIA_LIST_NAME))) 97 | .collect(Collectors.toList()); 98 | logger.info(playlistsToMigrate.size() + " playlist(s) were found in songbird: " 99 | + extractPlaylistNames(playlistsToMigrate)); 100 | 101 | // Filter playlist as requested by the user 102 | if (requestedPlaylistNames != null && !requestedPlaylistNames.isEmpty()) { 103 | // Remove duplicates and sort 104 | List requestedPlaylistNamesOrdered = 105 | requestedPlaylistNames.stream().distinct().sorted().collect(Collectors.toList()); 106 | logger.info(requestedPlaylistNamesOrdered.size() + " playlist(s) were requested by the user: " 107 | + toStringQuoted(requestedPlaylistNamesOrdered)); 108 | 109 | Set requestedPlaylistNamesSetUpper = 110 | requestedPlaylistNamesOrdered.stream().map(playlistName -> playlistName.trim().toUpperCase()) 111 | .collect(Collectors.toSet()); 112 | Set songbirdPlaylistNamesSetUpper = 113 | playlistsToMigrate 114 | .stream() 115 | .map(playlist -> playlist.getList().getProperty(Property.PROP_MEDIA_LIST_NAME).trim() 116 | .toUpperCase()).collect(Collectors.toSet()); 117 | 118 | // find playlists that are only in songbird but not requeted 119 | List ignoredPlaylists = 120 | Sets.relativeComplement( 121 | playlistsToMigrate, 122 | requestedPlaylistNamesSetUpper, 123 | playlist -> playlist.getList().getProperty(Property.PROP_MEDIA_LIST_NAME).trim() 124 | .toUpperCase()) 125 | .map(playlist -> playlist.getList().getProperty(Property.PROP_MEDIA_LIST_NAME)) 126 | .distinct().sorted().collect(Collectors.toList()); 127 | if (!ignoredPlaylists.isEmpty()) { 128 | logger.info(ignoredPlaylists.size() 129 | + " playlists are not migrated because they were not requested by the user: " 130 | + toStringQuoted(ignoredPlaylists)); 131 | } 132 | 133 | // find playlists thate are only requested but not in songbird 134 | List requestedPlaylistsNotFound = 135 | Sets.relativeComplement(requestedPlaylistNamesOrdered, songbirdPlaylistNamesSetUpper, 136 | playlistName -> playlistName.trim().toUpperCase()).distinct().sorted() 137 | .collect(Collectors.toList()); 138 | if (!requestedPlaylistsNotFound.isEmpty()) { 139 | // This must be a warning 140 | logger.warn(requestedPlaylistsNotFound.size() 141 | + " playlist(s) were requested by the user but not found in songbird: " 142 | + toStringQuoted(requestedPlaylistsNotFound)); 143 | } 144 | 145 | // Limit to playlists that are both: in songbird and requested 146 | playlistsToMigrate = 147 | Sets.intersection( 148 | playlistsToMigrate, 149 | requestedPlaylistNamesSetUpper, 150 | playlist -> playlist.getList().getProperty(Property.PROP_MEDIA_LIST_NAME).trim() 151 | .toUpperCase()).distinct().collect(Collectors.toList()); 152 | 153 | logger.info(playlistsToMigrate.size() 154 | + " playlist(s) from the list were found in songbird and will be migrated: " 155 | + extractPlaylistNames(playlistsToMigrate)); 156 | } 157 | 158 | // Migrate filtered playlists 159 | for (SimpleMediaList simpleMediaList : playlistsToMigrate) { 160 | 161 | // String playlistName = simpleMediaList.getList().getProperty( 162 | // Property.PROP_MEDIA_LIST_NAME); 163 | 164 | // if (logger.isDebugEnabled()) { 165 | // // Print playlist info 166 | // logger.debug("Playlist: ID: " 167 | // + simpleMediaList.getList().getId() 168 | // + ": \"" 169 | // + simpleMediaList.getList().getProperty( 170 | // Property.PROP_MEDIA_LIST_NAME) 171 | // + "\"; Type: " 172 | // + simpleMediaList.getList().getListType()); 173 | // } 174 | 175 | // Export Playlist 176 | // try { 177 | String playlistName = simpleMediaList.getList().getProperty(Property.PROP_MEDIA_LIST_NAME); 178 | if (playlistName == null) { 179 | logger.warn("Found playlist with no name. Skipping list. " + simpleMediaList); 180 | continue; 181 | } 182 | if (playlistName.startsWith("&smart.defaultlist.")) { 183 | playlistName = playlistName.substring("&smart.defaultlist.".length()); 184 | } 185 | 186 | try { 187 | List omittedFiles = 188 | playlistExporter.export(playlistNameToFileName(playlistName), 189 | getMemberPaths(simpleMediaList), destinationFolder, playlistFormat, 190 | useRelativePaths, skipDynamicLists); 191 | String output = "Finished writing playlist " + playlistName; 192 | if (omittedFiles != null && omittedFiles.size() > 0) { 193 | output += ". The following files were omitted because they did not exist: " + EOL; 194 | output += StringUtils.join(omittedFiles, EOL); 195 | } 196 | logger.info(output); 197 | } catch (PlaylistExporterException e) { 198 | logger.warn("Error creating playlist: " + e.getMessage(), e); 199 | } 200 | // } catch (IOException e) { 201 | // logger.error("Unable to write playlist file", e); 202 | // } catch (Exception e) { 203 | // logger.error("Error while trying to write playlist file", e); 204 | // } finally { 205 | // try { 206 | // out.close(); 207 | // } catch (IOException e) { 208 | // logger.error("Unable to close playlist file", e); 209 | // } 210 | // } 211 | // } catch (FileNotFoundException e) { 212 | // logger.error("Unable to open playlist file for writing", 213 | // e); 214 | // } 215 | } 216 | } catch (SQLException e) { 217 | /* 218 | * if the error message is "out of memory", it probably means no database file is found 219 | */ 220 | logger.error("Error reading songbird database", e); 221 | } 222 | } 223 | 224 | /** 225 | * Checks a path, if it exists, is a directory and if the application can write to it. 226 | * 227 | * @param destinationFolder 228 | * the path to be checked. 229 | * @throws FileSystemException 230 | * if any of the mentioned checks fails. 231 | */ 232 | private static void checkDirectory(final String destinationFolder) throws FileSystemException { 233 | File destinationFile = new File(destinationFolder); 234 | if (!destinationFile.exists()) { 235 | throw new FileSystemException("Destination folder does not exist: " + destinationFile.getAbsolutePath()); 236 | } 237 | if (!destinationFile.isDirectory()) { 238 | throw new FileSystemException("Destination folder is not a directory: " 239 | + destinationFile.getAbsolutePath()); 240 | } 241 | if (!destinationFile.canWrite()) { 242 | throw new FileSystemException("Destination folder is read only: " + destinationFile.getAbsolutePath()); 243 | } 244 | } 245 | 246 | /** 247 | * Changes the playlist name, so it can be used as file name (if necessary). 248 | * 249 | * @param playlistName 250 | * the name of the playlist 251 | * @return playlistName as a valid filename. 252 | */ 253 | private static String playlistNameToFileName(final String playlistName) { 254 | String newPlaylistName = playlistName; 255 | if (!ResourceUtils.isLegalFilename(playlistName)) { 256 | newPlaylistName = ResourceUtils.legalizeFileName(playlistName); 257 | logger.info("Playlist name \"" + playlistName + "\" cannot be used as file name. Replacing by \"" 258 | + newPlaylistName); 259 | } 260 | 261 | return newPlaylistName; 262 | } 263 | 264 | /** 265 | * Aggregates a list of member absolute paths from a {@link SimpleMediaList}. 266 | * 267 | * @param simpleMediaList 268 | * the media list to read the member objects from 269 | * @return all member files as absolute string Urls 270 | */ 271 | private static List getMemberPaths(final SimpleMediaList simpleMediaList) { 272 | List memberFiles = new LinkedList(); 273 | 274 | for (MemberMediaItem member : simpleMediaList.getMembers()) { 275 | MediaItem m = member.getMember(); 276 | 277 | try { 278 | File file = new File(new URI(m.getContentUrl())); 279 | /* 280 | * Make sure Songbird's slash-separated URI work (even on Windows). If this step is omitted, 281 | * relativize() is not going to work 282 | */ 283 | file = file.getCanonicalFile(); 284 | memberFiles.add(file.getAbsolutePath()); 285 | } catch (Exception e) { 286 | logger.warn(simpleMediaList.getList().getProperty(Property.PROP_MEDIA_LIST_NAME) 287 | + ": Unable to add path to playlist: " + m.getContentUrl() + ": \"" + e.getMessage() 288 | + "\". Omitting file...", e); 289 | // So we use the absolute path instead... 290 | } 291 | } 292 | return memberFiles; 293 | } 294 | 295 | /** 296 | * Returns only the names of a list of {@link SimpleMediaList}s. 297 | * 298 | * @param playLists 299 | * the list of playlist objects 300 | * @return the names of the playlist objects 301 | */ 302 | private String extractPlaylistNames(List playLists) { 303 | return toStringQuoted(playLists.stream() 304 | .map(playlist -> playlist.getList().getProperty(Property.PROP_MEDIA_LIST_NAME)) 305 | .collect(Collectors.toList())); 306 | } 307 | 308 | /** 309 | * Convert a list of Strings to a single string, that contains the comma-separated strings wrapped in quotes. 310 | * 311 | * @param list 312 | * the list to convert 313 | * 314 | * @return one concatenated string 315 | */ 316 | private String toStringQuoted(Collection list) { 317 | return list.stream().map(str -> "\"" + str + "\"").collect(Collectors.joining(", ")); 318 | } 319 | } 320 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.source=1.8 13 | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 14 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 15 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 16 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 17 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 18 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 19 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 20 | org.eclipse.jdt.core.formatter.alignment_for_assignment=16 21 | org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 22 | org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 23 | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 24 | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 25 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 26 | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=16 27 | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 28 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 29 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 30 | org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=16 31 | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 32 | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 33 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 34 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 35 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 36 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 37 | org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 38 | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 39 | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 40 | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 41 | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 42 | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 43 | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 44 | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 45 | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 46 | org.eclipse.jdt.core.formatter.blank_lines_before_package=0 47 | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 48 | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 49 | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line 50 | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line 51 | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line 52 | org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line 53 | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line 54 | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line 55 | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line 56 | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line 57 | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line 58 | org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line 59 | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line 60 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false 61 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false 62 | org.eclipse.jdt.core.formatter.comment.format_block_comments=true 63 | org.eclipse.jdt.core.formatter.comment.format_header=false 64 | org.eclipse.jdt.core.formatter.comment.format_html=true 65 | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true 66 | org.eclipse.jdt.core.formatter.comment.format_line_comments=true 67 | org.eclipse.jdt.core.formatter.comment.format_source_code=true 68 | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true 69 | org.eclipse.jdt.core.formatter.comment.indent_root_tags=true 70 | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert 71 | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert 72 | org.eclipse.jdt.core.formatter.comment.line_length=120 73 | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true 74 | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true 75 | org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 76 | org.eclipse.jdt.core.formatter.compact_else_if=true 77 | org.eclipse.jdt.core.formatter.continuation_indentation=2 78 | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 79 | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off 80 | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on 81 | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false 82 | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 83 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true 84 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true 85 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true 86 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true 87 | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true 88 | org.eclipse.jdt.core.formatter.indent_empty_lines=false 89 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true 90 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true 91 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true 92 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false 93 | org.eclipse.jdt.core.formatter.indentation.size=4 94 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert 95 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert 96 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert 97 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert 98 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert 99 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert 100 | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert 101 | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert 102 | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert 103 | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert 104 | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert 105 | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert 106 | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert 107 | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert 108 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert 109 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert 110 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert 111 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert 112 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert 113 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert 114 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert 115 | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert 116 | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert 117 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert 118 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert 119 | org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert 120 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert 121 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert 122 | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert 123 | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert 124 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert 125 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert 126 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert 127 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert 128 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert 129 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert 130 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert 131 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert 132 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert 133 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert 134 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert 135 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert 136 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert 137 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert 138 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert 139 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert 140 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert 141 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert 142 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert 143 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert 144 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert 145 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert 146 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert 147 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert 148 | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert 149 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert 150 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert 151 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert 152 | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert 153 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert 154 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert 155 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert 156 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert 157 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert 158 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert 159 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert 160 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert 161 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert 162 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert 163 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert 164 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert 165 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert 166 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert 167 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert 168 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert 169 | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert 170 | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert 171 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert 172 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert 173 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert 174 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert 175 | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert 176 | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert 177 | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert 178 | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert 179 | org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert 180 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert 181 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert 182 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert 183 | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert 184 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert 185 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert 186 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert 187 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert 188 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert 189 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert 190 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert 191 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert 192 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert 193 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert 194 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert 195 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert 196 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert 197 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert 198 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert 199 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert 200 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert 201 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert 202 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert 203 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert 204 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert 205 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert 206 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert 207 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert 208 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert 209 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert 210 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert 211 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert 212 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert 213 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert 214 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert 215 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert 216 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert 217 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert 218 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert 219 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert 220 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert 221 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert 222 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert 223 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert 224 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert 225 | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert 226 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert 227 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert 228 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert 229 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert 230 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert 231 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert 232 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert 233 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert 234 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert 235 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert 236 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert 237 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert 238 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert 239 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert 240 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert 241 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert 242 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert 243 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert 244 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert 245 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert 246 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert 247 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert 248 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert 249 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert 250 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert 251 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert 252 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert 253 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert 254 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert 255 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert 256 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert 257 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert 258 | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert 259 | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert 260 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert 261 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert 262 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert 263 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert 264 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert 265 | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert 266 | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert 267 | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert 268 | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert 269 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert 270 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert 271 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert 272 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert 273 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert 274 | org.eclipse.jdt.core.formatter.join_lines_in_comments=true 275 | org.eclipse.jdt.core.formatter.join_wrapped_lines=true 276 | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false 277 | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false 278 | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false 279 | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false 280 | org.eclipse.jdt.core.formatter.lineSplit=119 281 | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false 282 | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 283 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 284 | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 285 | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true 286 | org.eclipse.jdt.core.formatter.tabulation.char=tab 287 | org.eclipse.jdt.core.formatter.tabulation.size=4 288 | org.eclipse.jdt.core.formatter.use_on_off_tags=false 289 | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false 290 | org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true 291 | org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true 292 | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true 293 | -------------------------------------------------------------------------------- /src/main/resources/songbirdDbToolsFormatter.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | --------------------------------------------------------------------------------