diff --git a/src/invidious.cr b/src/invidious.cr index ba5d79e6..9c9049fc 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -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 diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 7efecebf..e0bcd64c 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -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 diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 55005ca8..d52d9092 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -55,7 +55,7 @@

<%= number_with_separator(video.views) %>

<%= number_with_separator(video.likes) %>

<%= number_with_separator(video.dislikes) %>

-

Genre: <%= video.genre %>

+

Genre: <%= video.genre %>

Family Friendly? <%= video.is_family_friendly %>

Wilson Score: <%= video.wilson_score.round(4) %>

Rating: <%= rating.round(4) %> / 5