iv-org / invidious

Invidious is an alternative front-end to YouTube
https://invidious.io
GNU Affero General Public License v3.0
16.19k stars 1.79k forks source link

Add support for an external signature server #4772

Closed SamantazFox closed 1 month ago

SamantazFox commented 2 months ago

Closes #4649

This PR adds support for inv_sig_helper, which offloads the player fetching, function extraction and signature parsing, which in turn allows to use the web client to watch videos.

Side note: I had to update the crystal overrides because the stdlib changed quite a while ago (See https://github.com/crystal-lang/crystal/pull/11049) and it was required to properly use TCP/unix sockets.


TODO:

SamantazFox commented 2 months ago

Also, what do you think about splitting the signature communication logic into its own shard?

Why though? Sound harder to maintain and I don't see anyone using this code except us. The connection multiplexing code might actually be a good candidate for a shard, but I don't think the code is versatile enough in its current state.

syeopite commented 2 months ago

Ah right. I did not think about the additional maintenance burden.

I requested it to potentially open the opportunity for other YouTube projects within the Crystal ecosystem though the possibility of that is pretty low...

Let's just keep it within Invidious.

SamantazFox commented 2 months ago

Important note: with the current state of the PR, invidious can't start if the socket is not present. I will add some logic to fallback to another client in that case.

unixfox commented 2 months ago

I don't see the way to configure to which address the inv_sig_helper is listening on. Is it done on purpose or an oversight?

I'm thinking about docker, where each service has its separate private IP address.

techmetx11 commented 2 months ago

I don't see the way to configure to which address the inv_sig_helper is listening on. Is it done on purpose or an oversight?

I'm thinking about docker, where each service has its separate private IP address.

Currently, it's listening on a UNIX socket (aka. on a path, by default: /tmp/inv_sig_helper.sock) I could change it to let it listen on UNIX or TCP

unixfox commented 2 months ago

@techmetx11

I don't see the way to configure to which address the inv_sig_helper is listening on. Is it done on purpose or an oversight? I'm thinking about docker, where each service has its separate private IP address.

Currently, it's listening on a UNIX socket (aka. on a path, by default: /tmp/inv_sig_helper.sock) I could change it to let it listen on UNIX or TCP

Ah, yes that would be a great improvement because we have people in the community that run Invidious over multiple servers, and you can only communicate through TCP if you have multiple servers, a UNIX socket won't work.

I'm not sure if the sig parameter can be shared between multiple public IP addresses or not, though.

techmetx11 commented 2 months ago

@techmetx11

I don't see the way to configure to which address the inv_sig_helper is listening on. Is it done on purpose or an oversight? I'm thinking about docker, where each service has its separate private IP address.

Currently, it's listening on a UNIX socket (aka. on a path, by default: /tmp/inv_sig_helper.sock) I could change it to let it listen on UNIX or TCP

Ah, yes that would be a great improvement because we have people in the community that run Invidious over multiple servers, and you can only communicate through TCP if you have multiple servers, a UNIX socket won't work.

That would make the current design, of Invidious sending a FORCE_UPDATE opcode to the server, a bit network-intensive. I would have to make the signature server have its own scheduler

I'm not sure if the sig parameter can be shared between multiple public IP addresses or not, though.

The JS code doesn't require network access, so I would hope so

unixfox commented 2 months ago

Continuing the discussion about signature helper server here: https://github.com/iv-org/inv_sig_helper/issues/1

unixfox commented 2 months ago

There will be a need to add the support for TCP/IP, as such that it can be used from multiple invidious processes.

Issue opened on inv_sig_helper side: https://github.com/iv-org/inv_sig_helper/issues/2

999eagle commented 2 months ago

i've been running this and #4789 on iv.catgirl.cloud for a while now to circumvent the login requirements, but occasionally invidious workers fail to start correctly after their hourly restart due to waiting indefinitely for the sig helper to force update the player. i've opened https://github.com/iv-org/inv_sig_helper/issues/4 for the underlying issue here

unixfox commented 2 months ago

Missing feature:

MMaster commented 1 month ago

To also write it here: Video caching in invidious also caches and reuses data from player so if the player changes the video that is pulled from cache will cause 403s to be returned for videoplayback requests.

SamantazFox commented 1 month ago

To also write it here: Video caching in invidious also caches and reuses data from player so if the player changes the video that is pulled from cache will cause 403s to be returned for videoplayback requests.

Yeah, I should rewrite the URLs during parsing (i.e before caching) not during use.