ruby-on-rails - 从 Youtube Data API 在我的 ruby 应用程序中显示 Youtube 缩略图:我做错了什么?
问题描述
我一直在开发这个名为youtube cancer free的应用程序一个星期,但我遇到了缩略图问题。我要做的是在发送 youtube API 请求时显示频道标题 + 视频标题 + 视频缩略图。到目前为止,后者似乎不起作用,我真的不知道为什么。这是进行研究时结果的示例:
JRE Clips
Joe Rogan on France's Anti-Macron Riots
#<Google::Apis::YoutubeV3::ThumbnailDetails:0x00007fa7c862c790>
为了记录,这是我的控制器的样子:
class WelcomeController < ApplicationController
def index
youtube_data_api = YoutubeDataApi.new.client
@result, @errors = youtube_data_api.list_searches 'snippet', q:
'youtube france -cyprien -fortnite -gotaga -gamemixtreize -bodytime -
farod -andy -telefoot -konbini -topito -inthepanda -vdbuzz -mickalow -
sandrea', max_results: '50'
end
end
以及我的看法:
<div>
<% @result.items.each do |video| %>
<div>
<%= video.snippet.channel_title %>
</div>
<div>
<%= video.snippet.title %>
</div>
<div>
<%= video.snippet.thumbnails %>
</div>
<% end %>
谁能告诉我我的错误是什么以及可以做些什么来解决这个问题?提前致谢。
解决方案
我最终自己找到了答案,哈哈
@result, @errors = youtube_data_api.list_videos 'snippet, id', chart: 'mostPopular', region_code: 'FR', max_results: '50'
如果你愿意,你现在可以锁定这个话题。