jellyfin / jellyfin-tizen

Jellyfin Samsung TV Client
https://jellyfin.org
979 stars 76 forks source link

Startup app #25

Open dga4130-renato opened 4 years ago

dga4130-renato commented 4 years ago

Would it be possible to insert somewhere in the code before compiling an http request ? i mean, if i insert an http address that will wake up my home server in the code, will this be called before loading the app.. maybe i could modify somethin my side ?

dmitrylyzo commented 4 years ago

Have you configured Wake-on-LAN via HTTP already? I did a quick search and discussed with team, and it seems that this cannot be done via HTTP directly.

All that comes to mind is the use of an additional device that will receive a "wakeup" request and send a magic packet to the media server.

Also it is might be possible to somehow use a reverse proxy to wake up the media server by just receiving a request to it. I am not a PRO in proxy, so could be wrong

dga4130-renato commented 4 years ago

i am using a raspberry to wake up server when tv set powers on but sill have to poweron something else to wake up the server... wake on lan option will not be implemented on jellyfin ... i allredy asked.. that is why i was asking about an http request . i tested on the router tcpdump on port 8096 but seems the android app sens multiple calls to that port even in background... so the server will never sleep. reverse proxy could be a solution but the tizen app should call it somehow...

dmitrylyzo commented 4 years ago

i am using a raspberry to wake up server when tv set powers on but sill have to poweron something else to wake up the server

So you have raspberry that can wake up server. Can't same raspberry power on "something else"? Who should receive your HTTP request?

dga4130-renato commented 4 years ago

Yes .. but I want to remove the raspberry with libreelec and keep only jellyfin.. but without the raspberry the server will never wake up

dmitrylyzo commented 4 years ago

When you remove raspberry, who should receive your HTTP request? Someone has to be there to wake a sleepy server.

Nazar78 commented 4 years ago

Yeah you would need something at the frontend that's always online to wake up the sleeping server unless if you use an app or sort of CGI. The WOL could be done automatically using a reverse proxy but again you'll need two servers, an always online frontend low powered server and a sleeping backend server i.e. jellyfin? Several ways to do this but think this method below is the simplest without implementing interpreters such as php/perl and could be improved but not officially supported by jellyfin. On the Raspberry:

  1. Install etherwake or wakeonlan using apt-get.

  2. Install nginx as the frontend reverse proxy together with the Lua module.

  3. Edit the nginx jellyfin config as per official documentation: https://jellyfin.org/docs/general/networking/nginx.html

  4. While editing the nginx jellyfin config above, add another location block:

location /wol {
    content_by_lua_block {
        # etherwake needs root, so you need to allow passwordless sudo 
        # for the user running nginx i.e. www-data.
        # os.execute("sudo etherwake -i eth0 FF:FF:FF:FF:FF:FF")
        os.execute("wakeonlan FF:FF:FF:FF:FF:FF")
        # If accessing from the jellyfin web: https://jellyfin.myserver.com/wol
        # return ngx.redirect("/web/index.html")
        # else do step #5 below on jellyfin-tizen or you can make another /wol2.
    }
}
  1. Edit the jellyfin-tizen index.html: Remove: <meta http-equiv="refresh" content="0; url=www/index.html" /> Replace with a callback:
    <script>
    const http = new XMLHttpRequest()
    http.open("GET", "https://jellyfin.myserver.com/wol")
    http.send()
    http.onload = () => document.location = 'www/index.html';
    </script>

    Can add a delay if your server takes time to wake up. Then regenerate the Jellyfin.wgt push to your TV and that's it.

Above is just an idea I just think of (take note of the /wol) but it works only that you need to relaunch jellyfin-tizen every time you wanna wake the server up also depending on how you want it to be done it's up to you.

dmitrylyzo commented 4 years ago

In addition to what @Nazar78 said.

My untested/naive idea with proxy Proxy monitors http://<your_server_address>/<baseurl>/system/info/public and performs special action for such requests.

dga4130-renato commented 4 years ago

What if I put this in the tizen script brackets https://www.depicus.com/wake-on-lan That is a wake on lan site service

dga4130-renato commented 4 years ago
Nazar78 commented 4 years ago

What if I put this in the tizen script brackets https://www.depicus.com/wake-on-lan That is a wake on lan site service

Yup that would work too but you'll need to forward the udp port from your router to the sleeping server. I've used such online service before long ago. Sometimes it would work and least of the time elsewhere it wouldn't not sure why probably blocked by ISP in foreign countries. Also opening up this online could result to bots scanning flooding your internal network unless you have some iptables rules to filter.

dmitrylyzo commented 4 years ago

Personally, I would keep homenet to be "local" as much as possible. That's why Jellyfin I wonder if it is possible to make a proxy (with some perl wrapper) on the router.

Nazar78 commented 4 years ago

Personally, I would keep homenet to be "local" as much as possible. That's why Jellyfin I wonder if it is possible to make a proxy (with some perl wrapper) on the router.

Yes it's possible on dd-wrt optware. Just install nginx, you can use the lua module or better install perl. Personally for a long time I've been using my simple self-written perl script to maintain my list of home sleeping devices. You can make it accessible online or local only and run it on anything that supports nginx/apache and perl. Feel free modify it to suite your needs http://teanazar.com/2015/10/setting-up-remote-wol-wake-on-lan/

dga4130-renato commented 4 years ago

Nice solutions, really , but i am still asking myself why jellyfin will never support wol while emby does.