Commit Graph
100 Commits
Author SHA1 Message Date
syeopite 1f5685ef92 Reduce indent in StaticAssetsHandler#serve_file 2025-12-19 12:35:00 +01:00
syeopite 21049518d6 Improve cache size check to be more performant
Summing the sizes of each cached file every time is very inefficient.
Instead we can simply store the cache size in an constant and increase
it everytime a file is added into the cache.
2025-12-19 12:35:00 +01:00
syeopite 7f9cfe1aa2 Refactor logic for updating temp files in tests 2025-12-19 12:35:00 +01:00
syeopite 89a0761a19 Fix Ameba Lint/UselessAssign 2025-12-19 12:35:00 +01:00
syeopite 7749ea1956 Isolate static assets handler spec from others
Running `crystal spec` without a file argument essentially produces one
big program that combines every single spec file, their imports, and
the files that those imports themselves depend on. Most of the types
within this combined program will get ignored by the compiler due to a
lack of any calls to them from the spec files.

But for some types, partially the HTTP module ones, using them within
the spec files will suddenly make the compiler enable a bunch of
previously ignored code. And those code will suddenly require the
presence of additional types, constants, etc. This not only make it
annoying for getting the specs working but also makes it difficult to
isolate behaviors for testing.

The `static_assets_handler_spec.cr` causes this issue and so will be
marked as an isolated spec for now. In the future all of the tests
should be organized into independent groupings similar to how the
Crystal compiler splits their tests into std, compiler, primitives and
interpreter.
2025-12-19 12:35:00 +01:00
syeopite 9e482b4807 Add specs for the new StaticAssetsHandler 2025-12-19 12:35:00 +01:00
syeopite 6fd1cb3585 Compare against 1.17.0-dev until full release 2025-12-19 12:35:00 +01:00
syeopite ddfbed68f7 Simplify StaticAssetsHandler implementation
Overriding `#call` or patching out `serve_file_compressed` provides
only minimal benefits over the ease of maintenance granted by only
overriding what we need to for the caching behavior.
2025-12-19 12:35:00 +01:00
syeopite d2be57a454 Replace Kemal::StaticFileHandler on Crystal < 1.17.0
Kemal's subclass of the stdlib `HTTP::StaticFileHandler` is not as
maintained as its parent, and so misses out on many enhancements and bug
fixes from upstream, which unfortunately also includes the patches for
security vulnerabilities...

Though this isn't necessarily Kemal's fault since the bulk of the stdlib
handler's logic was done in a single big method, making any changes hard
to maintain. This was fixed in Crystal 1.17.0 where the handler
was refactored into many private methods, making it easier for an
inheriting type to implement custom behaviors while still leveraging
much of the pre-existing code.

Since we don't actually use any of the Kemal specific features added by
`Kemal::StaticFileHandler`, there really isn't a reason to not just
create a new handler based upon the stdlib implementation instead which
will address the problems mentioned above.

This PR implements a new handler which inherits from the stdlib variant
and overrides the helper methods added in Crystal 1.17.0 to add the
caching behavior with minimal code changes. Since this new handler
depends on the code in Crystal 1.17.0, it will only be applied on
versions greater than or equal to 1.17.0. On older versions we'll
fallback to the current monkey patched `Kemal::StaticFileHandler`
2025-12-19 12:35:00 +01:00
syeopite 325e013e0d Prepare for the next release 2025-09-13 11:55:10 -07:00
syeopite 5e9d51c06e Refactor FilteredCompressHandler to inherit from stdlib
This changes its behavior to align with the stdlib variant in that
compression is now delayed till the moment that the server begins to
send a response.

This allows the handler to avoid compressing empty responses,and
safeguards against any double compression of content that may occur
if another handler decides to compressi ts response.

This does however come at the drawback(?) of it now removing
`content-length` headers on requests if it exists; since compression
makes the value inaccurate anyway.

See: https://github.com/crystal-lang/crystal/pull/9625
2025-09-08 21:34:47 +02:00
syeopite fd8dc93569 Show message when connection to the database is not possible (#5346) 2025-08-23 04:04:06 -07:00
syeopite 67f93e55d8 Fix "ex" variable collision in invidious.cr
The exception handling for database connections results in an
`ex` variable which Ameba sees as overshadowing the `ex` used by the
`ex` block arg used to define the HTTP status code 500 handler below.

Although this is a non-issue since the db connection exception handling
will cause Invidious to exit, Ameba's nature as a static checker means
that it isn't aware of this.

The simplest fix without a dirty ameba ignore comment is to rename `ex`
within the Kemal handler block below, since `ex` within a begin rescue
block is a Crystal convention that will also cause Ameba to raise when
not adhered to.
2025-08-23 03:35:59 -07:00
syeopite f35f529adc Videos: Fix missing .id to retrieve first playlist video ID (#5366) 2025-08-23 03:30:00 -07:00
syeopite b32b077a80 Player: Persist caption settings (#5417) 2025-08-23 03:29:07 -07:00
syeopite 6badb80082 Channels: Fix fetching channel playlists (#5418) 2025-08-23 03:26:49 -07:00
syeopite 15099ac1dd Frontend: Fix notification count of TRUE (#5391) 2025-08-23 03:26:11 -07:00
syeopite adc83f1c09 Documentation: Fix typo (effet -> effect) (#5369) 2025-08-23 03:23:42 -07:00
syeopite 41e0e77d33 HTML: Add Missing Noreferrers (#5368) 2025-08-23 03:23:05 -07:00
syeopite 9ebc76462f Channels: Fix fetching of individual community posts (#5361) 2025-08-23 03:20:04 -07:00
syeopite 0308acb624 Videos: Add fallback to TvSimply client (#5345) 2025-08-23 03:18:41 -07:00
syeopite cac2397494 YTAPI: Add TvSimply client (#5344) 2025-08-23 03:17:28 -07:00
syeopite cf640d808e YtAPI: Bump client versions (#5325) 2025-08-23 03:16:55 -07:00
syeopite 80ec027c8f CI: Fix docker ci job not checking if Invidious starts successfully or not (#5306) 2025-08-23 03:16:32 -07:00
syeopite 6f5f0dceca CI: Use public ARM64 Github actions runners for ARM64 builds (#5305) 2025-08-23 03:16:05 -07:00
syeopite a8ab7b61f7 Player: Add keyboard shortcuts to configure captions (#5188) 2025-08-23 03:15:28 -07:00
syeopite 2c857b5ab6 Remove text captchas from Invidious (#5308)
textcaptcha.com seems to be down since April and it does not appear that
service will be restored.

Text captchas can be easily automated using free LLMs, so keeping the
text captcha is more like a gate to create accounts in mass on public
Invidious instances.

It also gives headaches like bots automating account creation to modify
the videos that appear popular page of each instance (since the popular
page is based on the subscriptions of the registered users).
2025-05-17 16:37:55 -07:00
syeopite 9d18c8699f Release versioning maintenance (#5310) 2025-05-17 16:22:32 -07:00
syeopite 475bf7448a Add Javascript licence information automatically (#5297) 2025-05-17 16:20:38 -07:00
syeopite 50e0a4361b Add missing javascript licenses (#5292) 2025-05-17 16:19:21 -07:00
syeopite 6bfb61e9b4 fix: safely access "label" key (#5282) 2025-05-17 16:18:58 -07:00
syeopite ef07c542dc fix: pass user to query.process if present (#5277) 2025-05-17 16:18:37 -07:00
syeopite a9180aa6c1 fix: do not strip '+' character from referer (#5276) 2025-05-17 16:18:15 -07:00
syeopite 4b2f9ffffc fix: set CSP header after setting preferences of registered users (#5275) 2025-05-17 16:17:43 -07:00
syeopite 64ad97f308 fix(typo): 'Salect' -> 'Select' (#5242) 2025-05-17 16:17:08 -07:00
syeopite d5cb653fd1 Handle parse errors gracefully on timeline items (#5196) 2025-05-17 16:16:20 -07:00
syeopite 0b23dd12e1 require base_job before the other jobs (#5194) 2025-05-17 16:15:32 -07:00
syeopite 23d66338cd Translations update from Hosted Weblate (#5192) 2025-05-17 16:15:03 -07:00
syeopite df41cb9588 Update Kemal to 1.6.0 and remove Kilt (#5120) 2025-05-17 16:14:40 -07:00
syeopite 49ada0aae9 Fix incorrect PR link for v2.20250504.0 2025-05-17 15:49:03 -07:00
syeopite f6a41ce90d Bump shard.yml version 2025-05-17 15:42:48 -07:00
syeopite 20cf913a4e Add Javascript licence information automatically
This commit automates the process of documenting the licenses of
Invidious Javascript files through a compile time macro in the
licenses.ecr template file.

This should hopefully help keep the license documentation up-to-date
and allow extensions like LibreJS to always be able to load the latest
Javascript files of Invidious.

Currently only Invidious's first-party Javascript files are supported.
In the future it should be possible to leverage videojs-dependencies.yml
to automatically document the Javascript licenses for
VideoJS and co. as well.
2025-05-10 18:44:53 -07:00
syeopite 6c063436d4 Fix issues raised by code review
Remove explicit `self.` from #process of parsers

Remove explicit return tuple in get_issue_template

Fix formatting

Move inline issue template style to stylesheet

Use @id in ProblematicTimelineItem xml repr

Fix naming
2025-04-05 12:40:38 -07:00
syeopite 7b27585454 Support ProblematicTimelineItem in trending feed 2025-03-19 23:50:41 -07:00
syeopite f7810ba007 Use ProblematicTimelineItem as needed in playlists 2025-03-19 23:32:46 -07:00
syeopite c288005bfd Make "show technical details" btn translatable 2025-03-19 22:52:04 -07:00
syeopite aae5ba01c2 Fix formatting 2025-03-19 22:52:04 -07:00
syeopite dd16f15aae Improve error card border color on dark theme 2025-03-19 22:52:04 -07:00
syeopite 180d77276b Emphasise error card icon 2025-03-19 22:52:04 -07:00
syeopite 0e0a95430a Improve JSON repr of ProblematicTimelineItem 2025-03-19 22:52:03 -07:00
syeopite 9de69c0052 Improve design of placeholder item
Also makes it show the error backtrace
2025-03-19 22:52:03 -07:00
syeopite dbeee71457 Apply search filters details css only to itself
The CSS for the search filters details box was applied to every
detail element when search.css is loaded
2025-03-19 22:52:03 -07:00
syeopite 94cb80ea81 Handle parse errors gracefully on timeline items
Prior to this commit, if even a single item fails to parse Invidious
will throw out an error. This means that even if everything else
on a page can be parsed and rendered without issues, the single
problematic item will cause the entire page to be unusable.

This commit gracefully handles parse errors by catching and then
replacing the problematic item with a new "timeline error" object
that represents the parse error. This will allow the rest of the page
to be rendered and an error card that will replace the location of the
problematic item.
2025-03-19 22:52:03 -07:00
syeopite adcdb8cb92 Fix lint and formatting 2025-02-26 14:18:50 -08:00
syeopite fe4fa0480a Fix HLS being used for non-livestream videos (#5189)
Invidious does not currently support non-livestream hls playback

Originally, the HLS manifest check was essentially a boolean:
if the HLS manifest field was present, it was assumed to be a
livestream. Some videos include the HLS Manifest but aren't
livestreams.

In the case where they are livestreams, the video contains a videoType
field with the value "Livestream". In the case that they're normal
videos, the videoType is "Video". This is exposed via the
`video.live_now` property.

This commit just checks that `video.live_now` is true before treating
it as a livestream
2025-02-26 14:14:29 -08:00
syeopite dbbcacc955 Images: fix typo in thumbnail logic 2025-02-26 14:13:58 -08:00
syeopite 58ad848d56 Channels: Support YouTube's change to from /community to /posts (#5183) 2025-02-26 14:13:22 -08:00
syeopite f9b9e85ee4 Docker: Use Crystal compiler cache in docker builds (#5163)
Adding the compiler cache reduces the build times on repeated
builds significantly
2025-02-26 14:11:12 -08:00
syeopite 6ac74f4362 Videos: Fix empty response when rv published field is nonexistent (#5162)
Fixes #5161 by checking recommended videos published field for presence
before attempting to parse it in api
2025-02-26 14:09:28 -08:00
syeopite 9fbe3944b0 Channels: Add Courses to channel page and channel API (#5158)
Closes #5144
2025-02-26 14:08:44 -08:00
syeopite c5e9447f41 Pick a different instance upon redirect (#5154)
The automatic instance redirection has the potential to pick
the same instance the user is currently on. This is especially
prevalent when the instance list is limited in number like how it is
today.

This PR checks the domain of the instance and ensures that it is not
the same as the current instane before redirecting the user to it.
Otherwise, it just sends the user to rediret.invidious.io
2025-02-26 14:05:21 -08:00
syeopite 3e329410d1 Add the ability to listen on UNIX sockets (#5112) 2025-02-26 14:04:29 -08:00
syeopite 74dfda150e i18n: Enable Tamil 2025-02-26 14:02:57 -08:00
syeopite e60f53154e Translations update from Hosted Weblate (#4989) 2025-02-26 13:57:04 -08:00
syeopite 3d77635a5c Add API endpoint for fetching transcripts from YouTube (#4788) 2025-02-26 13:56:39 -08:00
syeopite d0433c8386 JS: Update timeupdate event defensive to prevent errors (#4782) 2025-02-26 13:56:13 -08:00
syeopite 4ea4878d1a User: Batch notifications together 2025-02-26 13:55:25 -08:00
syeopite 1f0a89fb5f RSS: Channel + Playlist improvements (#4298) 2025-02-26 13:55:01 -08:00
syeopite f95f87e448 Frontend: Add a first page and previous page buttons for channel navigation (#4123) 2025-02-26 13:54:25 -08:00
syeopite 05c5448bc1 Update Kemal to 1.6.0 and remove Kilt
Kilt is unmaintained and the ECR templating logic has been
natively integrated into Kemal with the issues previously seen
having been resolved.

This commit is mostly a precursor to support the next Kemal
release which will add the ability to create error handlers for
raised exceptions.

See https://github.com/kemalcr/kemal/pull/688
2025-01-29 11:49:45 -08:00
syeopite e2df12b7d6 Use Crystal compiler cache in docker builds 2025-01-28 23:31:01 -08:00
syeopite 164d764d55 API: Add a 'published' video parameter for related videos (#4149) 2025-01-22 11:38:12 -08:00
syeopite 4a31da4000 User: Ensure IO is properly closed when importing NewPipe subscriptions (#4346) 2025-01-22 11:36:58 -08:00
syeopite 831017f403 Frontend: Carry over audio-only mode in playlist links (#4784) 2025-01-22 11:35:33 -08:00
syeopite 52daafe047 Videos: Fix missing host parameter on playback URLs when local=true (#4992) 2025-01-22 11:34:46 -08:00
syeopite dca130ca6f Routes: Clean ajax actions handlers (#5036) 2025-01-22 11:33:51 -08:00
syeopite 086c6209ab Remove stdlib override for proxy initialization (#5065) 2025-01-22 11:33:20 -08:00
syeopite 0d398c9d1a API: Add support for author thumbnails in search api for videos (#5072) 2025-01-22 11:32:21 -08:00
syeopite dc38bcdf17 Kemal: Skip route if response was closed by handlers (#5073) 2025-01-22 11:30:45 -08:00
syeopite d5442d45bc API: Fix video thumbnails in mixes (#5116) 2025-01-22 11:29:12 -08:00
syeopite d4f0560e80 CI: Drop support for versions prior to 1.12 and add 1.15.0 (#5148) 2025-01-22 11:28:38 -08:00
syeopite eae3c42dab Videos: Set language for dash audio streams and sort (#5149) 2025-01-22 11:25:39 -08:00
syeopite c0131d8646 Warn when any top-level config is "CHANGE_ME!!" (#5150) 2025-01-22 11:16:24 -08:00
syeopite 21fd717701 Comment out http_proxy in example config (#5151)
The http_proxy section was not commented out in the example config
causing Invidious to error out unless an HTTP proxy was configured.

This problem affects new manual installs in which the example config
is copied to create the actual config Invidious uses
2025-01-22 11:11:42 -08:00
syeopite d36f372bd1 CI: Add support for 1.15.0 2025-01-22 10:34:24 -08:00
syeopite 58c65e921f CI: Drop support for versions prior to 1.12.0 2025-01-22 10:34:24 -08:00
syeopite 5d9ed95ffd Warn when any top-level config is "CHANGE_ME!!" 2025-01-22 10:34:04 -08:00
syeopite 033e42a981 Comment out http_proxy in example config 2025-01-22 10:33:34 -08:00
syeopite 097b4f0433 CI: Use separate shards cache for lint step
Ameba could be built with an older version of Crystal that follows
a different set of formatting rules than the latest version causing
the Lint/Formatting rule to fail when in actuality the code is actually
compliant with the formatting rules in the latest version of Crystal
2025-01-20 16:39:33 -08:00
syeopite e1378702af Apply upcoming formatting rules from Crystal 1.15 2025-01-20 16:15:13 -08:00
syeopite 9d54cf903e Update shard.yml metadata 2024-11-08 15:54:37 -08:00
syeopite 1333fed26c Remove stdlib override for proxy initialization
HTTP Proxy is now initialized in the make_client function
2024-11-08 15:28:12 -08:00
syeopite ce910b5269 Prevent discussion issues from being staled 2024-11-07 20:45:23 -08:00
syeopite 78f18b257c Double stale timer for issues
Days before staling is increased to 730 days
Days before closing is increased to 60 days
2024-11-07 20:42:19 -08:00
syeopite 3196182d4d Prevent PRs from being considered stale 2024-11-07 20:41:04 -08:00
syeopite f1baeef4bc Ameba: Disable Style/RedundantNext rule 2024-08-28 23:49:10 -07:00
syeopite 75b68618ab Remove useless proc usage in images.cr 2024-08-24 19:47:42 -07:00
syeopite 003c6f81dc Preserve connection close header of get_storyboard 2024-08-24 19:47:42 -07:00
syeopite 4bc77b81bf Move YTIMG_POOLS to connection_pool.cr 2024-08-24 19:47:40 -07:00
syeopite 06e1a508e8 Fix headers not being added in image requests
Regression from #2364
2024-08-24 19:45:52 -07:00