diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-11-02 08:09:28 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-11-02 08:09:28 -0500 |
| commit | c92f6e44e708c6085eb9143e68a8a451ef641846 (patch) | |
| tree | b7103962eedf4224d47972bde2cd81b01bd98a09 | |
| parent | 19516eaa25f5d2ba723b2c28adaa40b745589880 (diff) | |
| download | invidious-c92f6e44e708c6085eb9143e68a8a451ef641846.tar.gz invidious-c92f6e44e708c6085eb9143e68a8a451ef641846.tar.bz2 invidious-c92f6e44e708c6085eb9143e68a8a451ef641846.zip | |
Update keywords and view_count
| -rw-r--r-- | src/invidious.cr | 6 | ||||
| -rw-r--r-- | src/invidious/videos.cr | 13 | ||||
| -rw-r--r-- | src/invidious/views/channel.ecr | 2 | ||||
| -rw-r--r-- | src/invidious/views/watch.ecr | 4 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 0ad09e2f..2924c894 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2087,11 +2087,7 @@ get "/api/v1/videos/:id" do |env| json.field "descriptionHtml", video.description json.field "published", video.published.epoch json.field "publishedText", "#{recode_date(video.published)} ago" - json.field "keywords" do - json.array do - video.info["keywords"].split(",").each { |keyword| json.string keyword } - end - end + json.field "keywords", video.keywords json.field "viewCount", video.views json.field "likeCount", video.likes diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 26aa487e..d21806d5 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -262,6 +262,10 @@ class Video end end + def keywords + return self.player_response["videoDetails"]["keywords"].as_a + end + def fmt_stream(decrypt_function) streams = [] of HTTP::Params self.info["url_encoded_fmt_stream_map"].split(",") do |string| @@ -638,16 +642,19 @@ def fetch_video(id, proxies) end title = info["title"] - views = info["view_count"].to_i64 author = info["author"] ucid = info["ucid"] + views = html.xpath_node(%q(//meta[@itemprop="interactionCount"])) + views = views.try &.["content"].to_i64? + views ||= 0_i64 + likes = html.xpath_node(%q(//button[@title="I like this"]/span)) - likes = likes.try &.content.delete(",").try &.to_i + likes = likes.try &.content.delete(",").try &.to_i? likes ||= 0 dislikes = html.xpath_node(%q(//button[@title="I dislike this"]/span)) - dislikes = dislikes.try &.content.delete(",").try &.to_i + dislikes = dislikes.try &.content.delete(",").try &.to_i? dislikes ||= 0 description = html.xpath_node(%q(//p[@id="eow-description"])) diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr index d8cc4a8d..b9b75ef5 100644 --- a/src/invidious/views/channel.ecr +++ b/src/invidious/views/channel.ecr @@ -106,4 +106,4 @@ function unsubscribe() { } } } -</script>
\ No newline at end of file +</script> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 3cb6328b..fe785fb7 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -1,7 +1,7 @@ <% content_for "header" do %> <meta name="thumbnail" content="<%= thumbnail %>"> <meta name="description" content="<%= description %>"> -<meta name="keywords" content="<%= video.info["keywords"] %>"> +<meta name="keywords" content="<%= video.keywords.join(",") %>"> <meta property="og:site_name" content="Invidious"> <meta property="og:url" content="<%= host_url %>/watch?v=<%= video.id %>"> <meta property="og:title" content="<%= HTML.escape(video.title) %>"> @@ -451,4 +451,4 @@ function get_youtube_replies(target, load_more) { get_youtube_comments(); <% end %> -</script>
\ No newline at end of file +</script> |
