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

net.beardbot.subsonic.client.api.lists.ListsService Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2020 Joscha Düringer
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package net.beardbot.subsonic.client.api.lists;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.beardbot.subsonic.client.Subsonic;
import net.beardbot.subsonic.client.base.SubsonicClient;
import org.subsonic.restapi.*;

import java.util.List;

import static net.beardbot.subsonic.client.utils.SubsonicResponseErrorHandler.handleError;

@Slf4j
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public class ListsService {
    private final ListsClient listsClient;

    public ListsService(Subsonic subsonic) {
        this.listsClient = SubsonicClient.create(subsonic, ListsClient.class);
    }

    public List getNowPlaying(){
        log.debug("Fetching now playing.");

        var response = listsClient.getNowPlaying();
        handleError(response);

        return response.getNowPlaying().getEntries();
    }

    public Starred getStarred(){
        log.debug("Fetching starred.");

        var response = listsClient.getStarred();
        handleError(response);

        return response.getStarred();
    }

    public Starred2 getStarred2(){
        log.debug("Fetching starred2.");

        var response = listsClient.getStarred2();
        handleError(response);

        return response.getStarred2();
    }

    public AlbumList getAlbumList(){
        return getAlbumList(AlbumListParams.create());
    }

    public AlbumList getAlbumList(AlbumListParams albumListParams){
        log.debug("Fetching album list with params {}", albumListParams.getParamMapForLogging());

        var response = listsClient.getAlbumList(albumListParams.getParamMap());
        handleError(response);

        return response.getAlbumList();
    }

    public AlbumList2 getAlbumList2(){
        return getAlbumList2(AlbumListParams.create());
    }

    public AlbumList2 getAlbumList2(AlbumListParams albumListParams){
        log.debug("Fetching album list with params {}", albumListParams.getParamMapForLogging());

        var response = listsClient.getAlbumList2(albumListParams.getParamMap());
        handleError(response);

        return response.getAlbumList2();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy