diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb index fe45228..03c592e 100644 --- a/app/controllers/videos_controller.rb +++ b/app/controllers/videos_controller.rb @@ -7,7 +7,6 @@ class VideosController < ApplicationController # GET /videos # GET /videos.json def index - if I18n.locale.to_s == "en" @videos = Video.video_by_type("Youtube") elsif I18n.locale.to_s == "zh-CN" @@ -21,7 +20,7 @@ def show # render file: 'videos/show.js.erb' @video = Video.find(params[:id]) respond_to do |format| - format.html + format.html format.js {} end end diff --git a/app/models/video.rb b/app/models/video.rb index 5de06d0..518c3d1 100644 --- a/app/models/video.rb +++ b/app/models/video.rb @@ -54,23 +54,23 @@ def self.fetching_videos(list) begin entry = find_or_create_by(video_id: video.id) entry.update( - title: video.title, - summary: video.description, - video_type: "Youtube", - published_at: video.published_at, - thumbnail_url: video.thumbnail_url, - channel_id: video.channel_id, - channel_title: video.channel_title, - category_id: video.category_id, - category_title: video.category_title, - view_count: video.view_count, - like_count: video.like_count, - dislike_count: video.dislike_count, - favorite_count: video.favorite_count, - comment_count: video.comment_count, - duration: video.duration, - is_hd: video.hd?, - embed_html: video.embed_html) + title: video.title, + summary: video.description, + video_type: "Youtube", + published_at: video.published_at, + thumbnail_url: video.thumbnail_url, + channel_id: video.channel_id, + channel_title: video.channel_title, + category_id: video.category_id, + category_title: video.category_title, + view_count: video.view_count, + like_count: video.like_count, + dislike_count: video.dislike_count, + favorite_count: video.favorite_count, + comment_count: video.comment_count, + duration: video.duration, + is_hd: video.hd?, + embed_html: video.embed_html) rescue next end @@ -83,18 +83,18 @@ def self.fetching_videos(list) embed_html = "" entry = find_or_create_by(video_id: id) entry.update( - title: video["title"], - video_type: "Youku", - published_at: video["published"], - thumbnail_url: video["thumbnail"], - category_title: video["category"], - view_count: video["view_count"], - like_count: video["up_count"], - dislike_count: video["down_count"], - favorite_count: video["favorite_count"], - comment_count: video["comment_count"], - duration: video["duration"], - embed_html: embed_html) + title: video["title"], + video_type: "Youku", + published_at: video["published"], + thumbnail_url: video["thumbnail"], + category_title: video["category"], + view_count: video["view_count"], + like_count: video["up_count"], + dislike_count: video["down_count"], + favorite_count: video["favorite_count"], + comment_count: video["comment_count"], + duration: video["duration"], + embed_html: embed_html) rescue next end diff --git a/db/seeds.rb b/db/seeds.rb index fc8ffad..8346cb2 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,8 +1,9 @@ -User.create(email: "test@techbay.com", password: "12345678", reward: 10, isadmin: true) -List.create(name: "programming", rid: "PLxsn9ryMcqFRaF8rXgwkwb6SMzBNWhCri", source_type: "youtube") -List.create(name: "test", rid: "27270192", source_type: "youku") +User.find_or_create_by(email: "test@techbay.com").update(password: "12345678", reward: 10, isadmin: true) +List.find_or_create_by(rid: "PLxsn9ryMcqFRaF8rXgwkwb6SMzBNWhCri").update(name: "programming", source_type: "youtube") +List.find_or_create_by(rid: "27270192").update(name: "test", source_type: "youku") Tag.create(name: "rails") Tag.create(name: "html") + # Suppose we use youtube List.all.each do |l| l.fetching_videos