From 1b3ef4d27da8dfdb00f1d57dcf606762576bfdc2 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 7 Dec 2018 23:50:04 +0100 Subject: [PATCH] Getting vid descriptions --- .idea/vcs.xml | 6 ++++++ src/main/java/Main.java | 32 ++++++++------------------------ 2 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 40fda58..dff92b7 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -9,13 +9,13 @@ import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.client.util.store.FileDataStoreFactory; import com.google.api.services.youtube.YouTube; -import com.google.api.services.youtube.model.VideoListResponse; +import com.google.api.services.youtube.model.PlaylistItem; +import com.google.api.services.youtube.model.PlaylistItemListResponse; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import java.util.HashMap; public class Main { @@ -87,29 +87,13 @@ public class Main { YouTube youtube = getYouTubeService(); try { - HashMap parameters = new HashMap<>(); - parameters.put("part", "snippet,contentDetails,statistics"); - parameters.put("chart", "mostPopular"); - parameters.put("regionCode", "US"); - parameters.put("videoCategoryId", ""); - - YouTube.Videos.List videosListMostPopularRequest = youtube.videos().list(parameters.get("part").toString()); - if (parameters.containsKey("chart") && parameters.get("chart") != "") { - videosListMostPopularRequest.setChart(parameters.get("chart").toString()); + /*System.out.println(youtube.playlists().list("snippet")//.setChannelId("UCR-ENZ64WL1vB8KU4YzdmTQ") + .setId("PLru1HAOKPcjJQr4lsCh2eU9F2lhSX23F_").execute().getItems().get(0).);*/ + //System.out.println(youtube.playlistItems().list("snippet").setPlaylistId("PLru1HAOKPcjJQr4lsCh2eU9F2lhSX23F_").execute()); + PlaylistItemListResponse vids = youtube.playlistItems().list("snippet").setPlaylistId("PLru1HAOKPcjJQr4lsCh2eU9F2lhSX23F_").execute(); + for (PlaylistItem item : vids.getItems()) { + System.out.println(item.getSnippet().getDescription()); } - - if (parameters.containsKey("regionCode") && parameters.get("regionCode") != "") { - videosListMostPopularRequest.setRegionCode(parameters.get("regionCode").toString()); - } - - if (parameters.containsKey("videoCategoryId") && parameters.get("videoCategoryId") != "") { - videosListMostPopularRequest.setVideoCategoryId(parameters.get("videoCategoryId").toString()); - } - - VideoListResponse response = videosListMostPopularRequest.execute(); - System.out.println(response); - - } catch (GoogleJsonResponseException e) { e.printStackTrace(); System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage());