Skip to content

Add engaged_views to channels and videos #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ doc/
.yardoc/
_site/
TODO.md

spec/cassettes/
8 changes: 7 additions & 1 deletion lib/yt/collections/reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ class Reports < Base
playlist_page: 'YT_PLAYLIST_PAGE',
campaign_card: 'CAMPAIGN_CARD',
end_screen: 'END_SCREEN',
info_card: 'INFO_CARD'
info_card: 'INFO_CARD',
hashtags: 'HASHTAGS',
live_redirect: 'LIVE_REDIRECT',
product_page: 'PRODUCT_PAGE',
shorts: 'SHORTS',
sound_page: 'SOUND_PAGE',
video_remixes: 'VIDEO_REMIXES'
}

# @see https://developers.google.com/youtube/analytics/dimensions#Playback_Location_Dimensions
Expand Down
3 changes: 3 additions & 0 deletions lib/yt/models/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def unsubscribe!
# @macro report_by_channel_dimensions
has_report :views, Integer

# @macro report_by_channel_dimensions
has_report :engaged_views, Integer

# @macro report_by_channel_dimensions
has_report :estimated_minutes_watched, Integer

Expand Down
3 changes: 3 additions & 0 deletions lib/yt/models/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ def claim
# @macro report_by_video_dimensions
has_report :views, Integer

# @macro report_by_video_dimensions
has_report :engaged_views, Integer

# @macro report_by_video_dimensions
has_report :estimated_minutes_watched, Integer

Expand Down
1 change: 1 addition & 0 deletions spec/requests/as_account/channel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
# Some reports are only available to Content Owners.
# See content owner test for more details about what the methods return.
expect{channel.views}.not_to raise_error
expect{channel.engaged_views}.not_to raise_error
expect{channel.comments}.not_to raise_error
expect{channel.likes}.not_to raise_error
expect{channel.dislikes}.not_to raise_error
Expand Down
5 changes: 5 additions & 0 deletions spec/requests/as_account/video_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,10 @@
expect(video.file_type).to be_nil
expect(video.container).to be_nil
end

it 'returns valid reports for video-related metrics' do
expect{video.views}.not_to raise_error
expect{video.engaged_views}.not_to raise_error
end
end
end