add youtube api
This commit is contained in:
parent
cbd05eadc7
commit
b6c831714a
|
@ -30,6 +30,14 @@ class Admin::VideoChannelsController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@video_channel = VideoChannel.find(params[:id])
|
||||
channel_id = @video_channel.channel_link.split("/")[-1]
|
||||
uri = URI('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' + channel_id + '&key=AIzaSyCTFdyLgb7GJfrr1JOI3gvVslZFw7td2zQ')
|
||||
@r = Net::HTTP.get(uri) # => String
|
||||
@r = JSON.parse(@r)
|
||||
end
|
||||
|
||||
def update
|
||||
video_channel = VideoChannel.find(params[:id])
|
||||
|
||||
|
|
|
@ -1,3 +1,25 @@
|
|||
class VideoChannelsController < ApplicationController
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
@video_channel = VideoChannel.find(params[:id])
|
||||
channel_id = @video_channel.channel_link.split("/")[-1]
|
||||
uri = URI('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=' + channel_id + '&key=AIzaSyCTFdyLgb7GJfrr1JOI3gvVslZFw7td2zQ')
|
||||
result = Net::HTTP.get(uri) # => String
|
||||
result = JSON.parse(result)
|
||||
|
||||
nextPageToken = result['nextPageToken']
|
||||
videos = {}
|
||||
|
||||
while !nextPageToken.nil?
|
||||
result['items'].each do item
|
||||
video = item['snippet']
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@
|
|||
<% @video_channels.each do |video_channel| %>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/admin/video_channels" target="_blank"><%= video_channel.title %></a>
|
||||
<a href="/admin/video_channels/<%= video_channel.id.to_s %>" target="_blank"><%= video_channel.title %></a>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<% if can_edit_or_delete?(video_channel) %>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<%= @video_channel.channel_link %>
|
||||
<br>
|
||||
<br>
|
||||
Video Title: <%= @r['items'].first['snippet']['title'] %><br>
|
||||
Description: <%= @r['items'].first['snippet']['description'] %><br>
|
||||
Publish Date: <%= @r['items'].first['snippet']['publishedAt'] %><br>
|
||||
img1: <img src="<%= @r['items'].first['snippet']['thumbnails']['default']['url'] %>"><br>
|
||||
img2: <img src="<%= @r['items'].first['snippet']['thumbnails']['medium']['url'] %>"><br>
|
||||
img3: <img src="<%= @r['items'].first['snippet']['thumbnails']['high']['url'] %>"><br>
|
||||
Channel Title: <%= @r['items'].first['snippet']['channelTitle'] %><br>
|
|
@ -1 +1,3 @@
|
|||
sadsadaskldasjdlkasdkla
|
||||
aaaaaa
|
||||
|
||||
<%= render_view %>
|
Loading…
Reference in New Issue