mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Add 'genre', 'allowedRegions', 'isFamilyFriendly' to videos
This commit is contained in:
parent
1202e1f2bf
commit
0f46c18f99
3 changed files with 41 additions and 16 deletions
|
@ -733,6 +733,10 @@ get "/api/v1/videos/:id" do |env|
|
||||||
json.field "likeCount", video.likes
|
json.field "likeCount", video.likes
|
||||||
json.field "dislikeCount", video.dislikes
|
json.field "dislikeCount", video.dislikes
|
||||||
|
|
||||||
|
json.field "isFamilyFriendly", video.is_family_friendly
|
||||||
|
json.field "allowedRegions", video.allowed_regions
|
||||||
|
json.field "genre", video.genre
|
||||||
|
|
||||||
json.field "author", video.author
|
json.field "author", video.author
|
||||||
json.field "authorId", video.ucid
|
json.field "authorId", video.ucid
|
||||||
json.field "authorUrl", "/channel/#{video.ucid}"
|
json.field "authorUrl", "/channel/#{video.ucid}"
|
||||||
|
@ -984,7 +988,7 @@ get "/search" do |env|
|
||||||
html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=EgIQAVAU").body
|
html = client.get("/results?q=#{URI.escape(query)}&page=#{page}&sp=EgIQAVAU").body
|
||||||
html = XML.parse_html(html)
|
html = XML.parse_html(html)
|
||||||
|
|
||||||
videos = [] of Video
|
videos = [] of ChannelVideo
|
||||||
|
|
||||||
html.xpath_nodes(%q(//ol[@class="item-section"]/li)).each do |item|
|
html.xpath_nodes(%q(//ol[@class="item-section"]/li)).each do |item|
|
||||||
root = item.xpath_node(%q(div[contains(@class,"yt-lockup-video")]/div))
|
root = item.xpath_node(%q(div[contains(@class,"yt-lockup-video")]/div))
|
||||||
|
@ -1009,7 +1013,7 @@ get "/search" do |env|
|
||||||
author ||= ""
|
author ||= ""
|
||||||
ucid ||= ""
|
ucid ||= ""
|
||||||
|
|
||||||
video = Video.new(id, HTTP::Params.parse(""), Time.now, title, 0_i64, 0, 0, 0.0, Time.now, "", nil, author, ucid)
|
video = ChannelVideo.new(id, title, Time.now, Time.now, ucid, author)
|
||||||
videos << video
|
videos << video
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,17 +85,32 @@ class Video
|
||||||
default: HTTP::Params.parse(""),
|
default: HTTP::Params.parse(""),
|
||||||
converter: Video::HTTPParamConverter,
|
converter: Video::HTTPParamConverter,
|
||||||
},
|
},
|
||||||
updated: Time,
|
updated: Time,
|
||||||
title: String,
|
title: String,
|
||||||
views: Int64,
|
views: Int64,
|
||||||
likes: Int32,
|
likes: Int32,
|
||||||
dislikes: Int32,
|
dislikes: Int32,
|
||||||
wilson_score: Float64,
|
wilson_score: Float64,
|
||||||
published: Time,
|
published: Time,
|
||||||
description: String,
|
description: String,
|
||||||
language: String?,
|
language: String?,
|
||||||
author: String,
|
author: String,
|
||||||
ucid: 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
|
end
|
||||||
|
|
||||||
|
@ -274,7 +289,11 @@ def fetch_video(id, client)
|
||||||
published = html.xpath_node(%q(//meta[@itemprop="datePublished"])).not_nil!["content"]
|
published = html.xpath_node(%q(//meta[@itemprop="datePublished"])).not_nil!["content"]
|
||||||
published = Time.parse(published, "%Y-%m-%d", Time::Location.local)
|
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
|
return video
|
||||||
end
|
end
|
||||||
|
@ -298,7 +317,7 @@ def get_video(id, client, db, refresh = true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
video = fetch_video(id, client)
|
video = fetch_video(id, client)
|
||||||
video_array = video.to_a
|
video_array = video.to_a[0, 13]
|
||||||
args = arg_array(video_array)
|
args = arg_array(video_array)
|
||||||
|
|
||||||
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array)
|
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array)
|
||||||
|
@ -983,7 +1002,7 @@ def generate_captcha(key)
|
||||||
<text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>
|
<text x="17.091" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">10</text>
|
||||||
<text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>
|
<text x="31" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">11</text>
|
||||||
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
|
<text x="50" y="15" text-anchor="middle" fill="black" font-family="Arial" font-size="10px">12</text>
|
||||||
|
|
||||||
<circle cx="50" cy="50" r="3" fill="black"></circle>
|
<circle cx="50" cy="50" r="3" fill="black"></circle>
|
||||||
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
<line id="minute" transform="rotate(#{minute_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="16" fill="black" stroke="black" stroke-width="2"></line>
|
||||||
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
<line id="hour" transform="rotate(#{hour_angle}, 50, 50)" x1="50" y1="50" x2="50" y2="24" fill="black" stroke="black" stroke-width="2"></line>
|
||||||
|
|
|
@ -217,6 +217,8 @@ String.prototype.supplant = function (o) {
|
||||||
<p><i class="fa fa-eye" aria-hidden="true"></i> <%= number_with_separator(video.views) %></p>
|
<p><i class="fa fa-eye" aria-hidden="true"></i> <%= number_with_separator(video.views) %></p>
|
||||||
<p><i class="fa fa-thumbs-up" aria-hidden="true"></i> <%= number_with_separator(video.likes) %></p>
|
<p><i class="fa fa-thumbs-up" aria-hidden="true"></i> <%= number_with_separator(video.likes) %></p>
|
||||||
<p><i class="fa fa-thumbs-down" aria-hidden="true"></i> <%= number_with_separator(video.dislikes) %></p>
|
<p><i class="fa fa-thumbs-down" aria-hidden="true"></i> <%= number_with_separator(video.dislikes) %></p>
|
||||||
|
<p id="Genre">Genre : <%= video.genre %></p>
|
||||||
|
<p id="FamilyFriendly">Family Friendly? <%= video.is_family_friendly %></p>
|
||||||
<p id="Wilson">Wilson Score : <%= video.wilson_score.round(4) %></p>
|
<p id="Wilson">Wilson Score : <%= video.wilson_score.round(4) %></p>
|
||||||
<p id="Rating">Rating : <%= rating.round(4) %> / 5</p>
|
<p id="Rating">Rating : <%= rating.round(4) %> / 5</p>
|
||||||
<p id="Engagement">Engagement : <%= engagement.round(2) %>%</p>
|
<p id="Engagement">Engagement : <%= engagement.round(2) %>%</p>
|
||||||
|
|
Loading…
Reference in a new issue