All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xyz.gianlu.librespot.api.Main Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
package xyz.gianlu.librespot.api;

import org.apache.log4j.LogManager;
import xyz.gianlu.librespot.AbsConfiguration;
import xyz.gianlu.librespot.FileConfiguration;
import xyz.gianlu.librespot.core.AuthConfiguration;
import xyz.gianlu.librespot.core.Session;
import xyz.gianlu.librespot.core.ZeroconfServer;
import xyz.gianlu.librespot.mercury.MercuryClient;

import java.io.IOException;
import java.security.GeneralSecurityException;

/**
 * @author Gianlu
 */
public class Main {

    public static void main(String[] args) throws IOException, MercuryClient.MercuryException, GeneralSecurityException, Session.SpotifyAuthenticationException {
        AbsConfiguration conf = new FileConfiguration(args);
        LogManager.getRootLogger().setLevel(conf.loggingLevel());

        SessionWrapper wrapper;
        if (conf.authStrategy() == AuthConfiguration.Strategy.ZEROCONF)
            wrapper = SessionWrapper.fromZeroconf(ZeroconfServer.create(conf));
        else
            wrapper = SessionWrapper.fromSession(new Session.Builder(conf).create());

        ApiServer server = new ApiServer(conf, wrapper);
        Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
        server.start();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy