summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-03-16 19:45:37 -0500
committerOmar Roth <omarroth@hotmail.com>2018-03-16 19:45:37 -0500
commit6b5c9cfaf1a7177c1779856c9631a5fa911a8705 (patch)
tree9c44e52d74f6fea6d3095b8dc48646e1e3fa52f3
parent997449ab4b11124d11e638294ea35a4018343148 (diff)
downloadinvidious-6b5c9cfaf1a7177c1779856c9631a5fa911a8705.tar.gz
invidious-6b5c9cfaf1a7177c1779856c9631a5fa911a8705.tar.bz2
invidious-6b5c9cfaf1a7177c1779856c9631a5fa911a8705.zip
Add "language" to postgres
-rw-r--r--src/helpers.cr18
-rw-r--r--videos.sql1
2 files changed, 14 insertions, 5 deletions
diff --git a/src/helpers.cr b/src/helpers.cr
index c54dfb22..e01b847a 100644
--- a/src/helpers.cr
+++ b/src/helpers.cr
@@ -51,6 +51,7 @@ class Video
wilson_score: Float64,
published: Time,
description: String,
+ language: String?,
})
end
@@ -171,7 +172,7 @@ def fetch_video(id, client)
end
end
- video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description)
+ video = Video.new(id, info, Time.now, title, views, likes, dislikes, wilson_score, published, description, nil)
return video
end
@@ -261,12 +262,19 @@ def rank_videos(db, n, pool, filter)
video = get_video(id, client, db)
pool << client
- description = XML.parse(video.description)
- content = [video.title, description.content].join(" ")
+ if video.language
+ language = video.language
+ else
+ description = XML.parse(video.description)
+ content = [video.title, description.content].join(" ")
- results = DetectLanguage.detect(content)
+ results = DetectLanguage.detect(content)
+ language = results[0].language
- if results[0].language == "en"
+ db.exec("UPDATE videos SET language = $1 WHERE id = $2", language, id)
+ end
+
+ if language == "en"
language_list << id
end
end
diff --git a/videos.sql b/videos.sql
index 9a434096..444de280 100644
--- a/videos.sql
+++ b/videos.sql
@@ -12,6 +12,7 @@ CREATE TABLE public.videos
wilson_score double precision,
published timestamp with time zone,
description text COLLATE pg_catalog."default",
+ language text COLLATE pg_catalog."default",
CONSTRAINT videos_pkey PRIMARY KEY (id)
)
WITH (