summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/stale.yml2
-rw-r--r--docker-compose.yml3
-rw-r--r--spec/invidious/search/yt_filters_spec.cr54
-rw-r--r--src/invidious/routes/feeds.cr25
-rw-r--r--src/invidious/routes/video_playback.cr8
-rw-r--r--src/invidious/search/filters.cr6
-rw-r--r--src/invidious/yt_backend/connection_pool.cr15
7 files changed, 64 insertions, 49 deletions
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
index b25199e3..16d3269b 100644
--- a/.github/workflows/stale.yml
+++ b/.github/workflows/stale.yml
@@ -16,7 +16,7 @@ jobs:
days-before-stale: 365
days-before-pr-stale: 90
days-before-close: 30
- exempt-pr-labels: blocked
+ exempt-pr-labels: blocked,exempt-stale
stale-issue-message: 'This issue has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely outdated. If you think this issue is still relevant and applicable, you just have to post a comment and it will be unmarked.'
stale-pr-message: 'This pull request has been automatically marked as stale and will be closed in 30 days because it has not had recent activity and is much likely abandoned or outdated. If you think this pull request is still relevant and applicable, you just have to post a comment and it will be unmarked.'
stale-issue-label: "stale"
diff --git a/docker-compose.yml b/docker-compose.yml
index d879919a..42a5c06b 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -37,7 +37,8 @@ services:
timeout: 5s
retries: 2
depends_on:
- - invidious-db
+ invidious-db:
+ condition: service_healthy
invidious-db:
image: docker.io/library/postgres:14
diff --git a/spec/invidious/search/yt_filters_spec.cr b/spec/invidious/search/yt_filters_spec.cr
index bf7f21e7..8abed5ce 100644
--- a/spec/invidious/search/yt_filters_spec.cr
+++ b/spec/invidious/search/yt_filters_spec.cr
@@ -12,45 +12,45 @@ end
# page of Youtube with any browser devtools HTML inspector.
DATE_FILTERS = {
- Invidious::Search::Filters::Date::Hour => "EgIIAQ%3D%3D",
- Invidious::Search::Filters::Date::Today => "EgIIAg%3D%3D",
- Invidious::Search::Filters::Date::Week => "EgIIAw%3D%3D",
- Invidious::Search::Filters::Date::Month => "EgIIBA%3D%3D",
- Invidious::Search::Filters::Date::Year => "EgIIBQ%3D%3D",
+ Invidious::Search::Filters::Date::Hour => "EgIIAfABAQ%3D%3D",
+ Invidious::Search::Filters::Date::Today => "EgIIAvABAQ%3D%3D",
+ Invidious::Search::Filters::Date::Week => "EgIIA_ABAQ%3D%3D",
+ Invidious::Search::Filters::Date::Month => "EgIIBPABAQ%3D%3D",
+ Invidious::Search::Filters::Date::Year => "EgIIBfABAQ%3D%3D",
}
TYPE_FILTERS = {
- Invidious::Search::Filters::Type::Video => "EgIQAQ%3D%3D",
- Invidious::Search::Filters::Type::Channel => "EgIQAg%3D%3D",
- Invidious::Search::Filters::Type::Playlist => "EgIQAw%3D%3D",
- Invidious::Search::Filters::Type::Movie => "EgIQBA%3D%3D",
+ Invidious::Search::Filters::Type::Video => "EgIQAfABAQ%3D%3D",
+ Invidious::Search::Filters::Type::Channel => "EgIQAvABAQ%3D%3D",
+ Invidious::Search::Filters::Type::Playlist => "EgIQA_ABAQ%3D%3D",
+ Invidious::Search::Filters::Type::Movie => "EgIQBPABAQ%3D%3D",
}
DURATION_FILTERS = {
- Invidious::Search::Filters::Duration::Short => "EgIYAQ%3D%3D",
- Invidious::Search::Filters::Duration::Medium => "EgIYAw%3D%3D",
- Invidious::Search::Filters::Duration::Long => "EgIYAg%3D%3D",
+ Invidious::Search::Filters::Duration::Short => "EgIYAfABAQ%3D%3D",
+ Invidious::Search::Filters::Duration::Medium => "EgIYA_ABAQ%3D%3D",
+ Invidious::Search::Filters::Duration::Long => "EgIYAvABAQ%3D%3D",
}
FEATURE_FILTERS = {
- Invidious::Search::Filters::Features::Live => "EgJAAQ%3D%3D",
- Invidious::Search::Filters::Features::FourK => "EgJwAQ%3D%3D",
- Invidious::Search::Filters::Features::HD => "EgIgAQ%3D%3D",
- Invidious::Search::Filters::Features::Subtitles => "EgIoAQ%3D%3D",
- Invidious::Search::Filters::Features::CCommons => "EgIwAQ%3D%3D",
- Invidious::Search::Filters::Features::ThreeSixty => "EgJ4AQ%3D%3D",
- Invidious::Search::Filters::Features::VR180 => "EgPQAQE%3D",
- Invidious::Search::Filters::Features::ThreeD => "EgI4AQ%3D%3D",
- Invidious::Search::Filters::Features::HDR => "EgPIAQE%3D",
- Invidious::Search::Filters::Features::Location => "EgO4AQE%3D",
- Invidious::Search::Filters::Features::Purchased => "EgJIAQ%3D%3D",
+ Invidious::Search::Filters::Features::Live => "EgJAAfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::FourK => "EgJwAfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::HD => "EgIgAfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::Subtitles => "EgIoAfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::CCommons => "EgIwAfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::ThreeSixty => "EgJ4AfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::VR180 => "EgPQAQHwAQE%3D",
+ Invidious::Search::Filters::Features::ThreeD => "EgI4AfABAQ%3D%3D",
+ Invidious::Search::Filters::Features::HDR => "EgPIAQHwAQE%3D",
+ Invidious::Search::Filters::Features::Location => "EgO4AQHwAQE%3D",
+ Invidious::Search::Filters::Features::Purchased => "EgJIAfABAQ%3D%3D",
}
SORT_FILTERS = {
- Invidious::Search::Filters::Sort::Relevance => "",
- Invidious::Search::Filters::Sort::Date => "CAI%3D",
- Invidious::Search::Filters::Sort::Views => "CAM%3D",
- Invidious::Search::Filters::Sort::Rating => "CAE%3D",
+ Invidious::Search::Filters::Sort::Relevance => "8AEB",
+ Invidious::Search::Filters::Sort::Date => "CALwAQE%3D",
+ Invidious::Search::Filters::Sort::Views => "CAPwAQE%3D",
+ Invidious::Search::Filters::Sort::Rating => "CAHwAQE%3D",
}
Spectator.describe Invidious::Search::Filters do
diff --git a/src/invidious/routes/feeds.cr b/src/invidious/routes/feeds.cr
index 40bca008..e20a7139 100644
--- a/src/invidious/routes/feeds.cr
+++ b/src/invidious/routes/feeds.cr
@@ -407,14 +407,23 @@ module Invidious::Routes::Feeds
end
spawn do
- rss = XML.parse_html(body)
- rss.xpath_nodes("//feed/entry").each do |entry|
- id = entry.xpath_node("videoid").not_nil!.content
- author = entry.xpath_node("author/name").not_nil!.content
- published = Time.parse_rfc3339(entry.xpath_node("published").not_nil!.content)
- updated = Time.parse_rfc3339(entry.xpath_node("updated").not_nil!.content)
-
- video = get_video(id, force_refresh: true)
+ # TODO: unify this with the other almost identical looking parts in this and channels.cr somehow?
+ namespaces = {
+ "yt" => "http://www.youtube.com/xml/schemas/2015",
+ "default" => "http://www.w3.org/2005/Atom",
+ }
+ rss = XML.parse(body)
+ rss.xpath_nodes("//default:feed/default:entry", namespaces).each do |entry|
+ id = entry.xpath_node("yt:videoId", namespaces).not_nil!.content
+ author = entry.xpath_node("default:author/default:name", namespaces).not_nil!.content
+ published = Time.parse_rfc3339(entry.xpath_node("default:published", namespaces).not_nil!.content)
+ updated = Time.parse_rfc3339(entry.xpath_node("default:updated", namespaces).not_nil!.content)
+
+ begin
+ video = get_video(id, force_refresh: true)
+ rescue
+ next # skip this video since it raised an exception (e.g. it is a scheduled live event)
+ end
if CONFIG.enable_user_notifications
# Deliver notifications to `/api/v1/auth/notifications`
diff --git a/src/invidious/routes/video_playback.cr b/src/invidious/routes/video_playback.cr
index 1d5aa914..ec18f3b8 100644
--- a/src/invidious/routes/video_playback.cr
+++ b/src/invidious/routes/video_playback.cr
@@ -42,7 +42,7 @@ module Invidious::Routes::VideoPlayback
headers["Range"] = "bytes=#{range_for_head}"
end
- client = make_client(URI.parse(host), region)
+ client = make_client(URI.parse(host), region, force_resolve = true)
response = HTTP::Client::Response.new(500)
error = ""
5.times do
@@ -57,7 +57,7 @@ module Invidious::Routes::VideoPlayback
if new_host != host
host = new_host
client.close
- client = make_client(URI.parse(new_host), region)
+ client = make_client(URI.parse(new_host), region, force_resolve = true)
end
url = "#{location.request_target}&host=#{location.host}#{region ? "&region=#{region}" : ""}"
@@ -71,7 +71,7 @@ module Invidious::Routes::VideoPlayback
fvip = "3"
host = "https://r#{fvip}---#{mn}.googlevideo.com"
- client = make_client(URI.parse(host), region)
+ client = make_client(URI.parse(host), region, force_resolve = true)
rescue ex
error = ex.message
end
@@ -196,7 +196,7 @@ module Invidious::Routes::VideoPlayback
break
else
client.close
- client = make_client(URI.parse(host), region)
+ client = make_client(URI.parse(host), region, force_resolve = true)
end
end
diff --git a/src/invidious/search/filters.cr b/src/invidious/search/filters.cr
index c2b5c758..bf968734 100644
--- a/src/invidious/search/filters.cr
+++ b/src/invidious/search/filters.cr
@@ -300,9 +300,9 @@ module Invidious::Search
object["9:varint"] = ((page - 1) * 20).to_i64
end
- # If the object is empty, return an empty string,
- # otherwise encode to protobuf then to base64
- return "" if object.empty?
+ # Prevent censoring of self harm topics
+ # See https://github.com/iv-org/invidious/issues/4398
+ object["30:varint"] = 1.to_i64
return object
.try { |i| Protodec::Any.cast_json(i) }
diff --git a/src/invidious/yt_backend/connection_pool.cr b/src/invidious/yt_backend/connection_pool.cr
index 36e82766..81cfb272 100644
--- a/src/invidious/yt_backend/connection_pool.cr
+++ b/src/invidious/yt_backend/connection_pool.cr
@@ -26,7 +26,7 @@ struct YoutubeConnectionPool
def client(region = nil, &block)
if region
- conn = make_client(url, region)
+ conn = make_client(url, region, force_resolve = true)
response = yield conn
else
conn = pool.checkout
@@ -59,9 +59,14 @@ struct YoutubeConnectionPool
end
end
-def make_client(url : URI, region = nil)
+def make_client(url : URI, region = nil, force_resolve : Bool = false)
client = HTTPClient.new(url, OpenSSL::SSL::Context::Client.insecure)
- client.family = CONFIG.force_resolve
+
+ # Some services do not support IPv6.
+ if force_resolve
+ client.family = CONFIG.force_resolve
+ end
+
client.before_request { |r| add_yt_headers(r) } if url.host == "www.youtube.com"
client.read_timeout = 10.seconds
client.connect_timeout = 10.seconds
@@ -80,8 +85,8 @@ def make_client(url : URI, region = nil)
return client
end
-def make_client(url : URI, region = nil, &block)
- client = make_client(url, region)
+def make_client(url : URI, region = nil, force_resolve : Bool = false, &block)
+ client = make_client(url, region, force_resolve)
begin
yield client
ensure