yt 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +17 -17
- data/lib/yt/associations/has_reports.rb +4 -4
- data/lib/yt/associations/has_viewer_percentages.rb +0 -6
- data/lib/yt/models/asset.rb +7 -5
- data/lib/yt/models/asset_snippet.rb +4 -3
- data/lib/yt/models/claim.rb +10 -8
- data/lib/yt/models/policy_rule.rb +4 -5
- data/lib/yt/models/rating.rb +1 -1
- data/lib/yt/models/reference.rb +11 -13
- data/lib/yt/models/resource.rb +28 -4
- data/lib/yt/models/status.rb +0 -18
- data/lib/yt/models/user_info.rb +1 -1
- data/lib/yt/models/video.rb +52 -13
- data/lib/yt/version.rb +1 -1
- data/spec/models/resource_spec.rb +36 -0
- data/spec/models/status_spec.rb +0 -36
- 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: 9b9767e99d417362ada2195c0d52a9a739a0ead3
|
4
|
+
data.tar.gz: c73d616d817e5c08a67fe6e82bd4192060175c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81cf574551196ee465e708561ad151c1c095d5348c537fadcb6cf7fca6ffe085e0dec832e712263146106f6a43657879171a058eba3fc9fa186dda0015b3580a
|
7
|
+
data.tar.gz: af7747988d6d86dc5cc51b3442c018d344ff6ca12bd8612c462d2fdd778e036e70c2dde22d2f2220add7d8dbf08877ffa7ac04f900375419d2469828a821506c
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,18 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.18.0 - 2015-04-28
|
10
|
+
|
11
|
+
**How to upgrade**
|
12
|
+
|
13
|
+
If your code never calls `public?`, `private?` or `unlisted?` on a Status
|
14
|
+
object, then you are good to go.
|
15
|
+
|
16
|
+
If it does, then call the same methods on the parent Resource object instead.
|
17
|
+
For instance, replace `video.status.private?` with `video.private?`.
|
18
|
+
|
19
|
+
* [ENHANCEMENT] Don’t over-delegate privacy status methods of Resource.
|
20
|
+
|
9
21
|
## 0.17.0 - 2015-04-28
|
10
22
|
|
11
23
|
**How to upgrade**
|
data/README.md
CHANGED
@@ -3,13 +3,13 @@ Yt - a Ruby client for the YouTube API
|
|
3
3
|
|
4
4
|
Yt helps you write apps that need to interact with YouTube.
|
5
5
|
|
6
|
-
The **full documentation** is available at [rubydoc.info](http://rubydoc.info/
|
6
|
+
The **full documentation** is available at [rubydoc.info](http://www.rubydoc.info/gems/yt/frames).
|
7
7
|
|
8
8
|
[![Build Status](http://img.shields.io/travis/Fullscreen/yt/master.svg)](https://travis-ci.org/Fullscreen/yt)
|
9
9
|
[![Coverage Status](http://img.shields.io/coveralls/Fullscreen/yt/master.svg)](https://coveralls.io/r/Fullscreen/yt)
|
10
10
|
[![Dependency Status](http://img.shields.io/gemnasium/Fullscreen/yt.svg)](https://gemnasium.com/Fullscreen/yt)
|
11
11
|
[![Code Climate](http://img.shields.io/codeclimate/github/Fullscreen/yt.svg)](https://codeclimate.com/github/Fullscreen/yt)
|
12
|
-
[![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://rubydoc.info/
|
12
|
+
[![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://www.rubydoc.info/gems/yt/frames)
|
13
13
|
[![Gem Version](http://img.shields.io/gem/v/yt.svg)](http://rubygems.org/gems/yt)
|
14
14
|
|
15
15
|
After [registering your app](#configuring-your-app), you can run commands like:
|
@@ -30,7 +30,7 @@ video.hd? #=> true
|
|
30
30
|
video.annotations.count #=> 1
|
31
31
|
```
|
32
32
|
|
33
|
-
The **full documentation** is available at [rubydoc.info](http://rubydoc.info/
|
33
|
+
The **full documentation** is available at [rubydoc.info](http://www.rubydoc.info/gems/yt/frames).
|
34
34
|
|
35
35
|
How to install
|
36
36
|
==============
|
@@ -41,7 +41,7 @@ To install on your system, run
|
|
41
41
|
|
42
42
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
43
43
|
|
44
|
-
gem 'yt', '~> 0.
|
44
|
+
gem 'yt', '~> 0.18.0'
|
45
45
|
|
46
46
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
47
47
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -54,7 +54,7 @@ Available resources
|
|
54
54
|
Yt::Account
|
55
55
|
-----------
|
56
56
|
|
57
|
-
Use [Yt::Account](http://rubydoc.info/
|
57
|
+
Use [Yt::Account](http://www.rubydoc.info/gems/yt/Yt/Models/Account) to:
|
58
58
|
|
59
59
|
* authenticate as a YouTube account
|
60
60
|
* read the attributes of the account
|
@@ -99,7 +99,7 @@ account.content_owners.first #=> #<Yt::Models::ContentOwner @id=...>
|
|
99
99
|
Yt::ContentOwner
|
100
100
|
----------------
|
101
101
|
|
102
|
-
Use [Yt::ContentOwner](http://rubydoc.info/
|
102
|
+
Use [Yt::ContentOwner](http://www.rubydoc.info/gems/yt/Yt/Models/ContentOwner) to:
|
103
103
|
|
104
104
|
* authenticate as a YouTube content owner
|
105
105
|
* list the channels partnered with a YouTube content owner
|
@@ -140,7 +140,7 @@ content_owner.create_asset type: 'web' #=> #<Yt::Models::Asset @id=...>
|
|
140
140
|
Yt::Channel
|
141
141
|
-----------
|
142
142
|
|
143
|
-
Use [Yt::Channel](http://rubydoc.info/
|
143
|
+
Use [Yt::Channel](http://www.rubydoc.info/gems/yt/Yt/Models/Channel) to:
|
144
144
|
|
145
145
|
* read the attributes of a channel
|
146
146
|
* access the videos of a channel
|
@@ -292,7 +292,7 @@ channel.linked_at #=> Wed, 28 May 2014
|
|
292
292
|
Yt::Video
|
293
293
|
-----------
|
294
294
|
|
295
|
-
Use [Yt::Video](http://rubydoc.info/
|
295
|
+
Use [Yt::Video](http://www.rubydoc.info/gems/yt/Yt/Models/Video) to:
|
296
296
|
|
297
297
|
* read the attributes of a video
|
298
298
|
* update the attributes of a video
|
@@ -472,7 +472,7 @@ video.ad_formats #=> ["standard_instream", "trueview_instream"]
|
|
472
472
|
Yt::Playlist
|
473
473
|
------------
|
474
474
|
|
475
|
-
Use [Yt::Playlist](http://rubydoc.info/
|
475
|
+
Use [Yt::Playlist](http://www.rubydoc.info/gems/yt/Yt/Models/Playlist) to:
|
476
476
|
|
477
477
|
* read the attributes of a playlist
|
478
478
|
* update the attributes of a playlist
|
@@ -526,7 +526,7 @@ playlist.views_per_playlist_start since: 7.days.ago #=> {Wed, 28 May 2014 => 12.
|
|
526
526
|
Yt::PlaylistItem
|
527
527
|
----------------
|
528
528
|
|
529
|
-
Use [Yt::PlaylistItem](http://rubydoc.info/
|
529
|
+
Use [Yt::PlaylistItem](http://www.rubydoc.info/gems/yt/Yt/Models/PlaylistItem) to:
|
530
530
|
|
531
531
|
* read the attributes of a playlist item
|
532
532
|
* update the position of an item inside a playlist
|
@@ -562,7 +562,7 @@ item.delete #=> true
|
|
562
562
|
Yt::Collections::Videos
|
563
563
|
-----------------------
|
564
564
|
|
565
|
-
Use [Yt::Collections::Videos](http://rubydoc.info/
|
565
|
+
Use [Yt::Collections::Videos](http://www.rubydoc.info/gems/yt/Yt/Collections/Videos) to:
|
566
566
|
|
567
567
|
* search for videos
|
568
568
|
|
@@ -580,7 +580,7 @@ videos.where(id: 'MESycYJytkU,invalid').map(&:title) #=> ["Fullscreen Creator Pl
|
|
580
580
|
Yt::Annotation
|
581
581
|
--------------
|
582
582
|
|
583
|
-
Use [Yt::Annotation](http://rubydoc.info/
|
583
|
+
Use [Yt::Annotation](http://www.rubydoc.info/gems/yt/Yt/Models/Annotation) to:
|
584
584
|
|
585
585
|
* read the attributes of an annotation
|
586
586
|
|
@@ -598,7 +598,7 @@ annotation.has_link_to_playlist? #=> true
|
|
598
598
|
Yt::MatchPolicy
|
599
599
|
---------------
|
600
600
|
|
601
|
-
Use [Yt::MatchPolicy](http://rubydoc.info/
|
601
|
+
Use [Yt::MatchPolicy](http://www.rubydoc.info/gems/yt/Yt/Models/MatchPolicy) to:
|
602
602
|
|
603
603
|
* update the policy used by an asset
|
604
604
|
|
@@ -611,7 +611,7 @@ match_policy.update policy_id: 'aBcdEF6g-HJ' #=> true
|
|
611
611
|
Yt::Asset
|
612
612
|
---------
|
613
613
|
|
614
|
-
Use [Yt::Asset](http://rubydoc.info/
|
614
|
+
Use [Yt::Asset](http://www.rubydoc.info/gems/yt/Yt/Models/Asset) to:
|
615
615
|
|
616
616
|
* read the ownership of an asset
|
617
617
|
* update the attributes of an asset
|
@@ -632,7 +632,7 @@ asset.update metadata_mine: {notes: 'Some notes'} #=> true
|
|
632
632
|
Yt::Claim
|
633
633
|
---------
|
634
634
|
|
635
|
-
Use [Yt::Claim](http://rubydoc.info/
|
635
|
+
Use [Yt::Claim](http://www.rubydoc.info/gems/yt/Yt/Models/Claim) to:
|
636
636
|
|
637
637
|
* read the attributes of a claim
|
638
638
|
* view the history of a claim
|
@@ -658,7 +658,7 @@ claim.delete #=> true
|
|
658
658
|
Yt::Ownership
|
659
659
|
-------------
|
660
660
|
|
661
|
-
Use [Yt::Ownership](http://rubydoc.info/
|
661
|
+
Use [Yt::Ownership](http://www.rubydoc.info/gems/yt/Yt/Models/Ownership) to:
|
662
662
|
|
663
663
|
* update the ownership of an asset
|
664
664
|
|
@@ -674,7 +674,7 @@ ownership.update general: [new_general_owner_attrs]
|
|
674
674
|
Yt::AdvertisingOptionsSet
|
675
675
|
-------------------------
|
676
676
|
|
677
|
-
Use [Yt::AdvertisingOptionsSet](http://rubydoc.info/
|
677
|
+
Use [Yt::AdvertisingOptionsSet](http://www.rubydoc.info/gems/yt/Yt/Models/AdvertisingOptionsSet) to:
|
678
678
|
|
679
679
|
* update the advertising settings of a video
|
680
680
|
|
@@ -16,7 +16,7 @@ module Yt
|
|
16
16
|
|
17
17
|
# @!macro [new] daily_report
|
18
18
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
19
|
-
#
|
19
|
+
# Accepted values are: +:day+.
|
20
20
|
# @return [Hash<Date, Float>] if grouped by day, the $1 of the video
|
21
21
|
# for each day in the time-range.
|
22
22
|
# @example Get the video’s $1 for each day of last week:
|
@@ -26,8 +26,8 @@ module Yt
|
|
26
26
|
|
27
27
|
# @!macro [new] views_report
|
28
28
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
29
|
-
#
|
30
|
-
# +:embedded_player_location+, +:related_video+.
|
29
|
+
# Accepted values are: +:day+, +:traffic_source+,
|
30
|
+
# +:playback_location+,+:embedded_player_location+, +:related_video+.
|
31
31
|
# @return [Hash<Date, Float>] if grouped by day, the $1 of the video
|
32
32
|
# for each day in the time-range.
|
33
33
|
# @example Get the video’s $1 for each day of last week:
|
@@ -58,7 +58,7 @@ module Yt
|
|
58
58
|
# @!macro [new] demographics_report
|
59
59
|
# @option options [Symbol] :by (:gender_age_group) The dimension to
|
60
60
|
# show viewer percentage by.
|
61
|
-
#
|
61
|
+
# Accepted values are: +:gender+, +:age_group+, +:gender_age_group+.
|
62
62
|
# @return [Hash<Symbol, Float>] if grouped by gender, the video’s
|
63
63
|
# viewer percentage by gender.
|
64
64
|
# @example Get yesterday’s video’s viewer percentage by gender:
|
@@ -15,12 +15,6 @@ module Yt
|
|
15
15
|
# '25-34', '35-44', '45-54', '55-64', '65-')
|
16
16
|
# @example Return the % of male viewers of a channel older than 64
|
17
17
|
# channel.viewer_percentages[:male]['65-'] #=> 12.02
|
18
|
-
# @!method viewer_percentage(filters = {})
|
19
|
-
# @return [Float] the percentage of viewer matching the filters.
|
20
|
-
# @param [Hash] filters The type of viewers to be accounted for.
|
21
|
-
# @option filters [Symbol] :gender Either :male or :female.
|
22
|
-
# @example Return the % of male viewers of a video
|
23
|
-
# channel.viewer_percentage(gender: :male) #=> 52.02
|
24
18
|
|
25
19
|
# Defines one public instance methods to access the viewer percentages of
|
26
20
|
# a resource for a specific metric.
|
data/lib/yt/models/asset.rb
CHANGED
@@ -53,14 +53,15 @@ module Yt
|
|
53
53
|
# identify the asset.
|
54
54
|
has_attribute :id
|
55
55
|
|
56
|
+
# Returns the asset’s type.
|
56
57
|
# @return [String] the asset’s type. This value determines the metadata
|
57
58
|
# fields that you can set for the asset. In addition, certain API
|
58
59
|
# functions may only be supported for specific types of assets. For
|
59
60
|
# example, composition assets may have more complex ownership data than
|
60
61
|
# other types of assets.
|
61
|
-
#
|
62
|
-
# episode
|
63
|
-
# video_game
|
62
|
+
# Possible values are: +'art_track_video'+, +'composition'+,
|
63
|
+
# +'episode'+, +'general'+, +'movie'+, +'music_video'+, +'season'+,
|
64
|
+
# +'show'+, +'sound_recording'+, +'video_game'+, +'web'+.
|
64
65
|
has_attribute :type
|
65
66
|
|
66
67
|
# @return [Array<Yt::Models::Tag>] the list of asset labels associated
|
@@ -73,8 +74,9 @@ module Yt
|
|
73
74
|
|
74
75
|
STATUSES = %q(active inactive pending)
|
75
76
|
|
76
|
-
#
|
77
|
-
#
|
77
|
+
# Returns the asset’s status.
|
78
|
+
# @return [String] the asset’s status. Possible values are: +'active'+,
|
79
|
+
# +'inactive'+, +'pending'+.
|
78
80
|
# @note Despite what the documentation says, YouTube API never returns
|
79
81
|
# the status of an asset, so it’s impossible to update, although the
|
80
82
|
# documentation says this should be the case. If YouTube ever fixes
|
@@ -16,14 +16,15 @@ module Yt
|
|
16
16
|
# identify the asset.
|
17
17
|
has_attribute :id
|
18
18
|
|
19
|
+
# Returns the asset’s type.
|
19
20
|
# @return [String] the asset’s type. This value determines the metadata
|
20
21
|
# fields that you can set for the asset. In addition, certain API
|
21
22
|
# functions may only be supported for specific types of assets. For
|
22
23
|
# example, composition assets may have more complex ownership data than
|
23
24
|
# other types of assets.
|
24
|
-
#
|
25
|
-
# episode
|
26
|
-
# video_game
|
25
|
+
# Possible values are: +'art_track_video'+, +'composition'+,
|
26
|
+
# +'episode'+, +'general'+, +'movie'+, +'music_video'+, +'season'+,
|
27
|
+
# +'show'+, +'sound_recording'+, +'video_game'+, +'web'+.
|
27
28
|
has_attribute :type
|
28
29
|
|
29
30
|
# @return [String] the title of this asset.
|
data/lib/yt/models/claim.rb
CHANGED
@@ -45,8 +45,10 @@ module Yt
|
|
45
45
|
STATUSES = %q(active appealed disputed inactive pending potential
|
46
46
|
takedown unknown)
|
47
47
|
|
48
|
-
#
|
49
|
-
#
|
48
|
+
# Returns the claim’s status.
|
49
|
+
# @return [String] the claim’s status. Possible values are: +'active'+,
|
50
|
+
# +'appealed'+, +'disputed'+, +'inactive'+, +'pending'+, +'potential'+,
|
51
|
+
# +'takedown'+, +'unknown'+.
|
50
52
|
# @note When updating a claim, you can update its status from active to
|
51
53
|
# inactive to effectively release the claim, but the API does not
|
52
54
|
# support other updates to a claim’s status.
|
@@ -96,22 +98,22 @@ module Yt
|
|
96
98
|
|
97
99
|
CONTENT_TYPES = %q(audio video audiovisual)
|
98
100
|
|
99
|
-
#
|
100
|
-
#
|
101
|
-
# audiovisual
|
101
|
+
# Returns the audiovisual portion of the claimed content.
|
102
|
+
# @return [String] the audiovisual portion of the claimed content.
|
103
|
+
# Possible values are: +'audio'+, +'audiovisual'+, +'video'+.
|
102
104
|
has_attribute :content_type
|
103
105
|
|
104
|
-
# @return [Boolean] whether the covers the audio
|
106
|
+
# @return [Boolean] whether the claim covers only the audio.
|
105
107
|
def audio?
|
106
108
|
content_type == 'audio'
|
107
109
|
end
|
108
110
|
|
109
|
-
# @return [Boolean] whether the covers the video
|
111
|
+
# @return [Boolean] whether the claim covers only the video.
|
110
112
|
def video?
|
111
113
|
content_type == 'video'
|
112
114
|
end
|
113
115
|
|
114
|
-
# @return [Boolean] whether the covers
|
116
|
+
# @return [Boolean] whether the claim covers both audio and video.
|
115
117
|
def audiovisual?
|
116
118
|
content_type == 'audiovisual'
|
117
119
|
end
|
@@ -15,14 +15,13 @@ module Yt
|
|
15
15
|
|
16
16
|
# Return the policy that YouTube should enforce if the rule’s conditions
|
17
17
|
# are all valid for an asset or for an attempt to view that asset on
|
18
|
-
# YouTube.
|
19
|
-
# track
|
18
|
+
# YouTube. Possible values are: +'block'+, +'monetize'+, +'takedown'+,
|
19
|
+
# +'track'+.
|
20
20
|
# @return [String] the policy that YouTube should enforce.
|
21
21
|
has_attribute :action
|
22
22
|
|
23
|
-
# @return [Array] A list of additional actions that YouTube should take
|
24
|
-
#
|
25
|
-
# are: review.
|
23
|
+
# @return [Array] A list of additional actions that YouTube should take if
|
24
|
+
# the conditions in the rule are met. Possible values are: +'review'+.
|
26
25
|
has_attribute :subaction
|
27
26
|
|
28
27
|
# Return the list of territories where the policy applies.
|
data/lib/yt/models/rating.rb
CHANGED
@@ -7,7 +7,7 @@ module Yt
|
|
7
7
|
# @see https://developers.google.com/youtube/v3/docs/videos/getRating
|
8
8
|
class Rating < Base
|
9
9
|
# @return [Symbol, nil] the rating of a video (if present).
|
10
|
-
#
|
10
|
+
# Possible values are: +:dislike+, +:like+, +:none+, +:unspecified+.
|
11
11
|
attr_reader :rating
|
12
12
|
|
13
13
|
def initialize(options = {})
|
data/lib/yt/models/reference.rb
CHANGED
@@ -85,11 +85,12 @@ module Yt
|
|
85
85
|
duplicate_on_hold inactive live_streaming_processing
|
86
86
|
urgent_reference_processing)
|
87
87
|
|
88
|
-
# @return [String] the reference’s status.
|
89
|
-
# active
|
90
|
-
#
|
88
|
+
# @return [String] the reference’s status. Possible values are:
|
89
|
+
# +'activating'+, +'active'+, +'checking'+, +'computing_fingerprint'+,
|
90
|
+
# +'deleted'+, +'duplicate_on_hold'+, +'inactive'+,
|
91
|
+
# +'live_streaming_processing'+, +'urgent_reference_processing'+.
|
91
92
|
has_attribute :status
|
92
|
-
|
93
|
+
|
93
94
|
# @return [Boolean] whether the reference is pending.
|
94
95
|
def activating?
|
95
96
|
status == 'activating'
|
@@ -142,25 +143,22 @@ module Yt
|
|
142
143
|
|
143
144
|
CONTENT_TYPES = %q(audio video audiovisual)
|
144
145
|
|
145
|
-
#
|
146
|
-
#
|
147
|
-
# audiovisual
|
146
|
+
# Returns the audiovisual portion of the referenced content.
|
147
|
+
# @return [String] the audiovisual portion of the referenced content.
|
148
|
+
# Possible values are: +'audio'+, +'audiovisual'+, +'video'+.
|
148
149
|
has_attribute :content_type
|
149
150
|
|
150
|
-
# @return [Boolean] whether the reference covers the audio
|
151
|
-
# content.
|
151
|
+
# @return [Boolean] whether the reference covers only the audio.
|
152
152
|
def audio?
|
153
153
|
content_type == 'audio'
|
154
154
|
end
|
155
155
|
|
156
|
-
# @return [Boolean] whether the reference covers the video
|
157
|
-
# content.
|
156
|
+
# @return [Boolean] whether the reference covers only the video.
|
158
157
|
def video?
|
159
158
|
content_type == 'video'
|
160
159
|
end
|
161
160
|
|
162
|
-
# @return [Boolean] whether the reference covers
|
163
|
-
# content.
|
161
|
+
# @return [Boolean] whether the reference covers both audio and video.
|
164
162
|
def audiovisual?
|
165
163
|
content_type == 'audiovisual'
|
166
164
|
end
|
data/lib/yt/models/resource.rb
CHANGED
@@ -8,17 +8,39 @@ module Yt
|
|
8
8
|
class Resource < Base
|
9
9
|
attr_reader :auth
|
10
10
|
|
11
|
+
### ID ###
|
12
|
+
|
11
13
|
# @!attribute [r] id
|
12
14
|
# @return [String] the ID that YouTube uses to identify each resource.
|
13
15
|
has_one :id
|
14
16
|
|
17
|
+
### STATUS ###
|
18
|
+
|
19
|
+
has_one :status
|
20
|
+
|
21
|
+
# @return [String] the privacy status of the resource. Possible values
|
22
|
+
# are: +'private'+, +'public'+, +'unlisted'+.
|
23
|
+
delegate :privacy_status, to: :status
|
24
|
+
|
25
|
+
# @return [Boolean] whether the resource is public.
|
26
|
+
def public?
|
27
|
+
privacy_status == 'public'
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [Boolean] whether the resource is private.
|
31
|
+
def private?
|
32
|
+
privacy_status == 'private'
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Boolean] whether the resource is unlisted.
|
36
|
+
def unlisted?
|
37
|
+
privacy_status == 'unlisted'
|
38
|
+
end
|
39
|
+
|
15
40
|
has_one :snippet
|
16
41
|
delegate :title, :description, :thumbnail_url, :published_at,
|
17
42
|
to: :snippet
|
18
43
|
|
19
|
-
has_one :status
|
20
|
-
delegate :privacy_status, :public?, :private?, :unlisted?, to: :status
|
21
|
-
|
22
44
|
def initialize(options = {})
|
23
45
|
@url = URL.new(options[:url]) if options[:url]
|
24
46
|
@id = options[:id] || (@url.id if @url)
|
@@ -47,9 +69,11 @@ module Yt
|
|
47
69
|
end
|
48
70
|
end
|
49
71
|
|
50
|
-
|
51
72
|
private
|
52
73
|
|
74
|
+
# TODO: instead of having Video, Playlist etc override this method,
|
75
|
+
# they should define *what* can be updated in their own *update*
|
76
|
+
# method.
|
53
77
|
# @return [Hash] the parameters to submit to YouTube to update a playlist.
|
54
78
|
# @see https://developers.google.com/youtube/v3/docs/playlists/update
|
55
79
|
# @see https://developers.google.com/youtube/v3/docs/videos/update
|
data/lib/yt/models/status.rb
CHANGED
@@ -22,25 +22,7 @@ module Yt
|
|
22
22
|
|
23
23
|
PRIVACY_STATUSES = %q(private public unlisted)
|
24
24
|
|
25
|
-
# @return [String] the privacy status of the resource. Valid values are:
|
26
|
-
# private, public, unlisted.
|
27
25
|
has_attribute :privacy_status
|
28
|
-
|
29
|
-
# @return [Boolean] whether the resource is public.
|
30
|
-
def public?
|
31
|
-
privacy_status == 'public'
|
32
|
-
end
|
33
|
-
|
34
|
-
# @return [Boolean] whether the resource is private.
|
35
|
-
def private?
|
36
|
-
privacy_status == 'private'
|
37
|
-
end
|
38
|
-
|
39
|
-
# @return [Boolean] whether the resource is unlisted.
|
40
|
-
def unlisted?
|
41
|
-
privacy_status == 'unlisted'
|
42
|
-
end
|
43
|
-
|
44
26
|
has_attribute :upload_status
|
45
27
|
has_attribute :failure_reason
|
46
28
|
has_attribute :rejection_reason
|
data/lib/yt/models/user_info.rb
CHANGED
@@ -34,7 +34,7 @@ module Yt
|
|
34
34
|
has_attribute :avatar_url, from: :picture, default: ''
|
35
35
|
|
36
36
|
# @return [String] the person’s gender. Possible values include, but
|
37
|
-
# are not limited to,
|
37
|
+
# are not limited to, +'male'+, +'female'+, +'other'+.
|
38
38
|
has_attribute :gender, default: ''
|
39
39
|
|
40
40
|
# @return [String] the user’s preferred locale.
|
data/lib/yt/models/video.rb
CHANGED
@@ -9,13 +9,11 @@ module Yt
|
|
9
9
|
### SNIPPET ###
|
10
10
|
|
11
11
|
# @!attribute [r] title
|
12
|
-
# @return [String] the video’s title.
|
13
|
-
# may contain all valid UTF-8 characters except < and >.
|
12
|
+
# @return [String] the video’s title.
|
14
13
|
delegate :title, to: :snippet
|
15
14
|
|
16
15
|
# @!attribute [r] description
|
17
|
-
# @return [String] the video’s description.
|
18
|
-
# and may contain all valid UTF-8 characters except < and >.
|
16
|
+
# @return [String] the video’s description.
|
19
17
|
delegate :description, to: :snippet
|
20
18
|
|
21
19
|
# Return the URL of the video’s thumbnail.
|
@@ -41,11 +39,10 @@ module Yt
|
|
41
39
|
|
42
40
|
# @!attribute [r] live_broadcast_content
|
43
41
|
# @return [String] the type of live broadcast that the video contains.
|
44
|
-
#
|
42
|
+
# Possible values are: +'live'+, +'none'+, +'upcoming'+.
|
45
43
|
delegate :live_broadcast_content, to: :snippet
|
46
44
|
|
47
|
-
# @return [Array<
|
48
|
-
# with the video.
|
45
|
+
# @return [Array<String>] the list of tags attached to the video.
|
49
46
|
def tags
|
50
47
|
ensure_complete_snippet :tags
|
51
48
|
end
|
@@ -196,8 +193,8 @@ module Yt
|
|
196
193
|
end
|
197
194
|
|
198
195
|
# @!attribute [r] license
|
199
|
-
# @return [String] the video’s license.
|
200
|
-
#
|
196
|
+
# @return [String] the video’s license. Possible values are:
|
197
|
+
# +'creativeCommon'+, +'youtube'+.
|
201
198
|
delegate :license, to: :status
|
202
199
|
|
203
200
|
# @return [Boolean] whether the video uses the Standard YouTube license.
|
@@ -222,7 +219,7 @@ module Yt
|
|
222
219
|
status.public_stats_viewable
|
223
220
|
end
|
224
221
|
|
225
|
-
# @return [Boolean] whether the video can be embedded on
|
222
|
+
# @return [Boolean] whether the video can be embedded on other websites.
|
226
223
|
def embeddable?
|
227
224
|
status.embeddable
|
228
225
|
end
|
@@ -328,8 +325,9 @@ module Yt
|
|
328
325
|
|
329
326
|
# @!attribute [r] ad_formats
|
330
327
|
# @return [Array<String>] the list of ad formats that the video is
|
331
|
-
# allowed to show.
|
332
|
-
# standard_instream
|
328
|
+
# allowed to show. Possible values are: +'long'+, +'overlay'+,
|
329
|
+
# +'standard_instream'+, +'third_party'+, +'trueview_inslate'+,
|
330
|
+
# +'trueview_instream'+.
|
333
331
|
delegate :ad_formats, to: :advertising_options_set
|
334
332
|
|
335
333
|
|
@@ -465,7 +463,7 @@ module Yt
|
|
465
463
|
# @return [Integer] the number of users who marked the video as favorite.
|
466
464
|
delegate :favorite_count, to: :statistics_set
|
467
465
|
|
468
|
-
# @!attribute [r]
|
466
|
+
# @!attribute [r] comment_count
|
469
467
|
# @return [Integer] the number of comments for the video.
|
470
468
|
delegate :comment_count, to: :statistics_set
|
471
469
|
|
@@ -507,6 +505,44 @@ module Yt
|
|
507
505
|
!exists?
|
508
506
|
end
|
509
507
|
|
508
|
+
# Updates the attributes of a video.
|
509
|
+
# @return [Boolean] whether the video was successfully updated.
|
510
|
+
# @raise [Yt::Errors::Unauthorized] if {Resource#auth auth} is not an
|
511
|
+
# authenticated Yt::Account with permissions to update the video.
|
512
|
+
# @param [Hash] attributes the attributes to update.
|
513
|
+
# @option attributes [String] :title The new video’s title.
|
514
|
+
# Cannot have more than 100 characters. Can include the characters
|
515
|
+
# < and >, which are replaced to ‹ › in order to be accepted by YouTube.
|
516
|
+
# @option attributes [String] :description The new video’s description.
|
517
|
+
# Cannot have more than 5000 bytes. Can include the characters
|
518
|
+
# < and >, which are replaced to ‹ › in order to be accepted by YouTube.
|
519
|
+
# @option attributes [Array<String>] :tags The new video’s tags.
|
520
|
+
# Cannot have more than 500 characters. Can include the characters
|
521
|
+
# < and >, which are replaced to ‹ › in order to be accepted by YouTube.
|
522
|
+
# @option attributes [String] :category_id The new video’s category ID.
|
523
|
+
# @option attributes [String] :privacy_status The new video’s privacy
|
524
|
+
# status. Must be one of: private, unscheduled, public.
|
525
|
+
# @option attributes [Boolean] :embeddable The new value to specify
|
526
|
+
# whether the video can be embedded on other websites.
|
527
|
+
# @option attributes [String] :license The new video’s license. Must be
|
528
|
+
# one of: youtube, creativeCommon.
|
529
|
+
# @option attributes [Boolean] :public_stats_viewable The new value to
|
530
|
+
# specify whether the video’s statistics are publicly viewable.
|
531
|
+
# @option attributes :publish_at The new timestamp when the video will be
|
532
|
+
# made public. Must be in ISO 8601 format (YYYY-MM-DDThh:mm:ss.sZ).
|
533
|
+
# @example Update title and description of a video.
|
534
|
+
# video.update title: 'New title', description: 'New description'
|
535
|
+
# @example Update tags and category ID of a video.
|
536
|
+
# video.update tags: ['new', 'tags'], category_id: '22'
|
537
|
+
# @example Update status of a video.
|
538
|
+
# video.update privacy_status: 'public', public_stats_viewable: true
|
539
|
+
# @example Update visibility/license of a video.
|
540
|
+
# video.update embeddable: true, license: :youtube
|
541
|
+
# @example Update the time when a private video will become public.
|
542
|
+
# video.update publish_at: 3.days.from_now.utc.iso8601(3)
|
543
|
+
def update(attributes = {})
|
544
|
+
super
|
545
|
+
end
|
510
546
|
|
511
547
|
### PRIVATE API ###
|
512
548
|
|
@@ -587,6 +623,9 @@ module Yt
|
|
587
623
|
snippet.public_send attribute
|
588
624
|
end
|
589
625
|
|
626
|
+
# TODO: instead of having Video, Playlist etc override this method,
|
627
|
+
# they should define *what* can be updated in their own *update*
|
628
|
+
# method.
|
590
629
|
# @see https://developers.google.com/youtube/v3/docs/videos/update
|
591
630
|
# @todo: Add recording details keys
|
592
631
|
def update_parts
|
data/lib/yt/version.rb
CHANGED
@@ -18,4 +18,40 @@ describe Yt::Resource do
|
|
18
18
|
it { expect(resource.kind).to eq 'channel' }
|
19
19
|
it { expect(resource.username).to eq 'fullscreen' }
|
20
20
|
end
|
21
|
+
|
22
|
+
describe '#public?' do
|
23
|
+
context 'given fetching a status returns privacyStatus "public"' do
|
24
|
+
let(:attrs) { {status: {"privacyStatus"=>"public"}} }
|
25
|
+
it { expect(resource).to be_public }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'given fetching a status does not return privacyStatus "public"' do
|
29
|
+
let(:attrs) { {status: {}} }
|
30
|
+
it { expect(resource).not_to be_public }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#private?' do
|
35
|
+
context 'given fetching a status returns privacyStatus "private"' do
|
36
|
+
let(:attrs) { {status: {"privacyStatus"=>"private"}} }
|
37
|
+
it { expect(resource).to be_private }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'given fetching a status does not return privacyStatus "private"' do
|
41
|
+
let(:attrs) { {status: {}} }
|
42
|
+
it { expect(resource).not_to be_private }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#unlisted?' do
|
47
|
+
context 'given fetching a status returns privacyStatus "unlisted"' do
|
48
|
+
let(:attrs) { {status: {"privacyStatus"=>"unlisted"}} }
|
49
|
+
it { expect(resource).to be_unlisted }
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'given fetching a status does not return privacyStatus "unlisted"' do
|
53
|
+
let(:attrs) { {status: {}} }
|
54
|
+
it { expect(resource).not_to be_unlisted }
|
55
|
+
end
|
56
|
+
end
|
21
57
|
end
|
data/spec/models/status_spec.rb
CHANGED
@@ -10,40 +10,4 @@ describe Yt::Status do
|
|
10
10
|
expect(status.data).to eq data
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
describe '#public?' do
|
15
|
-
context 'given fetching a status returns privacyStatus "public"' do
|
16
|
-
let(:data) { {"privacyStatus"=>"public"} }
|
17
|
-
it { expect(status).to be_public }
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'given fetching a status does not return privacyStatus "public"' do
|
21
|
-
let(:data) { {} }
|
22
|
-
it { expect(status).not_to be_public }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#private?' do
|
27
|
-
context 'given fetching a status returns privacyStatus "private"' do
|
28
|
-
let(:data) { {"privacyStatus"=>"private"} }
|
29
|
-
it { expect(status).to be_private }
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'given fetching a status does not return privacyStatus "private"' do
|
33
|
-
let(:data) { {} }
|
34
|
-
it { expect(status).not_to be_private }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#unlisted?' do
|
39
|
-
context 'given fetching a status returns privacyStatus "unlisted"' do
|
40
|
-
let(:data) { {"privacyStatus"=>"unlisted"} }
|
41
|
-
it { expect(status).to be_unlisted }
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'given fetching a status does not return privacyStatus "unlisted"' do
|
45
|
-
let(:data) { {} }
|
46
|
-
it { expect(status).not_to be_unlisted }
|
47
|
-
end
|
48
|
-
end
|
49
13
|
end
|