mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-08-12 08:08:24 +00:00
xd
This commit is contained in:
parent
1f94a0e1ec
commit
31e9773b0c
@ -79,6 +79,16 @@ module Invidious::Database::Users
|
|||||||
PG_DB.exec(request, user.email)
|
PG_DB.exec(request, user.email)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_watched(user : User)
|
||||||
|
request = <<-SQL
|
||||||
|
SELECT watched
|
||||||
|
from users
|
||||||
|
where email = $1
|
||||||
|
SQL
|
||||||
|
|
||||||
|
PG_DB.query_one?(request, user.email, &.read(Array(JSON::Any)))
|
||||||
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
# Update (channels)
|
# Update (channels)
|
||||||
# -------------------
|
# -------------------
|
||||||
|
@ -124,7 +124,7 @@ module Invidious::Routes::Embed
|
|||||||
user = env.get?("user").try &.as(User)
|
user = env.get?("user").try &.as(User)
|
||||||
if user
|
if user
|
||||||
subscriptions = user.subscriptions
|
subscriptions = user.subscriptions
|
||||||
watched = user.watched
|
# watched = user.watched
|
||||||
notifications = user.notifications
|
notifications = user.notifications
|
||||||
end
|
end
|
||||||
subscriptions ||= [] of String
|
subscriptions ||= [] of String
|
||||||
|
@ -123,15 +123,17 @@ module Invidious::Routes::Feeds
|
|||||||
end
|
end
|
||||||
|
|
||||||
user = user.as(User)
|
user = user.as(User)
|
||||||
|
watched = Invidious::Database::Users.get_watched(user)
|
||||||
|
|
||||||
max_results = env.params.query["max_results"]?.try &.to_i?.try &.clamp(0, MAX_ITEMS_PER_PAGE)
|
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 ||= user.preferences.max_results
|
||||||
max_results ||= CONFIG.default_user_preferences.max_results
|
max_results ||= CONFIG.default_user_preferences.max_results
|
||||||
|
|
||||||
if user.watched[(page - 1) * max_results]?
|
# TODO: History!!
|
||||||
watched = user.watched.reverse[(page - 1) * max_results, max_results]
|
# if user.watched[(page - 1) * max_results]?
|
||||||
end
|
# watched = user.watched.reverse[(page - 1) * max_results, max_results]
|
||||||
watched ||= [] of String
|
# end
|
||||||
|
# watched ||= [] of String
|
||||||
|
|
||||||
# Used for pagination links
|
# Used for pagination links
|
||||||
base_url = "/feed/history"
|
base_url = "/feed/history"
|
||||||
|
@ -43,7 +43,7 @@ module Invidious::Routes::Watch
|
|||||||
user = env.get?("user").try &.as(User)
|
user = env.get?("user").try &.as(User)
|
||||||
if user
|
if user
|
||||||
subscriptions = user.subscriptions
|
subscriptions = user.subscriptions
|
||||||
watched = user.watched
|
# watched = user.watched
|
||||||
notifications = user.notifications
|
notifications = user.notifications
|
||||||
end
|
end
|
||||||
subscriptions ||= [] of String
|
subscriptions ||= [] of String
|
||||||
@ -74,7 +74,7 @@ module Invidious::Routes::Watch
|
|||||||
"author" => JSON::Any.new(video.author)
|
"author" => JSON::Any.new(video.author)
|
||||||
})
|
})
|
||||||
|
|
||||||
if watched && preferences.watch_history
|
if preferences.watch_history
|
||||||
Invidious::Database::Users.mark_watched(user.as(User), history_details)
|
Invidious::Database::Users.mark_watched(user.as(User), history_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
22
src/invidious/routes/xd.xml
Normal file
22
src/invidious/routes/xd.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<feed xmlns:yt= \x22http:// www.youtube.com/ xml/ schemas/ 2015\x22 xmlns= \x22http:// www.w3.org/ 2005/ Atom\x22>
|
||||||
|
<link rel= \x22hub\x22 href= \x22https:// pubsubhubbub.appspot.com\x22 />
|
||||||
|
<link rel= \x22self\x22 href= \x22https:// www.youtube.com/ xml/ feeds/ videos.xml?channel_id=UCn8n_wDeUDrdDMQfoElZlfw\x22/>
|
||||||
|
<title>YouTube video feed</title>
|
||||||
|
<updated>2024-12-18T23:19:42.357314923+00:00</updated>
|
||||||
|
<entry>
|
||||||
|
<id>yt:video:YYBivfsnwIU</id>
|
||||||
|
<yt:videoId>YYBivfsnwIU</yt:videoId>
|
||||||
|
<yt:channelId>
|
||||||
|
UCn8n_wDeUDrdDMQfoElZlfw</yt:channelId>
|
||||||
|
<title>How To Make Silicone Tray Liners For the HARVESTRIGHT FREEZE DRYER #siliconetrayliners</title>
|
||||||
|
<link rel= \x22alternate\x22 href= \x22https:// www.youtube.com/ watch?v=YYBivfsnwIU\x22/>\x0A
|
||||||
|
<author>\x0A
|
||||||
|
<name>TheFreeze Drying Community</name>
|
||||||
|
<uri>https://www.youtube.com/channel/UCn8n_wDeUDrdDMQfoElZlfw</uri>
|
||||||
|
</author>
|
||||||
|
<published>
|
||||||
|
2021-02-07T14:00:17+00:00</published>\x0A <updated>2024-12-18T23:19:42.357314923+00:00</updated>
|
||||||
|
\x0A
|
||||||
|
</entry>
|
||||||
|
</feed>
|
@ -8,7 +8,7 @@ struct Invidious::User
|
|||||||
return JSON.build do |json|
|
return JSON.build do |json|
|
||||||
json.object do
|
json.object do
|
||||||
json.field "subscriptions", user.subscriptions
|
json.field "subscriptions", user.subscriptions
|
||||||
json.field "watch_history", user.watched
|
# json.field "watch_history", user.watched
|
||||||
json.field "preferences", user.preferences
|
json.field "preferences", user.preferences
|
||||||
json.field "playlists" do
|
json.field "playlists" do
|
||||||
json.array do
|
json.array do
|
||||||
|
@ -100,11 +100,11 @@ struct Invidious::User
|
|||||||
Invidious::Database::Users.update_subscriptions(user)
|
Invidious::Database::Users.update_subscriptions(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
if data["watch_history"]?
|
# if data["watch_history"]?
|
||||||
user.watched += data["watch_history"].as_a.map(&.as_s)
|
# user.watched += data["watch_history"].as_a.map(&.as_s)
|
||||||
user.watched.reverse!.uniq!.reverse!
|
# user.watched.reverse!.uniq!.reverse!
|
||||||
Invidious::Database::Users.update_watch_history(user)
|
# Invidious::Database::Users.update_watch_history(user)
|
||||||
end
|
# end
|
||||||
|
|
||||||
if data["preferences"]?
|
if data["preferences"]?
|
||||||
user.preferences = Preferences.from_json(data["preferences"].to_json)
|
user.preferences = Preferences.from_json(data["preferences"].to_json)
|
||||||
@ -219,23 +219,23 @@ struct Invidious::User
|
|||||||
end
|
end
|
||||||
|
|
||||||
def from_youtube_wh(user : User, body : String, filename : String, type : String) : Bool
|
def from_youtube_wh(user : User, body : String, filename : String, type : String) : Bool
|
||||||
extension = filename.split(".").last
|
# extension = filename.split(".").last
|
||||||
|
|
||||||
if extension == "json" || type == "application/json"
|
# if extension == "json" || type == "application/json"
|
||||||
data = JSON.parse(body)
|
# data = JSON.parse(body)
|
||||||
watched = data.as_a.compact_map do |item|
|
# watched = data.as_a.compact_map do |item|
|
||||||
next unless url = item["titleUrl"]?
|
# next unless url = item["titleUrl"]?
|
||||||
next unless match = url.as_s.match(/\?v=(?<video_id>[a-zA-Z0-9_-]+)$/)
|
# next unless match = url.as_s.match(/\?v=(?<video_id>[a-zA-Z0-9_-]+)$/)
|
||||||
match["video_id"]
|
# match["video_id"]
|
||||||
end
|
# end
|
||||||
watched.reverse! # YouTube have newest first
|
# watched.reverse! # YouTube have newest first
|
||||||
user.watched += watched
|
# user.watched += watched
|
||||||
user.watched.uniq!
|
# user.watched.uniq!
|
||||||
Invidious::Database::Users.update_watch_history(user)
|
# Invidious::Database::Users.update_watch_history(user)
|
||||||
return true
|
# return true
|
||||||
else
|
# else
|
||||||
return false
|
return false
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------
|
# -------------------
|
||||||
@ -310,11 +310,11 @@ struct Invidious::User
|
|||||||
|
|
||||||
db = DB.open("sqlite3://" + tempfile.path)
|
db = DB.open("sqlite3://" + tempfile.path)
|
||||||
|
|
||||||
user.watched += db.query_all("SELECT url FROM streams", as: String)
|
# user.watched += db.query_all("SELECT url FROM streams", as: String)
|
||||||
.map(&.lchop("https://www.youtube.com/watch?v="))
|
# .map(&.lchop("https://www.youtube.com/watch?v="))
|
||||||
|
|
||||||
user.watched.uniq!
|
# user.watched.uniq!
|
||||||
Invidious::Database::Users.update_watch_history(user)
|
# Invidious::Database::Users.update_watch_history(user)
|
||||||
|
|
||||||
user.subscriptions += db.query_all("SELECT url FROM subscriptions", as: String)
|
user.subscriptions += db.query_all("SELECT url FROM subscriptions", as: String)
|
||||||
.map(&.lchop("https://www.youtube.com/channel/"))
|
.map(&.lchop("https://www.youtube.com/channel/"))
|
||||||
|
@ -12,7 +12,7 @@ struct Invidious::User
|
|||||||
property preferences : Preferences
|
property preferences : Preferences
|
||||||
property password : String?
|
property password : String?
|
||||||
property token : String
|
property token : String
|
||||||
property watched : Array(String)
|
# property watched : Array(String)
|
||||||
property feed_needs_update : Bool?
|
property feed_needs_update : Bool?
|
||||||
|
|
||||||
module PreferencesConverter
|
module PreferencesConverter
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<%-
|
<%-
|
||||||
thin_mode = env.get("preferences").as(Preferences).thin_mode
|
thin_mode = env.get("preferences").as(Preferences).thin_mode
|
||||||
item_watched = !item.is_a?(SearchChannel | SearchHashtag | SearchPlaylist | InvidiousPlaylist | Category) && env.get?("user").try &.as(User).watched.index(item.id) != nil
|
# item_watched = !item.is_a?(SearchChannel | SearchHashtag | SearchPlaylist | InvidiousPlaylist | Category) && env.get?("user").try &.as(User).watched.index(item.id) != nil
|
||||||
author_verified = item.responds_to?(:author_verified) && item.author_verified
|
author_verified = item.responds_to?(:author_verified) && item.author_verified
|
||||||
-%>
|
-%>
|
||||||
|
|
||||||
@ -117,10 +117,10 @@
|
|||||||
<a tabindex="-1" href="<%= link_url %>">
|
<a tabindex="-1" href="<%= link_url %>">
|
||||||
<img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg" alt="" />
|
<img loading="lazy" class="thumbnail" src="/vi/<%= item.id %>/mqdefault.jpg" alt="" />
|
||||||
|
|
||||||
<% if item_watched %>
|
<% #if item_watched %>
|
||||||
<div class="watched-overlay"></div>
|
<div class="watched-overlay"></div>
|
||||||
<div class="watched-indicator" data-length="<%= item.length_seconds %>" data-id="<%= item.id %>"></div>
|
<div class="watched-indicator" data-length="<%= item.length_seconds %>" data-id="<%= item.id %>"></div>
|
||||||
<% end %>
|
<% #end %>
|
||||||
</a>
|
</a>
|
||||||
<%- else -%>
|
<%- else -%>
|
||||||
<div class="thumbnail-placeholder"></div>
|
<div class="thumbnail-placeholder"></div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<div class="pure-g h-box">
|
<div class="pure-g h-box">
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
<h3><%= translate_count(locale, "generic_videos_count", user.watched.size, NumberFormatting::HtmlSpan) %></h3>
|
<h3><%= translate_count(locale, "generic_videos_count", watched.size, NumberFormatting::HtmlSpan) %></h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1-3">
|
<div class="pure-u-1-3">
|
||||||
<h3 style="text-align:center">
|
<h3 style="text-align:center">
|
||||||
|
Loading…
Reference in New Issue
Block a user