youtuberb 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 621b21bea6af44d5d861d0fd9f6d4394b0cc4f164c87e96ae97b49b284f9187a
4
- data.tar.gz: 0623d21c9c87e88c0968f25e405959994cbdd57c6578c491a471c21afec098e1
3
+ metadata.gz: abca9225386659a452e73a1a188260a389d4b9801ee8bad9cca354f0caf7fe46
4
+ data.tar.gz: 7c83234a7f9b0ce77a81ad8d152e3cae422052bee1145c974260011c4c7dbbc7
5
5
  SHA512:
6
- metadata.gz: 508dc5051850a3378fceb20a15e569a6b58d6eb456271d8cd4247b394e5c241d6015085e36150258775d2b2fb71d75f5c69f77193774f7dd3fcd5a4502450501
7
- data.tar.gz: 04c65890328f1126f5760d91ee984a046c464143936420a61628dbcdd139171db51071496de3413d7cb4b514559536ca19cc345456ad113716eaa5d57e648b3a
6
+ metadata.gz: 151f38d41251545eb90b3aa978b4b0293222ae1f70fd6edc34ffcc16b44200db773eddb9decb89340177c4050bb19c4c69dd3252951a1335946759b72a9ccfaa
7
+ data.tar.gz: 971c715687e1486aab1883055a08ecaa59c9271d223522f11e7b5a7d0902d2d4f2bf1f62329b48d400c2b68b0481211475a984e1bd8002ce47978cb92b49016c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- youtuberb (0.1.1)
4
+ youtuberb (0.1.2)
5
5
  faraday (~> 1.7)
6
6
  faraday_middleware (~> 1.1)
7
7
 
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
- @client.videos.get_by_id(user_id: 141981764)
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.
@@ -13,8 +13,8 @@ module YouTube
13
13
  @stubs = stubs
14
14
  end
15
15
 
16
- def activities
17
- ActivitiesResource.new(self)
16
+ def channels
17
+ ChannelsResource.new(self)
18
18
  end
19
19
 
20
20
  def videos
@@ -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
@@ -1,3 +1,3 @@
1
1
  module YouTube
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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 :ActivitiesResource, "you_tube/resources/activities"
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 :Activity, "you_tube/objects/activity"
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.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/activity.rb
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/activities.rb
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,4 +0,0 @@
1
- module YouTube
2
- class Activity < Object
3
- end
4
- end
@@ -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