当前位置: 首页>>代码示例>>Java>>正文


Java PlaylistRequest类代码示例

本文整理汇总了Java中com.wrapper.spotify.methods.PlaylistRequest的典型用法代码示例。如果您正苦于以下问题:Java PlaylistRequest类的具体用法?Java PlaylistRequest怎么用?Java PlaylistRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlaylistRequest类属于com.wrapper.spotify.methods包,在下文中一共展示了PlaylistRequest类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPlaylistById

import com.wrapper.spotify.methods.PlaylistRequest; //导入依赖的package包/类
private static Playlist getPlaylistById(String spotifyId, String playlistId, Api api) {
    final PlaylistRequest request = api.getPlaylist(spotifyId, playlistId).build();

    try {
        return request.get();
    } catch (Exception e) {
        e.printStackTrace();
        throw new WrapperException();
    }
}
 
开发者ID:jiaweizhang,项目名称:spotify-pull-requests,代码行数:11,代码来源:PlaylistService.java

示例2: main

import com.wrapper.spotify.methods.PlaylistRequest; //导入依赖的package包/类
public static void main(String[] args) {
    try {
        while(true) {
            //Get an authenticated client
            spotifyApi = spotifyClient.getSpotifyApi();
            spotifyApi.getPlaylistTracks(userId, playlistId);

            PlaylistRequest request = spotifyApi.getPlaylist(userId, playlistId).build();

            try {
                Playlist playlist = request.get();
                List<ComparablePlaylistTrack> newTracks = getNewPlaylistTracks(playlist);
                for(PlaylistTrack t : newTracks) {
                    postToSlack(playlist, t);
                    redisClient.addNewTrack(t);
                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }

            //Repeat playlist check every minute
            Thread.sleep(60 * 1000);
        }
    } catch (InterruptedException ie) {
        System.out.println("Thread interrupted!!");
    }
}
 
开发者ID:bradfogle,项目名称:slack-spotify-playlist,代码行数:28,代码来源:Main.java

示例3: process

import com.wrapper.spotify.methods.PlaylistRequest; //导入依赖的package包/类
public void process(String url) throws UnsupportedEncodingException {
    
    //Decodeamos y encodeamos los nombres de usuario
    String user = URLEncoder.encode(URLDecoder.decode(getUser(url), "UTF-8"), "UTF-8");
    String idP = getIdPlayList(url);

    System.out.println("Usuario: " + user + " - ID PlayList: " + idP);
    textui.printText("Usuario: " + user + " - ID PlayList: " + idP);

    // Create an API instance. The default instance connects to https://api.spotify.com/.
    api = Api.builder()
            .clientId(clientId)
            .clientSecret(clientSecret)
            .redirectURI("https://www.spotify.com/es/")
            .build();
    final ClientCredentialsGrantRequest request = api.clientCredentialsGrant().build();

    /* Use the request object to make the request, either asynchronously (getAsync) or synchronously (get) */
    final SettableFuture<ClientCredentials> responseFuture = request.getAsync();

    /* Add callbacks to handle success and failure */
    Futures.addCallback(responseFuture, new FutureCallback<ClientCredentials>() {
        @Override
        public void onSuccess(ClientCredentials clientCredentials) {

            /* Set access token on the Api object so that it's used going forward */
            api.setAccessToken(clientCredentials.getAccessToken());
            textui.printText("Procediendo a analizar la playList...");
            //Sacamos el numero de tracks que tiene la playlist
            final PlaylistRequest infoPlayListRequest = api.getPlaylist(user, idP).build();

            try {
                final Playlist playlist = infoPlayListRequest.get();
                numTracks = playlist.getTracks().getTotal();
                System.out.println("Num Tracks PlayList: " + numTracks);
                textui.printText("Num Tracks PlayList: " + numTracks);
                //Sacamos las canciones pasando el offset y el limite
                for (int i = 0; i <= numTracks - 1; i += 30) {
                    cargarCanciones(i, 30, user, idP,textui);
                }
            } catch (Exception e) {
                System.out.println("Something went wrong!" + e.getMessage());
                textui.printText("Something went wrong!" + e.getMessage());
            }
            
     
        }

        @Override
        public void onFailure(Throwable throwable) {
            /* An error occurred while getting the access token. This is probably caused by the client id or
 * client secret is invalid. */
        }
    });

}
 
开发者ID:vmunozre,项目名称:SpotifyDownloader,代码行数:57,代码来源:SpotifyProcessor.java


注:本文中的com.wrapper.spotify.methods.PlaylistRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。