Skip to content

Commit f89b275

Browse files
Update and rename README to README.md
Add descriptions of code samples.
1 parent 021f439 commit f89b275

2 files changed

Lines changed: 236 additions & 21 deletions

File tree

java/README

Lines changed: 0 additions & 21 deletions
This file was deleted.

java/README.md

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
Prerequisites for this code sample:
2+
- Java 1.6
3+
- Apache Maven (http://maven.apache.org)
4+
5+
Before running the sample, client_secrets.json must be populated with a
6+
client ID and client secret. You can create an ID/secret pair at:
7+
8+
https://code.google.com/apis/console
9+
10+
To build this code sample from the command line, type:
11+
12+
mvn compile
13+
14+
To run the code sample from the command line, enter the following:
15+
16+
mvn exec:java -Dexec.mainClass="FULL_CLASS_NAME"
17+
18+
For more instructions about how to set up Maven and/or your IDE to run
19+
YouTube API samples, see this video:
20+
21+
http://youtu.be/pb_t5_ShQOM
22+
23+
## Samples in this directory:
24+
25+
### [Authorize a request](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/Auth.java)
26+
27+
Description: This sample demonstrates how to use OAuth 2.0 to authorize an application to access resources on a user's behalf.
28+
29+
### [Add a channel subscription](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/AddSubscription.java)
30+
31+
Method: youtube.subscriptions.insert<br>
32+
Description: This sample calls the API's <code>subscriptions.insert</code> method to add a subscription to a specified
33+
channel.
34+
35+
### [Add a featured video](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/InvideoProgramming.java)
36+
37+
Method: youtube.channels.update<br>
38+
Description: This sample calls the API's <code>channels.update</code> method to set <code>invideoPromotion</code>
39+
properties for the channel.
40+
41+
### [Create and manage YouTube video caption tracks](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/Captions.java)
42+
43+
Method: youtube.captions.insert, youtube.captions.list, youtube.captions.update, youtube.captions.download,
44+
youtube.captions.delete<br>
45+
Description: This sample demonstrates how to use the following API methods to create and manage YouTube video caption
46+
tracks:<br>
47+
<ul>
48+
<li>It calls the <code>captions.insert</code> method with the <code>isDraft</code> parameter set to <code>true</code>
49+
to upload a caption track in draft status.</li>
50+
<li>It calls the <code>captions.list</code> method with the <code>videoId</code> parameter to retrieve video caption
51+
tracks.</li>
52+
<li>It calls the <code>captions.update</code> method with the caption in the request body to update a caption track.</li>
53+
<li>It calls the <code>captions.download</code> method to download the caption track.</li>
54+
<li>It calls the <code>captions.delete</code> method to delete the caption track, using the <code>id</code> parameter to
55+
identify the caption track.</li>
56+
</ul>
57+
58+
### [Post a channel bulletin](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/ChannelBulletin.java)
59+
60+
Method: youtube.activities.insert<br>
61+
Description: This sample calls the API's <code>activities.insert</code> method to post a bulletin to the channel
62+
associated with the request.
63+
64+
### [Set and retrieve localized metadata for a channel](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/ChannelLocalizations.java)
65+
66+
Method: youtube.channels.update, youtube.channels.list<br>
67+
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a
68+
channel:<br>
69+
<ul>
70+
<li>It calls the <code>channels.update</code> method to update the default language of a channel's metadata and to add a
71+
localized version of this metadata in a selected language. Note that to set the default language for a channel resource,
72+
you actually need to update the <code>brandingSettings.channel.defaultLanguage</code> property.</li>
73+
<li>It calls the <code>channels.list</code> method with the <code>hl</code> parameter set to a specific language to
74+
retrieve localized metadata in that language.</li>
75+
<li>It calls the <code>channels.list</code> method and includes <code>localizations</code> in the <code>part</code>
76+
parameter value to retrieve all of the localized metadata for that channel.</li>
77+
</ul>
78+
79+
### [Set and retrieve localized metadata for a channel section](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/ChannelSectionLocalizations.java)
80+
81+
Method: youtube.channelSections.update, youtube.channelSections.list<br>
82+
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a
83+
channel section:<br>
84+
<ul>
85+
<li>It calls the <code>channelSections.update</code> method to update the default language of a channel section's
86+
metadata and to add a localized version of this metadata in a selected language.</li>
87+
<li>It calls the <code>channelSections.list</code> method with the <code>hl</code> parameter set to a specific language
88+
to retrieve localized metadata in that language.</li>
89+
<li>It calls the <code>channelSections.list</code> method and includes <code>localizations</code> in the
90+
<code>part</code> parameter value to retrieve all of the localized metadata for that channel section.</li>
91+
</ul>
92+
93+
### [Create and manage comments](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/CommentHandling.java)
94+
95+
Method: youtube.commentThreads.list, youtube.comments.insert, youtube.comments.list, youtube.comments.update,
96+
youtube.comments.setModerationStatus, youtube.comments.markAsSpam, youtube.comments.delete<br>
97+
Description: This sample demonstrates how to use the following API methods to create and manage comments:<br>
98+
<ul>
99+
<li>It calls the <code>commentThreads.list</code> method with the <code>videoId</code> parameter set to retrieve comments
100+
for a video.</li>
101+
<li>It calls the <code>comments.insert</code> method with the <code>parentId</code> parameter set to reply to an existing
102+
comment.</li>
103+
<li>It calls the <code>comments.list</code> method with the <code>parentId</code> parameter to retrieve the comments in the
104+
thread.</li>
105+
<li>It calls the <code>comments.update</code> method with comment in the request body to update a comment.</li>
106+
<li>It calls the <code>comments.setModerationStatus</code> method to set the moderation status of the comment, the
107+
<code>comments.markAsSpam</code> method to mark the comment as spam, and the <code>comments.delete</code> method to
108+
delete the comment, using the <code>id</code> parameter to identify the comment.</li></ul>
109+
110+
### [Create and manage comment threads](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/CommentThreads.java)
111+
112+
Method: youtube.commentThreads.insert, youtube.commentThreads.list, youtube.commentThreads.update<br>
113+
Description: This sample demonstrates how to use the following API methods to create and manage top-level comments:<br>
114+
<ul>
115+
<li>It calls the <code>commentThreads.insert</code> method once with the <code>channelId</code> parameter to create a
116+
channel comment and once with the <code>videoId</code> parameter to create a video comment.</li>
117+
<li>It calls the <code>commentThreads.list</code> method once with the <code>channelId</code> parameter to retrieve
118+
channel comments and once with the <code>videoId</code> parameter to retrieve video comments.</li>
119+
<li>It calls the <code>commentThreads.update</code> method once to update a video comment and then again to update a
120+
channel comment. In each case, the request body contains the <code>comment</code> resource being updated.</li>
121+
</ul>
122+
123+
### [Search by geolocation](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/GeolocationSearch.java)
124+
125+
Method: youtube.search.list, youtube.videos.list<br>
126+
Description: This sample calls the API's <code>search.list</code> method with <code>q</code>, <code>location</code> and
127+
<code>locationRadius</code> parameters to retrieve search results matching the provided keyword within the radius centered
128+
at a particular location. Using the video ids from the search result, the sample calls the API's <code>videos.list</code>
129+
method to retrieve location details of each video.
130+
131+
### [Retrieve my uploads](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/MyUploads.java)
132+
133+
Method: youtube.playlistItems.list<br>
134+
Description: This sample calls the API's <code>playlistItems.list</code> method to retrieve a list of videos uploaded
135+
to the channel associated with the request. The code also calls the <code>channels.list</code> method with the
136+
<code>mine</code> parameter set to <code>true</code> to retrieve the playlist ID that identifies the channel's uploaded
137+
videos.
138+
139+
### [Set and retrieve localized metadata for a playlist](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/PlaylistLocalizations.java)
140+
141+
Method: youtube.playlists.update, youtube.playlists.list<br>
142+
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata for a
143+
playlist:<br>
144+
<ul>
145+
<li>It calls the <code>playlists.update</code> method to update the default language of a playlist's metadata and to add
146+
a localized version of this metadata in a selected language.</li>
147+
<li>It calls the <code>playlists.list</code> method with the <code>hl</code> parameter set to a specific language to
148+
retrieve localized metadata in that language.</li>
149+
<li>It calls the <code>playlists.list</code> method and includes <code>localizations</code> in the <code>part</code>
150+
parameter value to retrieve all of the localized metadata for that playlist.</li>
151+
</ul>
152+
153+
### [Create a playlist](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/PlaylistUpdates.java)
154+
155+
Method: youtube.playlists.insert<br>
156+
Description: This sample calls the API's <code>playlists.insert</code> method to create a private playlist owned by the
157+
channel authorizing the request.
158+
159+
### [Search by keyword](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/Search.java)
160+
161+
Method: youtube.search.list<br>
162+
Description: This sample calls the API's <code>search.list</code> method to retrieve search results associated with
163+
a particular keyword.
164+
165+
### [Update a video](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/UpdateVideo.java)
166+
167+
Method: youtube.videos.update<br>
168+
Description: This sample calls the API's <code>videos.update</code> method to update a video owned by the channel
169+
authorizing the request.
170+
171+
### [Upload a video thumbnail image](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/UploadThumbnail.java)
172+
173+
Method: youtube.thumbnails.set<br>
174+
Description: This sample calls the API's <code>thumbnails.set</code> method to upload an image and set it as the
175+
thumbnail image for a video. The request must be authorized by the channel that owns the video.
176+
177+
### [Upload a video](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/UploadVideo.java)
178+
179+
Method: youtube.videos.insert<br>
180+
Description: This sample calls the API's <code>videos.insert</code> method to upload a video to the channel associated
181+
with the request.
182+
183+
### [Set and retrieve localized metadata for a video](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/VideoLocalizations.java)
184+
185+
Method: youtube.videos.update, youtube.videos.list<br>
186+
Description: This sample demonstrates how to use the following API methods to set and retrieve localized metadata
187+
for a video:<br>
188+
<ul>
189+
<li>It calls the <code>videos.update</code> method to update the default language of a video's metadata and to add
190+
a localized version of this metadata in a selected language.</li>
191+
<li>It calls the <code>videos.list</code> method with the <code>hl</code> parameter set to a specific language to
192+
retrieve localized metadata in that language.</li>
193+
<li>It calls the <code>videos.list</code> method and includes <code>localizations</code> in the <code>part</code>
194+
parameter value to retrieve all of the localized metadata for that video.</li>
195+
</ul>
196+
197+
### [Retrieve top 10 videos by viewcount](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/analytics/YouTubeAnalyticsReports.java)
198+
199+
Method: youtubeAnalytics.reports.query<br>
200+
Description: This sample calls the API's <code>reports.query</code> method to retrieve YouTube Analytics data.
201+
By default, the report retrieves the top 10 videos based on viewcounts, and it returns several metrics for those
202+
videos, sorting the results in reverse order by viewcount. By setting command line parameters, you can use the
203+
same code to retrieve other reports as well.
204+
205+
### [Create a reporting job](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/reporting/CreateReportingJob.java)
206+
207+
Method: youtubeReporting.reportTypes.list, youtubeReporting.jobs.create<br>
208+
Description: This sample demonstrates how to create a reporting job. It calls the <code>reportTypes.list</code> method
209+
to retrieve a list of available report types. It then calls the <code>jobs.create</code> method to create a new reporting
210+
job.
211+
212+
### [Retrieve reports](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/reporting/RetrieveReports.java)
213+
214+
Method: youtubeReporting.jobs.list, youtubeReporting.reports.list<br>
215+
Description: This sample demonstrates how to retrieve reports created by a specific job. It calls the
216+
<code>jobs.list</code> method to retrieve reporting jobs. It then calls the <code>reports.list</code> method with the
217+
<code>jobId</code> parameter set to a specific job id to retrieve reports created by that job. Finally, the sample
218+
prints out the download URL for each report.
219+
220+
### [Create a broadcast](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/live/CreateBroadcast.java)
221+
222+
Method: youtube.liveBroadcasts.bind,youtube.liveBroadcasts.insert,youtube.liveStreams.insert<br>
223+
Description: This sample calls the API's <code>liveBroadcasts.insert</code> method to create a broadcast.
224+
225+
### [Retrieve a channel's broadcasts](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/live/ListBroadcasts.java)
226+
227+
Method: youtube.liveBroadcasts.list<br>
228+
Description: This sample calls the API's <code>liveBroadcasts.list</code> method to retrieve a list of broadcasts for
229+
the channel associated with the request. By default, the request retrieves all broadcasts for the channel, but you can
230+
also specify a value for the <code>--broadcast-status</code> option to only retrieve broadcasts with a particular status.
231+
232+
### [Retrieve a channel's live video streams](/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/live/ListStreams.java)
233+
234+
Method: youtube.liveStreams.list<br>
235+
Description: This sample calls the API's <code>liveStreams.list</code> method to retrieve a list of video stream settings
236+
that a channel can use to broadcast live events on YouTube.

0 commit comments

Comments
 (0)