mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-22 05:27:21 +00:00
Add genre URLs
This commit is contained in:
parent
2ac89d5e00
commit
53732cdcab
@ -2014,6 +2014,7 @@ get "/api/v1/videos/:id" do |env|
|
||||
json.field "isFamilyFriendly", video.is_family_friendly
|
||||
json.field "allowedRegions", video.allowed_regions
|
||||
json.field "genre", video.genre
|
||||
json.field "genreUrl", video.genre_url
|
||||
|
||||
json.field "author", video.author
|
||||
json.field "authorId", video.ucid
|
||||
|
@ -345,6 +345,10 @@ class Video
|
||||
allowed_regions: Array(String),
|
||||
is_family_friendly: Bool,
|
||||
genre: String,
|
||||
genre_url: {
|
||||
type: String,
|
||||
default: "/",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
@ -371,6 +375,10 @@ def get_video(id, db, refresh = true)
|
||||
begin
|
||||
video = fetch_video(id)
|
||||
video_array = video.to_a
|
||||
|
||||
# MIGRATION POINT
|
||||
video_array = video_array[0..-2]
|
||||
|
||||
args = arg_array(video_array[1..-1], 2)
|
||||
|
||||
db.exec("UPDATE videos SET (info,updated,title,views,likes,dislikes,wilson_score,\
|
||||
@ -384,6 +392,10 @@ def get_video(id, db, refresh = true)
|
||||
else
|
||||
video = fetch_video(id)
|
||||
video_array = video.to_a
|
||||
|
||||
# MIGRATION POINT
|
||||
video_array = video_array[0..-2]
|
||||
|
||||
args = arg_array(video_array)
|
||||
|
||||
db.exec("INSERT INTO videos VALUES (#{args}) ON CONFLICT (id) DO NOTHING", video_array)
|
||||
@ -490,10 +502,12 @@ def fetch_video(id)
|
||||
|
||||
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"]
|
||||
genre_url = html.xpath_node(%(//a[text()="#{genre}"])).not_nil!["href"]
|
||||
|
||||
video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description,
|
||||
nil, author, ucid, allowed_regions, is_family_friendly, genre)
|
||||
nil, author, ucid, allowed_regions, is_family_friendly, genre, genre_url)
|
||||
|
||||
return video
|
||||
end
|
||||
|
@ -55,7 +55,7 @@
|
||||
<p><i class="icon ion-ios-eye"></i> <%= number_with_separator(video.views) %></p>
|
||||
<p><i class="icon ion-ios-thumbs-up"></i> <%= number_with_separator(video.likes) %></p>
|
||||
<p><i class="icon ion-ios-thumbs-down"></i> <%= number_with_separator(video.dislikes) %></p>
|
||||
<p id="Genre">Genre: <%= video.genre %></p>
|
||||
<p id="Genre">Genre: <a href="<%= video.genre_url %>"><%= video.genre %></a></p>
|
||||
<p id="FamilyFriendly">Family Friendly? <%= video.is_family_friendly %></p>
|
||||
<p id="Wilson">Wilson Score: <%= video.wilson_score.round(4) %></p>
|
||||
<p id="Rating">Rating: <%= rating.round(4) %> / 5</p>
|
||||
|
Loading…
Reference in New Issue
Block a user