goodtube4u / goodtube

Loads Youtube videos from different sources. Also removes ads, shorts, etc.
113 stars 8 forks source link

Option to manage server list #39

Closed dwroland closed 1 month ago

dwroland commented 1 month ago

At the moment, to add or remove a server from the list we have to do a fork and make changes manually in the code

goodtube4u commented 1 month ago

This would be quite difficult I think. Is there a particular server you would like to add?

dwroland commented 1 month ago

You can store the list of custom values as JSON.stringify() in the extension store https://www.tampermonkey.net/documentation.php?locale=en#api:GM_setValue

I have local servers in the address pool 10.10.1.*. If I host goodtube on one of them, firefox mobile should also access that server.

goodtube4u commented 1 month ago

I've made some updates that will allow you to do this. Instructions are here: https://github.com/goodtube4u/goodtube#optional-add-custom-video-servers

Hopefully that makes sense. Any questions hit me up.

dwroland commented 1 month ago

Hmm. It seems that it's not working. It just skips my server. No connection attempt in the logs on the server. Zrzut ekranu 2024-08-08 030036 Zrzut ekranu 2024-08-08 030207

goodtube4u commented 1 month ago

Ah sorry there was a typo in the code. Fixed and pushed. Give it a few minutes, refresh, should work. You don't need to update the setting or anything. Just leave it turned on and it should simply start working.

Can you check and let me know?

dwroland commented 1 month ago

Still skipping.

goodtube4u commented 1 month ago

You sure? I just tried it and it's working for me.

My server is Invidious DASH (like yours): http://127.0.0.1:3000

So I used to test: https://www.youtube.com/?goodtube_customserver_0_name=Test%20server&goodtube_customserver_0_type=2&goodtube_customserver_0_proxy=true&goodtube_customserver_0_url=http://127.0.0.1:3000

dwroland commented 1 month ago

https://www.youtube.com?goodtube_customserver_0_name=S1&goodtube_customserver_0_type=2&goodtube_customserver_0_proxy=true&goodtube_customserver_0_url=http://S1.lan

I have tried changing type but it still skipps.

goodtube4u commented 1 month ago

image

goodtube4u commented 1 month ago

I think maybe you've got the casing wrong.

Should it be: http://s1.lan/

Instead of http://S1.lan/

https://www.youtube.com/?goodtube_customserver_0_name=S1&goodtube_customserver_0_type=2&goodtube_customserver_0_proxy=true&goodtube_customserver_0_url=http://s1.lan

It might also help to confirm that you can actually view the video you're watching / testing with in your Invidious instance.

p.s. Check out the console logs. They are fun / helpful. They'll show you which server it's trying to load, etc.

dwroland commented 1 month ago

[GoodTube] Loading video data from s1... watch:1:52269 Zasady odsyłaczy: ignorowanie mniej ograniczonej zasady odsyłaczy „origin-when-cross-origin” w przypadku żądania między witrynami: http://s1.lan/api/v1/videos/3gL9kWD9XRo watch:1:5978 Zablokowano wczytywanie mieszanych treści aktywnych „http://s1.lan/api/v1/videos/3gL9kWD9XRo”

And yeah, http://s1.lan/api/v1/videos/3gL9kWD9XRo is unreachable.

goodtube4u commented 1 month ago

I'd say that's because it's a mixed http type request.

You'll need to find a way to serve over https. It let's you do this if you're using a local IP address like 127.0.0.1 but otherwise won't work (I don't have control over this, it's a built in piece of web security)

http://s1.lan vs https://s1.lan

Don't give up! You're close.

dwroland commented 1 month ago

Hmm. I have added port to server address. Now I can get answer from API but goodtube still refuse to connect. [GoodTube] Loading video data from s1... [watch:1:52269](https://www.youtube.com/watch?v=3gL9kWD9XRo%20line%207066%20%3E%20injectedScript) Zasady odsyłaczy: ignorowanie mniej ograniczonej zasady odsyłaczy „origin-when-cross-origin” w przypadku żądania między witrynami: http://s1.lan:3000/api/v1/videos/3gL9kWD9XRo [watch:1:5978](https://www.youtube.com/watch?v=3gL9kWD9XRo) Zablokowano wczytywanie mieszanych treści aktywnych „http://s1.lan:3000/api/v1/videos/3gL9kWD9XRo” [watch:1:5978](https://www.youtube.com/watch?v=3gL9kWD9XRo) Nieprawidłowy adres URI. Treść multimedialna „” nie została wczytana.

Zrzut ekranu 2024-08-08 033645 Zrzut ekranu 2024-08-08 033742

Ah okay now I understand. https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default

dwroland commented 1 month ago

Am I stupid or something? Port 443 should be open, but it's not... obraz obraz

goodtube4u commented 1 month ago

Hmmm, not sure. I'm not great with this side of things to be honest - and the invidious documentation is terrible haha. I wonder if that "state = closed" part of the log has any relevance? Just a guess.

goodtube4u commented 1 month ago

So I'm interested to know if you got this working in the end. If you work it out could you share the info? Might be nice to update the guide for other people that want to do something similar.

dwroland commented 1 month ago

/I tried to do it quickly, but it is pain in the ass. Invidious docker container doesn't include nginx or any other service capable of reverse proxy, so I have to configure it myself. Maybe I will try it in the future. For now, I simply made a workaround with the redirection using this script:

// ==UserScript==
// @name         YT redirect
// @version      1.0
// @author       Greust
// @match        https://*.youtube.com/watch*
// @run-at       document-start
// ==/UserScript==
/* global $ */

function url_builder() {
    let newURL = "http://"
        + "yt.lan:3000"
        + window.location.pathname
        + window.location.search
        ;
    return newURL;
}

(function () {
    'use strict';
    window.location.replace(url_builder());
})();
goodtube4u commented 1 month ago

As in, you're just redirecting to your invidious instance and watching there? And yes, total pain in the ass.

goodtube4u commented 1 month ago

One thought I have had is that I might be able to unlock a lot of the restricted servers, and presumably request via normal http using GM_xmlhttpRequest: https://www.tampermonkey.net/documentation.php?locale=en#api:GM_xmlhttpRequest

This is a built in tampermonkey thing (also supported by Violentmonkey, etc). It basically uses some trickery to allow you to do cross origin requests.

So what I would need to do is swap the fetch calls to use this instead.

That said, I'm not entirely sure it will work. The request could get the mainfest file, which contains all the parts of the video which are loaded into the player. But the parts of the video would be http and I'm unsure if that'll work from however this is handled inside the player itself (might run into the same cross origin issue). Bit of work to test but on the cards one day...

At least I understand this properly. Where as the devops side of things, reverse proxies, https certs locally, that confuses the heck out of me.

Also if you're interested, there's a lot of the people that made invidious on chat here: https://web.libera.chat/?channel=#invidious

They can be helpful.

dwroland commented 1 month ago

Yes, and so far it's working fine. When I find some free time, I will try with this https://docs.linuxserver.io/general/swag/#docker-compose. Thanks for the link to the chat.