Created
September 18, 2016 21:35
-
-
Save vilaca/c2a9673c953063c30753691ca53e9f92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.vilaca.youtube; | |
import java.io.IOException; | |
import com.google.api.client.http.HttpRequest; | |
import com.google.api.client.http.HttpRequestInitializer; | |
import com.google.api.client.http.javanet.NetHttpTransport; | |
import com.google.api.client.json.jackson2.JacksonFactory; | |
import com.google.api.services.youtube.YouTube; | |
import com.google.api.services.youtube.YouTube.Channels.List; | |
import com.google.api.services.youtube.model.Channel; | |
public class GetUploadedPlaylist { | |
private static final String APP_NAME = "GetUploadedPlaylist"; | |
public static void main(String[] args) throws IOException { | |
System.out.println("Usage: GetUploadedPlaylist [API-KEY] [USER-ID]"); | |
if ( args.length < 2) return; | |
final YouTube youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), | |
new HttpRequestInitializer() { | |
@Override | |
public void initialize(HttpRequest request) throws IOException { | |
} | |
}).setApplicationName(APP_NAME).build(); | |
final List search = youtube.channels().list("contentDetails"); | |
search.setKey(args[0]); | |
search.setId(args[1]); | |
search.setFields("items/contentDetails/relatedPlaylists/uploads"); | |
final java.util.List<Channel> resp = search.execute().getItems(); | |
if ( resp == null) | |
{ | |
System.out.println(" No results!"); | |
return; | |
} | |
final Channel channel = resp.get(0); | |
System.out.println("Result: " + channel.getContentDetails().getRelatedPlaylists().getUploads()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment