youtuberb 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +41 -1
- data/lib/you_tube/client.rb +2 -2
- data/lib/you_tube/objects/channel.rb +29 -0
- data/lib/you_tube/resources/channels.rb +25 -0
- data/lib/you_tube/version.rb +1 -1
- data/lib/you_tube.rb +2 -2
- metadata +3 -3
- data/lib/you_tube/objects/activity.rb +0 -4
- data/lib/you_tube/resources/activities.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abca9225386659a452e73a1a188260a389d4b9801ee8bad9cca354f0caf7fe46
|
4
|
+
data.tar.gz: 7c83234a7f9b0ce77a81ad8d152e3cae422052bee1145c974260011c4c7dbbc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 151f38d41251545eb90b3aa978b4b0293222ae1f70fd6edc34ffcc16b44200db773eddb9decb89340177c4050bb19c4c69dd3252951a1335946759b72a9ccfaa
|
7
|
+
data.tar.gz: 971c715687e1486aab1883055a08ecaa59c9271d223522f11e7b5a7d0902d2d4f2bf1f62329b48d400c2b68b0481211475a984e1bd8002ce47978cb92b49016c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -17,15 +17,39 @@ gem 'youtuberb'
|
|
17
17
|
### Set Client Details
|
18
18
|
|
19
19
|
Firstly you'll need to set an API Key and an Access Token.
|
20
|
+
An Access Token will be an OAuth2 token generated after authentication.
|
20
21
|
|
21
22
|
```ruby
|
22
23
|
@client = YouTube::Client.new(api_key: "", access_token: "")
|
23
24
|
```
|
24
25
|
|
26
|
+
### Channels
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# Get the Channel details of the currently authenticated user
|
30
|
+
@client.channels.mine
|
31
|
+
|
32
|
+
# Get a Channel by ID
|
33
|
+
@client.channels.retrieve(id: "channel_id")
|
34
|
+
|
35
|
+
# Get a Channel by username
|
36
|
+
@client.channels.retrieve(username: "username")
|
37
|
+
```
|
38
|
+
|
25
39
|
### Videos
|
26
40
|
|
27
41
|
```ruby
|
28
|
-
|
42
|
+
# Get a single video
|
43
|
+
@client.videos.list(id: "abc123")
|
44
|
+
|
45
|
+
# Get multiple videos
|
46
|
+
@client.videos.list(id: "abc123,123abc")
|
47
|
+
|
48
|
+
# Liked videos for the currently authenticated user
|
49
|
+
@client.videos.liked
|
50
|
+
|
51
|
+
# Get a video owned by the current user. This retrieves extra information so will only work on videos owned by the current user.
|
52
|
+
@client.videos.retrieve(id: "abc123")
|
29
53
|
```
|
30
54
|
|
31
55
|
### Playlists
|
@@ -45,6 +69,22 @@ Firstly you'll need to set an API Key and an Access Token.
|
|
45
69
|
@client.playlists.update(id: "playlist_id", title: "My Playlist", privacy_status: "public")
|
46
70
|
@client.playlists.delete(id: "playlist_id")
|
47
71
|
```
|
72
|
+
### Playlist Items
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# Playlist Items for a Playlist
|
76
|
+
@client.playlist_items.list(playlist_id: "playlist_id")
|
77
|
+
|
78
|
+
@client.playlist_items.retrieve(id: "playlist_item_id")
|
79
|
+
|
80
|
+
# Add a video to a playlist
|
81
|
+
@client.playlist_items.create(playlist_id: "playlist_id", video_id: "video_id")
|
82
|
+
|
83
|
+
@client.playlist_items.update(id: "playlist_item_id", playlist_id: "playlist_id", video_id: "video_id")
|
84
|
+
|
85
|
+
@client.playlist_items.delete(id: "playlist_id")
|
86
|
+
```
|
87
|
+
|
48
88
|
## Contributing
|
49
89
|
|
50
90
|
Bug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/youtuberb.
|
data/lib/you_tube/client.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module YouTube
|
2
|
+
class Channel < Object
|
3
|
+
|
4
|
+
def initialize(options = {})
|
5
|
+
super options
|
6
|
+
|
7
|
+
if options["snippet"]
|
8
|
+
self.title = options["snippet"]["title"]
|
9
|
+
self.description = options["snippet"]["description"]
|
10
|
+
self.published_at = options["snippet"]["publishedAt"]
|
11
|
+
|
12
|
+
if options["snippet"]["thumbnails"]
|
13
|
+
thumb = options["snippet"]["thumbnails"]
|
14
|
+
self.thumbnail_default = thumb["default"]["url"] if thumb["default"]
|
15
|
+
self.thumbnail_medium = thumb["medium"]["url"] if thumb["medium"]
|
16
|
+
self.thumbnail_high = thumb["high"]["url"] if thumb["high"]
|
17
|
+
self.thumbnail_standard = thumb["standard"]["url"] if thumb["standard"]
|
18
|
+
self.thumbnail_maxres = thumb["maxres"]["url"] if thumb["maxres"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
if options["status"]
|
23
|
+
self.privacy_status = options["status"]["privacyStatus"]
|
24
|
+
self.long_uploads_status = options["status"]["longUploadsStatus"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module YouTube
|
2
|
+
class ChannelsResource < Resource
|
3
|
+
|
4
|
+
PARTS = "id,snippet,status,statistics"
|
5
|
+
|
6
|
+
# Retrieve the channel of the currently authenticated user
|
7
|
+
def mine
|
8
|
+
response = get_request "channels", params: {mine: true, part: PARTS}
|
9
|
+
return nil if response.body["pageInfo"]["totalResults"] == 0
|
10
|
+
Channel.new(response.body["items"][0])
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve a Channel by its ID or Username
|
14
|
+
def retrieve(id: nil, username: nil)
|
15
|
+
attrs = {}
|
16
|
+
attrs[:id] = id if id
|
17
|
+
attrs[:forUsername] = username if username
|
18
|
+
|
19
|
+
response = get_request "channels", params: attrs.merge({part: PARTS})
|
20
|
+
return nil if response.body["pageInfo"]["totalResults"] == 0
|
21
|
+
Channel.new(response.body["items"][0])
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
data/lib/you_tube/version.rb
CHANGED
data/lib/you_tube.rb
CHANGED
@@ -12,12 +12,12 @@ module YouTube
|
|
12
12
|
autoload :Resource, "you_tube/resource"
|
13
13
|
autoload :Object, "you_tube/object"
|
14
14
|
|
15
|
-
autoload :
|
15
|
+
autoload :ChannelsResource, "you_tube/resources/channels"
|
16
16
|
autoload :VideosResource, "you_tube/resources/videos"
|
17
17
|
autoload :PlaylistsResource, "you_tube/resources/playlists"
|
18
18
|
autoload :PlaylistItemsResource, "you_tube/resources/playlist_items"
|
19
19
|
|
20
|
-
autoload :
|
20
|
+
autoload :Channel, "you_tube/objects/channel"
|
21
21
|
autoload :Video, "you_tube/objects/video"
|
22
22
|
autoload :Playlist, "you_tube/objects/playlist"
|
23
23
|
autoload :PlaylistItem, "you_tube/objects/playlist_item"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: youtuberb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
@@ -58,12 +58,12 @@ files:
|
|
58
58
|
- lib/you_tube/collection.rb
|
59
59
|
- lib/you_tube/error.rb
|
60
60
|
- lib/you_tube/object.rb
|
61
|
-
- lib/you_tube/objects/
|
61
|
+
- lib/you_tube/objects/channel.rb
|
62
62
|
- lib/you_tube/objects/playlist.rb
|
63
63
|
- lib/you_tube/objects/playlist_item.rb
|
64
64
|
- lib/you_tube/objects/video.rb
|
65
65
|
- lib/you_tube/resource.rb
|
66
|
-
- lib/you_tube/resources/
|
66
|
+
- lib/you_tube/resources/channels.rb
|
67
67
|
- lib/you_tube/resources/playlist_items.rb
|
68
68
|
- lib/you_tube/resources/playlists.rb
|
69
69
|
- lib/you_tube/resources/videos.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module YouTube
|
2
|
-
class ActivitiesResource < Resource
|
3
|
-
|
4
|
-
def list
|
5
|
-
response = get_request "activities", params: {home: true}
|
6
|
-
# response = post_request("games", body: "fields id,name,status,url,created_at,updated_at;")
|
7
|
-
# Collection.from_response(response, type: Game)
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|