summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-09-09 14:47:26 -0500
committerOmar Roth <omarroth@hotmail.com>2018-09-09 14:47:26 -0500
commit5b2c228bb6d78e2bafc69f5d0b70320e1d9a9a6e (patch)
tree668b20debd431127ba26ac177b649880b7f2efcf
parentffab3ee79f0c7661aeb8e8c99fdea02d71a45ce4 (diff)
downloadinvidious-5b2c228bb6d78e2bafc69f5d0b70320e1d9a9a6e.tar.gz
invidious-5b2c228bb6d78e2bafc69f5d0b70320e1d9a9a6e.tar.bz2
invidious-5b2c228bb6d78e2bafc69f5d0b70320e1d9a9a6e.zip
Add 'license'
-rw-r--r--config/sql/videos.sql1
-rw-r--r--src/invidious/videos.cr19
-rw-r--r--src/invidious/views/watch.ecr3
3 files changed, 22 insertions, 1 deletions
diff --git a/config/sql/videos.sql b/config/sql/videos.sql
index dc5e75b6..5241d7a0 100644
--- a/config/sql/videos.sql
+++ b/config/sql/videos.sql
@@ -21,6 +21,7 @@ CREATE TABLE public.videos
is_family_friendly boolean,
genre text COLLATE pg_catalog."default",
genre_url text COLLATE pg_catalog."default",
+ license text COLLATE pg_catalog."default",
CONSTRAINT videos_pkey PRIMARY KEY (id)
)
WITH (
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index f81488c1..4718128b 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -346,6 +346,10 @@ class Video
is_family_friendly: Bool,
genre: String,
genre_url: String,
+ license: {
+ type: String,
+ default: "",
+ },
})
end
@@ -373,6 +377,9 @@ def get_video(id, db, refresh = true)
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,\
@@ -388,6 +395,9 @@ def get_video(id, db, refresh = true)
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)
@@ -498,8 +508,15 @@ def fetch_video(id)
genre = html.xpath_node(%q(//meta[@itemprop="genre"])).not_nil!["content"]
genre_url = html.xpath_node(%(//a[text()="#{genre}"])).not_nil!["href"]
+ license = html.xpath_node(%q(//h4[contains(text(),"License")]/parent::*/ul/li))
+ if license
+ license = license.content
+ else
+ license ||= ""
+ end
+
video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description,
- nil, author, ucid, allowed_regions, is_family_friendly, genre, genre_url)
+ nil, author, ucid, allowed_regions, is_family_friendly, genre, genre_url, license)
return video
end
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 296a545c..98c28d6a 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -56,6 +56,9 @@
<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: <a href="<%= video.genre_url %>"><%= video.genre %></a></p>
+ <% if !video.license.empty? %>
+ <p id="License">License: <%= video.license %></p>
+ <% end %>
<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>