From 55207da76a346f7105d84b0722da975806a8acf4 Mon Sep 17 00:00:00 2001 From: saurabhbhatia Date: Fri, 4 Oct 2013 11:27:00 +0800 Subject: [PATCH] Updated to 2 steps for android app, channel id and channel related videos --- .../back_end/channel_videos_controller.rb | 18 ++++++++++++++++-- vendor/built_in_modules/video/config/routes.rb | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb index 41a7e77ce..68e61b5a1 100644 --- a/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb +++ b/vendor/built_in_modules/video/app/controllers/panel/video/back_end/channel_videos_controller.rb @@ -56,8 +56,21 @@ class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController end + def get_channels + @channels = ChannelVideo.all + @data = Array.new + + @channels.each do |channel| + name = channel.channel_name + channel_id = channel.id.to_s + @data << { channel_name: name, channel_link: "http://ntue.tp.rulingcom.com/panel/location/back_end/channel_videos/get_channel_videos?channel_id=#{channel_id}"} + end + + render :json => JSON.pretty_generate(@data) + end + def get_channel_videos - @channel_video = ChannelVideo.all + @channel_video = ChannelVideo.where(:_id => params[:channel_id]) @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) @@ -69,8 +82,9 @@ class Panel::Video::BackEnd::ChannelVideosController < OrbitBackendController title = video.title description = video.description author = video.author.name + channel_name = channel.channel_name # category_id = category.id.to_s - @data << { title: title, description: description, url: url, author: author} + @data << { title: title, description: description, url: url, author: author, channel_name: channel_name} end render :json => JSON.pretty_generate(@data) diff --git a/vendor/built_in_modules/video/config/routes.rb b/vendor/built_in_modules/video/config/routes.rb index d3b74cc95..b460c1695 100644 --- a/vendor/built_in_modules/video/config/routes.rb +++ b/vendor/built_in_modules/video/config/routes.rb @@ -4,6 +4,7 @@ Rails.application.routes.draw do namespace :back_end do match "videos/get_videos" => "videos#get_videos" resources :videos + match "channel_videos/get_channels" => "channel_videos#get_channels" match "channel_videos/get_channel_videos" => "channel_videos#get_channel_videos" resources :channel_videos