Added video json api
This commit is contained in:
parent
4cd455441f
commit
795d881626
|
@ -1,6 +1,6 @@
|
|||
class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController
|
||||
before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete]
|
||||
before_filter :force_order_for_user,:except => [:index]
|
||||
before_filter :force_order_for_user,:except => [:index, :get_channel_videos]
|
||||
|
||||
def index
|
||||
@channel_videos = ChannelVideo.all
|
||||
|
@ -17,7 +17,7 @@ class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @location }
|
||||
format.json { render json: @channel_videos }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,4 +55,25 @@ class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController
|
|||
redirect_to panel_video_back_end_channel_videos_url
|
||||
|
||||
end
|
||||
|
||||
def get_channel_videos
|
||||
@channel_video = ChannelVideo.all
|
||||
@channel_video.each do |channel|
|
||||
client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
|
||||
@client_videos = client.videos_by(:user => channel.channel_name, :per_page => 5)
|
||||
@data = Array.new
|
||||
|
||||
|
||||
@client_videos.videos.each do |video|
|
||||
url = video.player_url
|
||||
title = video.title
|
||||
description = video.description
|
||||
author = video.author.name
|
||||
# category_id = category.id.to_s
|
||||
@data << { title: title, description: description, url: url, author: author}
|
||||
end
|
||||
|
||||
render :json => JSON.pretty_generate(@data)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,6 +4,8 @@ Rails.application.routes.draw do
|
|||
namespace :back_end do
|
||||
match "videos/get_videos" => "videos#get_videos"
|
||||
resources :videos
|
||||
match "channel_videos/get_channel_videos" => "channel_videos#get_channel_videos"
|
||||
|
||||
resources :channel_videos
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue