summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/channels/community.cr53
-rw-r--r--src/invidious/comments.cr39
-rw-r--r--src/invidious/helpers/serialized_yt_data.cr1
-rw-r--r--src/invidious/jsonify/api_v1/video_json.cr15
-rw-r--r--src/invidious/routes/account.cr1
-rw-r--r--src/invidious/routes/api/v1/authenticated.cr82
-rw-r--r--src/invidious/routes/api/v1/channels.cr2
-rw-r--r--src/invidious/routes/api/v1/misc.cr27
-rw-r--r--src/invidious/routes/subscriptions.cr29
-rw-r--r--src/invidious/routing.cr9
-rw-r--r--src/invidious/trending.cr7
-rw-r--r--src/invidious/user/exports.cr35
-rw-r--r--src/invidious/videos.cr7
-rw-r--r--src/invidious/videos/music.cr3
-rw-r--r--src/invidious/videos/parser.cr10
-rw-r--r--src/invidious/views/add_playlist_items.ecr2
-rw-r--r--src/invidious/views/channel.ecr2
-rw-r--r--src/invidious/views/components/item.ecr17
-rw-r--r--src/invidious/views/edit_playlist.ecr2
-rw-r--r--src/invidious/views/feeds/playlists.ecr2
-rw-r--r--src/invidious/views/feeds/popular.ecr2
-rw-r--r--src/invidious/views/feeds/subscriptions.ecr2
-rw-r--r--src/invidious/views/feeds/trending.ecr2
-rw-r--r--src/invidious/views/hashtag.ecr2
-rw-r--r--src/invidious/views/playlist.ecr2
-rw-r--r--src/invidious/views/search.ecr2
-rw-r--r--src/invidious/views/watch.ecr6
27 files changed, 315 insertions, 48 deletions
diff --git a/src/invidious/channels/community.cr b/src/invidious/channels/community.cr
index 13af2d8b..da8be6ea 100644
--- a/src/invidious/channels/community.cr
+++ b/src/invidious/channels/community.cr
@@ -1,3 +1,5 @@
+private IMAGE_QUALITIES = {320, 560, 640, 1280, 2000}
+
# TODO: Add "sort_by"
def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
response = YT_POOL.client &.get("/channel/#{ucid}/community?gl=US&hl=en")
@@ -75,10 +77,9 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
json.field "author", author
json.field "authorThumbnails" do
json.array do
- qualities = {32, 48, 76, 100, 176, 512}
author_thumbnail = post["authorThumbnail"]["thumbnails"].as_a[0]["url"].as_s
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", author_thumbnail.gsub(/s\d+-/, "s#{quality}-")
json.field "width", quality
@@ -108,6 +109,8 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
like_count = post["actionButtons"]["commentActionButtonsRenderer"]["likeButton"]["toggleButtonRenderer"]["accessibilityData"]["accessibilityData"]["label"]
.try &.as_s.gsub(/\D/, "").to_i? || 0
+ reply_count = short_text_to_number(post.dig?("actionButtons", "commentActionButtonsRenderer", "replyButton", "buttonRenderer", "text", "simpleText").try &.as_s || "0")
+
json.field "content", html_to_content(content_html)
json.field "contentHtml", content_html
@@ -115,6 +118,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
json.field "likeCount", like_count
+ json.field "replyCount", reply_count
json.field "commentId", post["postId"]? || post["commentId"]? || ""
json.field "authorIsChannelOwner", post["authorEndpoint"]["browseEndpoint"]["browseId"] == ucid
@@ -174,9 +178,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
aspect_ratio = (width.to_f / height.to_f)
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
- qualities = {320, 560, 640, 1280, 2000}
-
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
json.field "width", quality
@@ -185,10 +187,39 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
end
end
end
- # TODO
- # when .has_key?("pollRenderer")
- # attachment = attachment["pollRenderer"]
- # json.field "type", "poll"
+ when .has_key?("pollRenderer")
+ attachment = attachment["pollRenderer"]
+ json.field "type", "poll"
+ json.field "totalVotes", short_text_to_number(attachment["totalVotes"]["simpleText"].as_s.split(" ")[0])
+ json.field "choices" do
+ json.array do
+ attachment["choices"].as_a.each do |choice|
+ json.object do
+ json.field "text", choice.dig("text", "runs", 0, "text").as_s
+ # A choice can have an image associated with it.
+ # Ex post: https://www.youtube.com/post/UgkxD4XavXUD4NQiddJXXdohbwOwcVqrH9Re
+ if choice["image"]?
+ thumbnail = choice["image"]["thumbnails"][0].as_h
+ width = thumbnail["width"].as_i
+ height = thumbnail["height"].as_i
+ aspect_ratio = (width.to_f / height.to_f)
+ url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
+ json.field "image" do
+ json.array do
+ IMAGE_QUALITIES.each do |quality|
+ json.object do
+ json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
+ json.field "width", quality
+ json.field "height", (quality / aspect_ratio).ceil.to_i
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
when .has_key?("postMultiImageRenderer")
attachment = attachment["postMultiImageRenderer"]
json.field "type", "multiImage"
@@ -202,9 +233,7 @@ def fetch_channel_community(ucid, continuation, locale, format, thin_mode)
aspect_ratio = (width.to_f / height.to_f)
url = thumbnail["url"].as_s.gsub(/=w\d+-h\d+(-p)?(-nd)?(-df)?(-rwa)?/, "=s640")
- qualities = {320, 560, 640, 1280, 2000}
-
- qualities.each do |quality|
+ IMAGE_QUALITIES.each do |quality|
json.object do
json.field "url", url.gsub(/=s\d+/, "=s#{quality}")
json.field "width", quality
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index d691ca36..b15d63d4 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -181,6 +181,12 @@ def fetch_youtube_comments(id, cursor, format, locale, thin_mode, region, sort_b
json.field "content", html_to_content(content_html)
json.field "contentHtml", content_html
+ json.field "isPinned", (node_comment["pinnedCommentBadge"]? != nil)
+ json.field "isSponsor", (node_comment["sponsorCommentBadge"]? != nil)
+ if node_comment["sponsorCommentBadge"]?
+ # Sponsor icon thumbnails always have one object and there's only ever the url property in it
+ json.field "sponsorIconUrl", node_comment.dig("sponsorCommentBadge", "sponsorCommentBadgeRenderer", "customBadge", "thumbnails", 0, "url").to_s
+ end
json.field "published", published.to_unix
json.field "publishedText", translate(locale, "`x` ago", recode_date(published, locale))
@@ -322,11 +328,21 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)
end
author_name = HTML.escape(child["author"].as_s)
+ sponsor_icon = ""
if child["verified"]?.try &.as_bool && child["authorIsChannelOwner"]?.try &.as_bool
author_name += "&nbsp;<i class=\"icon ion ion-md-checkmark-circle\"></i>"
elsif child["verified"]?.try &.as_bool
author_name += "&nbsp;<i class=\"icon ion ion-md-checkmark\"></i>"
end
+
+ if child["isSponsor"]?.try &.as_bool
+ sponsor_icon = String.build do |str|
+ str << %(<img alt="" )
+ str << %(src="/ggpht) << URI.parse(child["sponsorIconUrl"].as_s).request_target << "\" "
+ str << %(title=") << translate(locale, "Channel Sponsor") << "\" "
+ str << %(width="16" height="16" />)
+ end
+ end
html << <<-END_HTML
<div class="pure-g" style="width:100%">
<div class="channel-profile pure-u-4-24 pure-u-md-2-24">
@@ -337,6 +353,7 @@ def template_youtube_comments(comments, locale, thin_mode, is_replies = false)
<b>
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{author_name}</a>
</b>
+ #{sponsor_icon}
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
END_HTML
@@ -670,8 +687,30 @@ def content_to_comment_html(content, video_id : String? = "")
end
text = "<b>#{text}</b>" if run["bold"]?
+ text = "<s>#{text}</s>" if run["strikethrough"]?
text = "<i>#{text}</i>" if run["italics"]?
+ # check for custom emojis
+ if run["emoji"]?
+ if run["emoji"]["isCustomEmoji"]?.try &.as_bool
+ if emojiImage = run.dig?("emoji", "image")
+ emojiAlt = emojiImage.dig?("accessibility", "accessibilityData", "label").try &.as_s || text
+ emojiThumb = emojiImage["thumbnails"][0]
+ text = String.build do |str|
+ str << %(<img alt=") << emojiAlt << "\" "
+ str << %(src="/ggpht) << URI.parse(emojiThumb["url"].as_s).request_target << "\" "
+ str << %(title=") << emojiAlt << "\" "
+ str << %(width=") << emojiThumb["width"] << "\" "
+ str << %(height=") << emojiThumb["height"] << "\" "
+ str << %(class="channel-emoji"/>)
+ end
+ else
+ # Hide deleted channel emoji
+ text = ""
+ end
+ end
+ end
+
text
end
diff --git a/src/invidious/helpers/serialized_yt_data.cr b/src/invidious/helpers/serialized_yt_data.cr
index 635f0984..c1874780 100644
--- a/src/invidious/helpers/serialized_yt_data.cr
+++ b/src/invidious/helpers/serialized_yt_data.cr
@@ -74,6 +74,7 @@ struct SearchVideo
json.field "author", self.author
json.field "authorId", self.ucid
json.field "authorUrl", "/channel/#{self.ucid}"
+ json.field "authorVerified", self.author_verified
json.field "videoThumbnails" do
Invidious::JSONify::APIv1.thumbnails(json, self.id)
diff --git a/src/invidious/jsonify/api_v1/video_json.cr b/src/invidious/jsonify/api_v1/video_json.cr
index a2b1a35c..fe4b5223 100644
--- a/src/invidious/jsonify/api_v1/video_json.cr
+++ b/src/invidious/jsonify/api_v1/video_json.cr
@@ -197,6 +197,21 @@ module Invidious::JSONify::APIv1
end
end
+ if !video.music.empty?
+ json.field "musicTracks" do
+ json.array do
+ video.music.each do |music|
+ json.object do
+ json.field "song", music.song
+ json.field "artist", music.artist
+ json.field "album", music.album
+ json.field "license", music.license
+ end
+ end
+ end
+ end
+ end
+
json.field "recommendedVideos" do
json.array do
video.related_videos.each do |rv|
diff --git a/src/invidious/routes/account.cr b/src/invidious/routes/account.cr
index e6a70ed2..5aa4452c 100644
--- a/src/invidious/routes/account.cr
+++ b/src/invidious/routes/account.cr
@@ -262,6 +262,7 @@ module Invidious::Routes::Account
end
query["token"] = access_token
+ query["username"] = URI.encode_path_segment(user.email)
url.query = query.to_s
env.redirect url.to_s
diff --git a/src/invidious/routes/api/v1/authenticated.cr b/src/invidious/routes/api/v1/authenticated.cr
index 421355bb..ce2ee812 100644
--- a/src/invidious/routes/api/v1/authenticated.cr
+++ b/src/invidious/routes/api/v1/authenticated.cr
@@ -31,6 +31,88 @@ module Invidious::Routes::API::V1::Authenticated
env.response.status_code = 204
end
+ def self.export_invidious(env)
+ env.response.content_type = "application/json"
+ user = env.get("user").as(User)
+
+ return Invidious::User::Export.to_invidious(user)
+ end
+
+ def self.import_invidious(env)
+ user = env.get("user").as(User)
+
+ begin
+ if body = env.request.body
+ body = env.request.body.not_nil!.gets_to_end
+ else
+ body = "{}"
+ end
+ Invidious::User::Import.from_invidious(user, body)
+ rescue
+ end
+
+ env.response.status_code = 204
+ end
+
+ def self.get_history(env)
+ env.response.content_type = "application/json"
+ user = env.get("user").as(User)
+
+ page = env.params.query["page"]?.try &.to_i?.try &.clamp(0, Int32::MAX)
+ page ||= 1
+
+ max_results = env.params.query["max_results"]?.try &.to_i?.try &.clamp(0, MAX_ITEMS_PER_PAGE)
+ max_results ||= user.preferences.max_results
+ max_results ||= CONFIG.default_user_preferences.max_results
+
+ start_index = (page - 1) * max_results
+ if user.watched[start_index]?
+ watched = user.watched.reverse[start_index, max_results]
+ end
+ watched ||= [] of String
+
+ return watched.to_json
+ end
+
+ def self.mark_watched(env)
+ user = env.get("user").as(User)
+
+ if !user.preferences.watch_history
+ return error_json(409, "Watch history is disabled in preferences.")
+ end
+
+ id = env.params.url["id"]
+ if !id.match(/^[a-zA-Z0-9_-]{11}$/)
+ return error_json(400, "Invalid video id.")
+ end
+
+ Invidious::Database::Users.mark_watched(user, id)
+ env.response.status_code = 204
+ end
+
+ def self.mark_unwatched(env)
+ user = env.get("user").as(User)
+
+ if !user.preferences.watch_history
+ return error_json(409, "Watch history is disabled in preferences.")
+ end
+
+ id = env.params.url["id"]
+ if !id.match(/^[a-zA-Z0-9_-]{11}$/)
+ return error_json(400, "Invalid video id.")
+ end
+
+ Invidious::Database::Users.mark_unwatched(user, id)
+ env.response.status_code = 204
+ end
+
+ def self.clear_history(env)
+ user = env.get("user").as(User)
+
+ Invidious::Database::Users.clear_watch_history(user)
+ env.response.status_code = 204
+ end
+
def self.feed(env)
env.response.content_type = "application/json"
diff --git a/src/invidious/routes/api/v1/channels.cr b/src/invidious/routes/api/v1/channels.cr
index ca2b2734..bcb4db2c 100644
--- a/src/invidious/routes/api/v1/channels.cr
+++ b/src/invidious/routes/api/v1/channels.cr
@@ -89,6 +89,8 @@ module Invidious::Routes::API::V1::Channels
json.field "descriptionHtml", channel.description_html
json.field "allowedRegions", channel.allowed_regions
+ json.field "tabs", channel.tabs
+ json.field "authorVerified", channel.verified
json.field "latestVideos" do
json.array do
diff --git a/src/invidious/routes/api/v1/misc.cr b/src/invidious/routes/api/v1/misc.cr
index 43d360e6..e499f4d6 100644
--- a/src/invidious/routes/api/v1/misc.cr
+++ b/src/invidious/routes/api/v1/misc.cr
@@ -150,4 +150,31 @@ module Invidious::Routes::API::V1::Misc
response
end
+
+ # resolve channel and clip urls, return the UCID
+ def self.resolve_url(env)
+ env.response.content_type = "application/json"
+ url = env.params.query["url"]?
+
+ return error_json(400, "Missing URL to resolve") if !url
+
+ begin
+ resolved_url = YoutubeAPI.resolve_url(url.as(String))
+ endpoint = resolved_url["endpoint"]
+ pageType = endpoint.dig?("commandMetadata", "webCommandMetadata", "webPageType").try &.as_s || ""
+ if resolved_ucid = endpoint.dig?("watchEndpoint", "videoId")
+ elsif resolved_ucid = endpoint.dig?("browseEndpoint", "browseId")
+ elsif pageType == "WEB_PAGE_TYPE_UNKNOWN"
+ return error_json(400, "Unknown url")
+ end
+ rescue ex
+ return error_json(500, ex)
+ end
+ JSON.build do |json|
+ json.object do
+ json.field "ucid", resolved_ucid.try &.as_s || ""
+ json.field "pageType", pageType
+ end
+ end
+ end
end
diff --git a/src/invidious/routes/subscriptions.cr b/src/invidious/routes/subscriptions.cr
index 7b1fa876..0704c05e 100644
--- a/src/invidious/routes/subscriptions.cr
+++ b/src/invidious/routes/subscriptions.cr
@@ -104,33 +104,8 @@ module Invidious::Routes::Subscriptions
if format == "json"
env.response.content_type = "application/json"
env.response.headers["content-disposition"] = "attachment"
- playlists = Invidious::Database::Playlists.select_like_iv(user.email)
-
- return JSON.build do |json|
- json.object do
- json.field "subscriptions", user.subscriptions
- json.field "watch_history", user.watched
- json.field "preferences", user.preferences
- json.field "playlists" do
- json.array do
- playlists.each do |playlist|
- json.object do
- json.field "title", playlist.title
- json.field "description", html_to_content(playlist.description_html)
- json.field "privacy", playlist.privacy.to_s
- json.field "videos" do
- json.array do
- Invidious::Database::PlaylistVideos.select_ids(playlist.id, playlist.index, limit: 500).each do |video_id|
- json.string video_id
- end
- end
- end
- end
- end
- end
- end
- end
- end
+
+ return Invidious::User::Export.to_invidious(user)
else
env.response.content_type = "application/xml"
env.response.headers["content-disposition"] = "attachment"
diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr
index 157e6de7..9e2ade3d 100644
--- a/src/invidious/routing.cr
+++ b/src/invidious/routing.cr
@@ -254,6 +254,14 @@ module Invidious::Routing
get "/api/v1/auth/preferences", {{namespace}}::Authenticated, :get_preferences
post "/api/v1/auth/preferences", {{namespace}}::Authenticated, :set_preferences
+ get "/api/v1/auth/export/invidious", {{namespace}}::Authenticated, :export_invidious
+ post "/api/v1/auth/import/invidious", {{namespace}}::Authenticated, :import_invidious
+
+ get "/api/v1/auth/history", {{namespace}}::Authenticated, :get_history
+ post "/api/v1/auth/history/:id", {{namespace}}::Authenticated, :mark_watched
+ delete "/api/v1/auth/history/:id", {{namespace}}::Authenticated, :mark_unwatched
+ delete "/api/v1/auth/history", {{namespace}}::Authenticated, :clear_history
+
get "/api/v1/auth/feed", {{namespace}}::Authenticated, :feed
get "/api/v1/auth/subscriptions", {{namespace}}::Authenticated, :get_subscriptions
@@ -281,6 +289,7 @@ module Invidious::Routing
get "/api/v1/playlists/:plid", {{namespace}}::Misc, :get_playlist
get "/api/v1/auth/playlists/:plid", {{namespace}}::Misc, :get_playlist
get "/api/v1/mixes/:rdid", {{namespace}}::Misc, :mixes
+ get "/api/v1/resolveurl", {{namespace}}::Misc, :resolve_url
{% end %}
end
end
diff --git a/src/invidious/trending.cr b/src/invidious/trending.cr
index 1f957081..134eb437 100644
--- a/src/invidious/trending.cr
+++ b/src/invidious/trending.cr
@@ -4,11 +4,12 @@ def fetch_trending(trending_type, region, locale)
plid = nil
- if trending_type == "Music"
+ case trending_type.try &.downcase
+ when "music"
params = "4gINGgt5dG1hX2NoYXJ0cw%3D%3D"
- elsif trending_type == "Gaming"
+ when "gaming"
params = "4gIcGhpnYW1pbmdfY29ycHVzX21vc3RfcG9wdWxhcg%3D%3D"
- elsif trending_type == "Movies"
+ when "movies"
params = "4gIKGgh0cmFpbGVycw%3D%3D"
else # Default
params = ""
diff --git a/src/invidious/user/exports.cr b/src/invidious/user/exports.cr
new file mode 100644
index 00000000..b52503c9
--- /dev/null
+++ b/src/invidious/user/exports.cr
@@ -0,0 +1,35 @@
+struct Invidious::User
+ module Export
+ extend self
+
+ def to_invidious(user : User)
+ playlists = Invidious::Database::Playlists.select_like_iv(user.email)
+
+ return JSON.build do |json|
+ json.object do
+ json.field "subscriptions", user.subscriptions
+ json.field "watch_history", user.watched
+ json.field "preferences", user.preferences
+ json.field "playlists" do
+ json.array do
+ playlists.each do |playlist|
+ json.object do
+ json.field "title", playlist.title
+ json.field "description", html_to_content(playlist.description_html)
+ json.field "privacy", playlist.privacy.to_s
+ json.field "videos" do
+ json.array do
+ Invidious::Database::PlaylistVideos.select_ids(playlist.id, playlist.index, limit: CONFIG.playlist_length_limit).each do |video_id|
+ json.string video_id
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end # module
+end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 436ac82d..0038a97a 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -249,7 +249,12 @@ struct Video
def music : Array(VideoMusic)
info["music"].as_a.map { |music_json|
- VideoMusic.new(music_json["album"].as_s, music_json["artist"].as_s, music_json["license"].as_s)
+ VideoMusic.new(
+ music_json["song"].as_s,
+ music_json["album"].as_s,
+ music_json["artist"].as_s,
+ music_json["license"].as_s
+ )
}
end
diff --git a/src/invidious/videos/music.cr b/src/invidious/videos/music.cr
index 402ae46f..08d88a3e 100644
--- a/src/invidious/videos/music.cr
+++ b/src/invidious/videos/music.cr
@@ -3,10 +3,11 @@ require "json"
struct VideoMusic
include JSON::Serializable
+ property song : String
property album : String
property artist : String
property license : String
- def initialize(@album : String, @artist : String, @license : String)
+ def initialize(@song : String, @album : String, @artist : String, @license : String)
end
end
diff --git a/src/invidious/videos/parser.cr b/src/invidious/videos/parser.cr
index cf43f1be..7cfc7ea7 100644
--- a/src/invidious/videos/parser.cr
+++ b/src/invidious/videos/parser.cr
@@ -325,17 +325,25 @@ def parse_video_info(video_id : String, player_response : Hash(String, JSON::Any
album = nil
music_license = nil
+ # Used when the video has multiple songs
+ if song_title = music_desc.dig?("carouselLockupRenderer", "videoLockup", "compactVideoRenderer", "title")
+ # "simpleText" for plain text / "runs" when song has a link
+ song = song_title["simpleText"]? || song_title.dig("runs", 0, "text")
+ end
+
music_desc.dig?("carouselLockupRenderer", "infoRows").try &.as_a.each do |desc|
desc_title = extract_text(desc.dig?("infoRowRenderer", "title"))
if desc_title == "ARTIST"
artist = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
+ elsif desc_title == "SONG"
+ song = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
elsif desc_title == "ALBUM"
album = extract_text(desc.dig?("infoRowRenderer", "defaultMetadata"))
elsif desc_title == "LICENSES"
music_license = extract_text(desc.dig?("infoRowRenderer", "expandedMetadata"))
end
end
- music_list << VideoMusic.new(album.to_s, artist.to_s, music_license.to_s)
+ music_list << VideoMusic.new(song.to_s, album.to_s, artist.to_s, music_license.to_s)
end
# Author infos
diff --git a/src/invidious/views/add_playlist_items.ecr b/src/invidious/views/add_playlist_items.ecr
index 22870317..bcba74cf 100644
--- a/src/invidious/views/add_playlist_items.ecr
+++ b/src/invidious/views/add_playlist_items.ecr
@@ -39,6 +39,8 @@
<% end %>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<% if query %>
<%- query_encoded = URI.encode_www_form(query.text, space_to_plus: true) -%>
<div class="pure-g h-box">
diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr
index a29315ef..6e62a471 100644
--- a/src/invidious/views/channel.ecr
+++ b/src/invidious/views/channel.ecr
@@ -49,6 +49,8 @@
<% end %>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-md-4-5"></div>
<div class="pure-u-1 pure-u-lg-1-5" style="text-align:right">
diff --git a/src/invidious/views/components/item.ecr b/src/invidious/views/components/item.ecr
index 0e959ff2..fa12374f 100644
--- a/src/invidious/views/components/item.ecr
+++ b/src/invidious/views/components/item.ecr
@@ -1,3 +1,5 @@
+<% item_watched = !item.is_a?(SearchChannel | SearchPlaylist | InvidiousPlaylist | Category) && env.get?("user").try &.as(User).watched.index(item.id) != nil %>
+
<div class="pure-u-1 pure-u-md-1-4">
<div class="h-box">
<% case item when %>
@@ -40,6 +42,11 @@
<% if item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
+
+ <% if item_watched %>
+ <div class="watched-overlay"></div>
+ <div class="watched-indicator" data-length="<%= item.length_seconds %>" data-id="<%= item.id %>"></div>
+ <% end %>
</div>
<% end %>
<p dir="auto"><%= HTML.escape(item.title) %></p>
@@ -67,6 +74,11 @@
<% elsif item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
+
+ <% if item_watched %>
+ <div class="watched-overlay"></div>
+ <div class="watched-indicator" data-length="<%= item.length_seconds %>" data-id="<%= item.id %>"></div>
+ <% end %>
</div>
<% end %>
<p dir="auto"><%= HTML.escape(item.title) %></p>
@@ -124,6 +136,11 @@
<% elsif item.length_seconds != 0 %>
<p class="length"><%= recode_length_seconds(item.length_seconds) %></p>
<% end %>
+
+ <% if item_watched %>
+ <div class="watched-overlay"></div>
+ <div class="watched-indicator" data-length="<%= item.length_seconds %>" data-id="<%= item.id %>"></div>
+ <% end %>
</div>
<% end %>
<p dir="auto"><%= HTML.escape(item.title) %></p>
diff --git a/src/invidious/views/edit_playlist.ecr b/src/invidious/views/edit_playlist.ecr
index 89819ef0..548104c8 100644
--- a/src/invidious/views/edit_playlist.ecr
+++ b/src/invidious/views/edit_playlist.ecr
@@ -62,6 +62,8 @@
<% end %>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<% if page > 1 %>
diff --git a/src/invidious/views/feeds/playlists.ecr b/src/invidious/views/feeds/playlists.ecr
index a59344c4..e52a7707 100644
--- a/src/invidious/views/feeds/playlists.ecr
+++ b/src/invidious/views/feeds/playlists.ecr
@@ -32,3 +32,5 @@
<%= rendered "components/item" %>
<% end %>
</div>
+
+<script src="/js/watched_indicator.js"></script>
diff --git a/src/invidious/views/feeds/popular.ecr b/src/invidious/views/feeds/popular.ecr
index e77f35b9..5fbe539c 100644
--- a/src/invidious/views/feeds/popular.ecr
+++ b/src/invidious/views/feeds/popular.ecr
@@ -16,3 +16,5 @@
<%= rendered "components/item" %>
<% end %>
</div>
+
+<script src="/js/watched_indicator.js"></script>
diff --git a/src/invidious/views/feeds/subscriptions.ecr b/src/invidious/views/feeds/subscriptions.ecr
index 76f2f2bd..9c69c5b0 100644
--- a/src/invidious/views/feeds/subscriptions.ecr
+++ b/src/invidious/views/feeds/subscriptions.ecr
@@ -62,6 +62,8 @@
<% end %>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<% if page > 1 %>
diff --git a/src/invidious/views/feeds/trending.ecr b/src/invidious/views/feeds/trending.ecr
index a35c4ee3..7dc416c6 100644
--- a/src/invidious/views/feeds/trending.ecr
+++ b/src/invidious/views/feeds/trending.ecr
@@ -45,3 +45,5 @@
<%= rendered "components/item" %>
<% end %>
</div>
+
+<script src="/js/watched_indicator.js"></script>
diff --git a/src/invidious/views/hashtag.ecr b/src/invidious/views/hashtag.ecr
index 0ecfe832..3351c21c 100644
--- a/src/invidious/views/hashtag.ecr
+++ b/src/invidious/views/hashtag.ecr
@@ -24,6 +24,8 @@
<%- end -%>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<%- if page > 1 -%>
diff --git a/src/invidious/views/playlist.ecr b/src/invidious/views/playlist.ecr
index df3112db..a04acf4c 100644
--- a/src/invidious/views/playlist.ecr
+++ b/src/invidious/views/playlist.ecr
@@ -106,6 +106,8 @@
<% end %>
</div>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<% if page > 1 %>
diff --git a/src/invidious/views/search.ecr b/src/invidious/views/search.ecr
index 254449a1..a7469e36 100644
--- a/src/invidious/views/search.ecr
+++ b/src/invidious/views/search.ecr
@@ -37,6 +37,8 @@
</div>
<%- end -%>
+<script src="/js/watched_indicator.js"></script>
+
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-lg-1-5">
<%- if query.page > 1 -%>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 666eb3b0..ce92a546 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -248,9 +248,9 @@ we're going to need to do it here in order to allow for translations.
<div id="music-description-box">
<% video.music.each do |music| %>
<div class="music-item">
- <p id="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
- <p id="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
- <p id="music-license"><%= translate(locale, "License: ") %><%= music.license %></p>
+ <p class="music-song"><%= translate(locale, "Song: ") %><%= music.song %></p>
+ <p class="music-artist"><%= translate(locale, "Artist: ") %><%= music.artist %></p>
+ <p class="music-album"><%= translate(locale, "Album: ") %><%= music.album %></p>
</div>
<% end %>
</div>