Updated channel json with number of videos

This commit is contained in:
saurabhbhatia 2013-10-04 18:04:47 +08:00
parent f8c7e8f17a
commit 839743779b
1 changed files with 4 additions and 1 deletions

View File

@ -61,9 +61,12 @@ class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController
@data = Array.new
@channels.each do |channel|
client = YouTubeIt::Client.new(:dev_key => "AI39si5KGPg8rhKLBfmeukit2tCSP_B9lT8igiNICbrbgUXQoAdYGvsyCGCmO1wGnr1OW4bDRv-ESolwk-rdBNIAgVTL9VYaEA")
@client_videos = client.videos_by(:user => channel.channel_name)
number_of_videos = @client_videos.videos.length
name = channel.channel_name
channel_id = channel.id.to_s
@data << { channel_name: name, channel_link: "http://ntue.tp.rulingcom.com/panel/video/back_end/channel_videos/get_channel_videos?channel_id=#{channel_id}"}
@data << { channel_name: name, channel_link: "http://ntue.tp.rulingcom.com/panel/video/back_end/channel_videos/get_channel_videos?channel_id=#{channel_id}", number_of_videos: number_of_videos }
end
render :json => JSON.pretty_generate(@data)