youtuberb 0.2.0 → 0.2.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 +4 -4
- data/Gemfile.lock +12 -8
- data/README.md +17 -0
- data/lib/you_tube/client.rb +4 -0
- data/lib/you_tube/collection.rb +12 -1
- data/lib/you_tube/objects/live_broadcast.rb +30 -0
- data/lib/you_tube/objects/video.rb +1 -0
- data/lib/you_tube/resources/channels.rb +9 -3
- data/lib/you_tube/resources/live_broadcasts.rb +26 -0
- data/lib/you_tube/version.rb +1 -1
- data/lib/you_tube.rb +2 -0
- metadata +5 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9fe8e6ecebef2bdb2227e76efedbb1ede0c3e18d2a7d0715ffd0830d16a0345a
|
|
4
|
+
data.tar.gz: 3a23f5aa3d670946d2f8fdec60ca0a3c93b38d4cc1056986a68d5e65e81c9aaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdbc338427501a21cf5536c9a566fc2d0491900eb1bd02f0c35b829ce800d275c767f19119d5311e2121584466b3927faab88cf1b4a0564ffd99470d3fdbd92d
|
|
7
|
+
data.tar.gz: 49cbe76dcc1eca7ef654e6a916650f99d98e8fc62666f26d26029d52e8d7debe6226b11087023e5a32c3fb899d37bd333ea12cbee7c0e4259bd3644f7db3b768
|
data/Gemfile.lock
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
youtuberb (0.2.
|
|
4
|
+
youtuberb (0.2.2)
|
|
5
5
|
faraday (~> 2.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
base64 (0.1.1)
|
|
11
10
|
dotenv (2.7.6)
|
|
12
|
-
faraday (2.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
faraday-net_http (3.
|
|
11
|
+
faraday (2.14.0)
|
|
12
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
13
|
+
json
|
|
14
|
+
logger
|
|
15
|
+
faraday-net_http (3.4.2)
|
|
16
|
+
net-http (~> 0.5)
|
|
17
|
+
json (2.16.0)
|
|
18
|
+
logger (1.7.0)
|
|
17
19
|
minitest (5.20.0)
|
|
20
|
+
net-http (0.8.0)
|
|
21
|
+
uri (>= 0.11.1)
|
|
18
22
|
rake (13.0.6)
|
|
19
|
-
|
|
23
|
+
uri (1.1.1)
|
|
20
24
|
|
|
21
25
|
PLATFORMS
|
|
22
26
|
x86_64-linux
|
data/README.md
CHANGED
|
@@ -38,6 +38,13 @@ An Access Token will be an OAuth2 token generated after authentication.
|
|
|
38
38
|
|
|
39
39
|
# Get a Channel by username
|
|
40
40
|
@client.channels.retrieve(username: "username")
|
|
41
|
+
|
|
42
|
+
# Get a Channel by it's handle
|
|
43
|
+
@client.channels.retrieve(handle: "@username")
|
|
44
|
+
|
|
45
|
+
# Retrieve a list of videos for a Channel
|
|
46
|
+
# Returns a collection of SearchResult's because YouTube don't have a direct API to view all videos on a Channel
|
|
47
|
+
@client.channels.videos(id: "channel_id")
|
|
41
48
|
```
|
|
42
49
|
|
|
43
50
|
### Videos
|
|
@@ -122,6 +129,16 @@ For a full list of parameters, see the [YouTube API Docs](https://developers.goo
|
|
|
122
129
|
@client.search.list(channelId: "channel", type: "video", order: "date")
|
|
123
130
|
```
|
|
124
131
|
|
|
132
|
+
### Live Broadcasts
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
# Live Broadcasts for the currently authenticated user
|
|
136
|
+
@client.live_broadcasts.list
|
|
137
|
+
|
|
138
|
+
# Live Broadcasts by status
|
|
139
|
+
@client.live_broadcasts.list status: "active"
|
|
140
|
+
```
|
|
141
|
+
|
|
125
142
|
## Contributing
|
|
126
143
|
|
|
127
144
|
Bug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/youtuberb.
|
data/lib/you_tube/client.rb
CHANGED
data/lib/you_tube/collection.rb
CHANGED
|
@@ -10,7 +10,6 @@ module YouTube
|
|
|
10
10
|
total: body["items"].count,
|
|
11
11
|
next_page_token: body["nextPageToken"],
|
|
12
12
|
prev_page_token: body["prevPageToken"],
|
|
13
|
-
# cursor: body.dig("pagination", "cursor")
|
|
14
13
|
)
|
|
15
14
|
end
|
|
16
15
|
|
|
@@ -20,5 +19,17 @@ module YouTube
|
|
|
20
19
|
@next_page_token = next_page_token
|
|
21
20
|
@prev_page_token = prev_page_token
|
|
22
21
|
end
|
|
22
|
+
|
|
23
|
+
def each(&block)
|
|
24
|
+
data.each(&block)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def first
|
|
28
|
+
data.first
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def last
|
|
32
|
+
data.last
|
|
33
|
+
end
|
|
23
34
|
end
|
|
24
35
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module YouTube
|
|
2
|
+
class LiveBroadcast < 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
|
+
self.channel_id = options["snippet"]["channelId"]
|
|
12
|
+
|
|
13
|
+
if options["snippet"]["thumbnails"]
|
|
14
|
+
thumb = options["snippet"]["thumbnails"]
|
|
15
|
+
self.thumbnail_default = thumb["default"]["url"] if thumb["default"]
|
|
16
|
+
self.thumbnail_medium = thumb["medium"]["url"] if thumb["medium"]
|
|
17
|
+
self.thumbnail_high = thumb["high"]["url"] if thumb["high"]
|
|
18
|
+
self.thumbnail_standard = thumb["standard"]["url"] if thumb["standard"]
|
|
19
|
+
self.thumbnail_maxres = thumb["maxres"]["url"] if thumb["maxres"]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
if options["status"]
|
|
24
|
+
self.upload_status = options["status"]["uploadStatus"]
|
|
25
|
+
self.privacy_status = options["status"]["privacyStatus"]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -23,6 +23,7 @@ module YouTube
|
|
|
23
23
|
# Is a Video is blocked in any countries?
|
|
24
24
|
if options["contentDetails"]
|
|
25
25
|
self.blocked = !options["contentDetails"]["regionRestriction"].nil?
|
|
26
|
+
self.age_restricted = !options["contentDetails"]["contentRating"].nil? && options["contentDetails"]["contentRating"]["ytRating"] == "ytAgeRestricted"
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
if options["liveStreamingDetails"]
|
|
@@ -10,17 +10,23 @@ module YouTube
|
|
|
10
10
|
Channel.new(response.body["items"][0])
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# Retrieve a Channel by its ID or
|
|
14
|
-
def retrieve(id: nil, username: nil)
|
|
13
|
+
# Retrieve a Channel by its ID, Username or Handle (@username)
|
|
14
|
+
def retrieve(id: nil, username: nil, handle: nil)
|
|
15
15
|
attrs = {}
|
|
16
16
|
attrs[:id] = id if id
|
|
17
17
|
attrs[:forUsername] = username if username
|
|
18
|
-
|
|
18
|
+
attrs[:forHandle] = handle if handle
|
|
19
|
+
raise ArgumentError, "Must provide either an ID, Username or Handle" if attrs.empty?
|
|
19
20
|
|
|
20
21
|
response = get_request "channels", params: attrs.merge({part: PARTS})
|
|
21
22
|
return nil if response.body["pageInfo"]["totalResults"] == 0
|
|
22
23
|
Channel.new(response.body["items"][0])
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
def videos(id:, **options)
|
|
27
|
+
response = get_request "search", params: {channelId: id, part: "id,snippet"}.merge(options)
|
|
28
|
+
Collection.from_response(response, type: SearchResult)
|
|
29
|
+
end
|
|
30
|
+
|
|
25
31
|
end
|
|
26
32
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module YouTube
|
|
2
|
+
class LiveBroadcastsResource < Resource
|
|
3
|
+
|
|
4
|
+
PARTS = "id,snippet,contentDetails,status"
|
|
5
|
+
|
|
6
|
+
# Retrieves Live Broadcasts by ID or for the currently authenticated user
|
|
7
|
+
def list(status: nil)
|
|
8
|
+
if status
|
|
9
|
+
response = get_request("liveBroadcasts", params: {broadcastStatus: status, part: PARTS})
|
|
10
|
+
else
|
|
11
|
+
response = get_request("liveBroadcasts", params: {mine: true, part: PARTS})
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Collection.from_response(response, type: LiveBroadcast)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Retrieves a Video by the ID. This retrieves extra information so will only work
|
|
18
|
+
# on videos for an authenticated user
|
|
19
|
+
def retrieve(id:)
|
|
20
|
+
response = get_request "liveBroadcasts", params: {id: id, part: PARTS}
|
|
21
|
+
return nil if response.body["items"].count == 0
|
|
22
|
+
LiveBroadcast.new(response.body["items"][0])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
end
|
data/lib/you_tube/version.rb
CHANGED
data/lib/you_tube.rb
CHANGED
|
@@ -16,11 +16,13 @@ module YouTube
|
|
|
16
16
|
autoload :PlaylistsResource, "you_tube/resources/playlists"
|
|
17
17
|
autoload :PlaylistItemsResource, "you_tube/resources/playlist_items"
|
|
18
18
|
autoload :SearchResource, "you_tube/resources/search"
|
|
19
|
+
autoload :LiveBroadcastsResource, "you_tube/resources/live_broadcasts"
|
|
19
20
|
|
|
20
21
|
autoload :Channel, "you_tube/objects/channel"
|
|
21
22
|
autoload :Video, "you_tube/objects/video"
|
|
22
23
|
autoload :Playlist, "you_tube/objects/playlist"
|
|
23
24
|
autoload :PlaylistItem, "you_tube/objects/playlist_item"
|
|
24
25
|
autoload :SearchResult, "you_tube/objects/search_result"
|
|
26
|
+
autoload :LiveBroadcast, "you_tube/objects/live_broadcast"
|
|
25
27
|
|
|
26
28
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: youtuberb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dean Perry
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: faraday
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '2.0'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- dean@deanpcmad.com
|
|
30
28
|
executables: []
|
|
@@ -45,12 +43,14 @@ files:
|
|
|
45
43
|
- lib/you_tube/error.rb
|
|
46
44
|
- lib/you_tube/object.rb
|
|
47
45
|
- lib/you_tube/objects/channel.rb
|
|
46
|
+
- lib/you_tube/objects/live_broadcast.rb
|
|
48
47
|
- lib/you_tube/objects/playlist.rb
|
|
49
48
|
- lib/you_tube/objects/playlist_item.rb
|
|
50
49
|
- lib/you_tube/objects/search_result.rb
|
|
51
50
|
- lib/you_tube/objects/video.rb
|
|
52
51
|
- lib/you_tube/resource.rb
|
|
53
52
|
- lib/you_tube/resources/channels.rb
|
|
53
|
+
- lib/you_tube/resources/live_broadcasts.rb
|
|
54
54
|
- lib/you_tube/resources/playlist_items.rb
|
|
55
55
|
- lib/you_tube/resources/playlists.rb
|
|
56
56
|
- lib/you_tube/resources/search.rb
|
|
@@ -64,7 +64,6 @@ licenses:
|
|
|
64
64
|
metadata:
|
|
65
65
|
homepage_uri: https://deanpcmad.com
|
|
66
66
|
source_code_uri: https://github.com/deanpcmad/youtuberb
|
|
67
|
-
post_install_message:
|
|
68
67
|
rdoc_options: []
|
|
69
68
|
require_paths:
|
|
70
69
|
- lib
|
|
@@ -79,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
79
78
|
- !ruby/object:Gem::Version
|
|
80
79
|
version: '0'
|
|
81
80
|
requirements: []
|
|
82
|
-
rubygems_version: 3.
|
|
83
|
-
signing_key:
|
|
81
|
+
rubygems_version: 3.6.9
|
|
84
82
|
specification_version: 4
|
|
85
83
|
summary: A Ruby library for interacting with the YouTube API
|
|
86
84
|
test_files: []
|