Updated to 2 steps for android app, channel id and channel related videos

This commit is contained in:
saurabhbhatia 2013-10-04 11:27:00 +08:00
parent 795d881626
commit 55207da76a
2 changed files with 17 additions and 2 deletions

View File

@ -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)

View File

@ -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