diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-09-04 09:50:19 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-09-04 09:50:19 -0500 |
| commit | 53732cdcab585da26505a41dcf0d87a36d957502 (patch) | |
| tree | ca3d4ed11a9ff86ccc3bd8936e0a0d87ca5f680e /src | |
| parent | 2ac89d5e00b44e563e7ecb56e5e1feb01076cfbc (diff) | |
| download | invidious-53732cdcab585da26505a41dcf0d87a36d957502.tar.gz invidious-53732cdcab585da26505a41dcf0d87a36d957502.tar.bz2 invidious-53732cdcab585da26505a41dcf0d87a36d957502.zip | |
Add genre URLs
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 1 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 16 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 2 |
3 files changed, 17 insertions, 2 deletions
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 @@ <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> |
