Skip to content

Commit

Permalink
update seed
Browse files Browse the repository at this point in the history
  • Loading branch information
iannono committed May 30, 2016
1 parent 3ac7054 commit 6591c43
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
3 changes: 1 addition & 2 deletions app/controllers/videos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
58 changes: 29 additions & 29 deletions app/models/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -83,18 +83,18 @@ def self.fetching_videos(list)
embed_html = "<embed src='http://player.youku.com/player.php/sid/" + id + "/v.swf' allowFullScreen='true' quality='high' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash'></embed>"
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
Expand Down
7 changes: 4 additions & 3 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
User.create(email: "[email protected]", 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: "[email protected]").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
Expand Down

0 comments on commit 6591c43

Please sign in to comment.