|
|
|
@ -96,6 +96,21 @@ class Video
|
|
|
|
|
language: String?,
|
|
|
|
|
author: String,
|
|
|
|
|
ucid: String,
|
|
|
|
|
allowed_regions: {
|
|
|
|
|
type: Array(String),
|
|
|
|
|
nilable: true,
|
|
|
|
|
default: [] of String,
|
|
|
|
|
},
|
|
|
|
|
is_family_friendly: {
|
|
|
|
|
type: Bool,
|
|
|
|
|
nilable: true,
|
|
|
|
|
default: nil,
|
|
|
|
|
},
|
|
|
|
|
genre: {
|
|
|
|
|
type: String,
|
|
|
|
|
nilable: true,
|
|
|
|
|
default: nil,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -274,7 +289,11 @@ def fetch_video(id, client)
|
|
|
|
|
published = html.xpath_node(%q(//meta[@itemprop="datePublished"])).not_nil!["content"]
|
|
|
|
|
published = Time.parse(published, "%Y-%m-%d", Time::Location.local)
|
|
|
|
|
|
|
|
|
|
video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description, nil, author, ucid)
|
|
|
|
|
allowed_regions = html.xpath_node(%q(//meta[@itemprop="regionsAllowed"])).not_nil!["content"].split(",")
|
|
|
|
|
is_family_friendly = html.xpath_node(%q(//meta[@itemprop="isFamilyFriendly"])).not_nil!["content"] == "True"
|
|
|
|
|
genre = html.xpath_node(%q(//meta[@itemprop="genre"])).not_nil!["content"]
|
|
|
|
|
|
|
|
|
|
video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description, nil, author, ucid, allowed_regions, is_family_friendly, genre)
|
|
|
|
|
|
|
|
|
|
return video
|
|
|
|
|
end
|
|
|
|
@ -298,7 +317,7 @@ def get_video(id, client, db, refresh = true)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
video = fetch_video(id, client)
|
|
|
|
|
video_array = video.to_a
|
|
|
|
|
video_array = video.to_a[0, 13]
|
|
|
|
|
args = arg_array(video_array)
|
|
|
|
|
|
|
|
|
|
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array)
|
|
|
|
|