summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-04-07 20:09:20 -0500
committerOmar Roth <omarroth@hotmail.com>2018-04-07 20:09:20 -0500
commit44ebf0ed8eff2ba24c182355c1a67d8e1f6d5042 (patch)
tree6f2d300ed3d60cf935a140058f52ebf8fcf8db5e /src
parent86bf5a62668533450ddb775efbe935c03a812fa3 (diff)
downloadinvidious-44ebf0ed8eff2ba24c182355c1a67d8e1f6d5042.tar.gz
invidious-44ebf0ed8eff2ba24c182355c1a67d8e1f6d5042.tar.bz2
invidious-44ebf0ed8eff2ba24c182355c1a67d8e1f6d5042.zip
Add detection for ad tags and category
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr24
-rw-r--r--src/views/watch.ecr12
2 files changed, 35 insertions, 1 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index c0b22d69..c89cfc2e 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -296,6 +296,30 @@ get "/watch" do |env|
calculated_rating = 0.0
end
+ if video.info["ad_slots"]?
+ ad_slots = video.info["ad_slots"].split(",")
+ ad_slots.sort_by! { |a| a.to_i }
+ ad_slots = ad_slots.join(", ")
+ end
+
+ if video.info["enabled_engage_types"]?
+ engage_types = video.info["enabled_engage_types"].split(",")
+ engage_types = engage_types.join(", ")
+ end
+
+ if video.info["ad_tag"]?
+ ad_tag = URI.parse(video.info["ad_tag"])
+ ad_query = HTTP::Params.parse(ad_tag.query.not_nil!)
+
+ ad_category = URI.unescape(ad_query["iu"])
+ ad_category = ad_category.lstrip("/4061/").split(".")[-1]
+
+ ad_query = HTTP::Params.parse(ad_query["scp"])
+
+ k2 = URI.unescape(ad_query["k2"]).split(",")
+ k2 = k2.join(", ")
+ end
+
reddit_client = make_client(REDDIT_URL)
headers = HTTP::Headers{"User-Agent" => "web:invidio.us:v0.1.0 (by /u/omarroth)"}
begin
diff --git a/src/views/watch.ecr b/src/views/watch.ecr
index 82065397..ce9f4b53 100644
--- a/src/views/watch.ecr
+++ b/src/views/watch.ecr
@@ -121,13 +121,23 @@ function toggle_comments(target) {
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-5">
- <div class="h-box">
+ <div style="overflow-wrap:break-word; word-wrap:break-word;" class="h-box">
<p><i class="fa fa-eye" aria-hidden="true"></i> <%= number_with_separator(video.views) %></p>
<p><i class="fa fa-thumbs-up" aria-hidden="true"></i> <%= number_with_separator(video.likes) %></p>
<p><i class="fa fa-thumbs-down" aria-hidden="true"></i> <%= number_with_separator(video.dislikes) %></p>
<p id="Wilson">Wilson Score : <%= video.wilson_score.round(4) %></p>
<p id="Rating">Rating : <%= rating.round(4) %> / 5</p>
<p id="Engagement">Engagement : <%= engagement.round(2) %>%</p>
+ <% if ad_slots %>
+ <p>Ad Slots : <%= ad_slots %></p>
+ <% end %>
+ <% if engage_types %>
+ <p>Engage Types : <%= engage_types %></p>
+ <% end %>
+ <% if ad_tag %>
+ <p>Ad Category : <%= ad_category %></p>
+ <p>Ad Tags(?) : <%= k2 %></p>
+ <% end %>
</div>
</div>