youtube_data_api 0.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +52 -19
- data/lib/youtube_data_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283309d21399dba484cc7e58c7f1b19b55d80550
|
4
|
+
data.tar.gz: 1ebb949d8ad19841183eb8ca9efc6f799610cc8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e485afcd3b0d7177dc64a18e20364753c96802420aae27df3ada56a9f0c809b5c55a4eabfdd1c9c9c65c65d51e1dd45c65f751bec90c2e2f1f83f44a55def6bb
|
7
|
+
data.tar.gz: 3a44a1327562ef662af658f3500367c84acb11dbea695ab7fb7f1b75df279d2b668a5952cc9c243c0b7d505faa3a4f13f7869c735c5ae7e77ae989efb265b3a1
|
data/README.md
CHANGED
@@ -8,56 +8,89 @@ A ruby library interface to the [YouTube Data API](https://developers.google.com
|
|
8
8
|
gem install youtube_data_api
|
9
9
|
````
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
If using bundler:
|
12
|
+
add `gem youtube_data_api, '~> 3.0'` to the Gemfile,
|
13
|
+
then run `bundle install`.
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
|
17
|
+
### API Requests
|
18
|
+
|
19
|
+
#### Get Channel
|
18
20
|
|
19
21
|
```` rb
|
22
|
+
channel_url = "https://www.youtube.com/user/CSPAN"
|
23
|
+
YoutubeDataApi.channel(channel_url)
|
24
|
+
````
|
20
25
|
|
21
|
-
|
26
|
+
#### List Playlists for a given Channel
|
22
27
|
|
28
|
+
```` rb
|
23
29
|
channel_url = "https://www.youtube.com/user/CSPAN"
|
24
|
-
YoutubeDataApi.channel(channel_url)
|
25
30
|
YoutubeDataApi.channel_playlists(channel_url)
|
31
|
+
````
|
32
|
+
|
33
|
+
#### Get Playlist
|
26
34
|
|
27
|
-
|
35
|
+
```` rb
|
28
36
|
|
29
37
|
playlist_url = "https://www.youtube.com/playlist?list=PLf0o4wbW8SXqTSo6iJkolKCKJYBnpo9NZ"
|
30
38
|
YoutubeDataApi.playlist(playlist_url)
|
39
|
+
````
|
40
|
+
|
41
|
+
#### List Playlist Items (Videos)
|
42
|
+
|
43
|
+
```` rb
|
44
|
+
playlist_url = "https://www.youtube.com/playlist?list=PLf0o4wbW8SXqTSo6iJkolKCKJYBnpo9NZ"
|
31
45
|
YoutubeDataApi.playlist_items(playlist_url)
|
46
|
+
````
|
32
47
|
|
33
|
-
|
48
|
+
#### Get Video
|
34
49
|
|
50
|
+
```` rb
|
35
51
|
video_url = "https://www.youtube.com/watch?v=oBM7DIeMsP0"
|
36
52
|
YoutubeDataApi.video(video_url)
|
37
53
|
````
|
38
54
|
|
39
|
-
###
|
55
|
+
### Pagination
|
56
|
+
|
57
|
+
You may need to paginate through responses.
|
58
|
+
|
59
|
+
```` rb
|
60
|
+
channel_url = "https://www.youtube.com/user/CSPAN"
|
61
|
+
response = YoutubeDataApi.channel_playlists(channel_url)
|
62
|
+
while response do
|
63
|
+
puts response["pageInfo"]
|
64
|
+
|
65
|
+
if response["nextPageToken"]
|
66
|
+
request_params = {:page_token => response["nextPageToken"]}
|
67
|
+
response = YoutubeDataApi.channel_playlists(channel_url, request_params)
|
68
|
+
else
|
69
|
+
response = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
````
|
73
|
+
|
74
|
+
## Prerequisites
|
40
75
|
|
41
|
-
|
76
|
+
### YouTube-API-enabled Application
|
42
77
|
|
43
78
|
Create a new application in the [google developer console](https://console.developers.google.com), and note its name. Navigate to the **APIs & Auth > APIs** menu and enable the *YouTube Data API v3* by searching for it. Refer to the
|
44
79
|
[YouTube API Application Registration Guide](https://developers.google.com/youtube/registering_an_application)
|
45
80
|
for more support.
|
46
81
|
|
47
|
-
|
82
|
+
### Youtube API Key
|
48
83
|
|
49
84
|
Navigate to the **APIs & Auth > Credentials** menu and add credentials for an API Key, specifically, a **Server Key**. Note the value of your API Key. Refer to the [YouTube API Key Generation Guide](https://developers.google.com/youtube/registering_an_application#Create_API_Keys)
|
50
85
|
for more support.
|
51
86
|
|
52
|
-
|
87
|
+
## Configuration
|
53
88
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
assigning it to an environment variable or
|
58
|
-
passing it as a request parameter.
|
89
|
+
Make requests on behalf of your YouTube API-enabled Application
|
90
|
+
by using an environment variable approach or
|
91
|
+
a request parameter approach to specifying your API Key.
|
59
92
|
|
60
|
-
|
93
|
+
### Environment Variable
|
61
94
|
|
62
95
|
If using the environment variable configuration approach,
|
63
96
|
add a variable called `YOUTUBE_DATA_API_KEY` to your **.bash_profile**:
|
@@ -66,7 +99,7 @@ If using the environment variable configuration approach,
|
|
66
99
|
export YOUTUBE_DATA_API_KEY="my-key-123"
|
67
100
|
````
|
68
101
|
|
69
|
-
|
102
|
+
### Request Parameter
|
70
103
|
|
71
104
|
If using the request parameter configuration approach, pass the `:api_key` parameter to any request:
|
72
105
|
|