elgatito / plugin.video.elementum

Elementum add-on for Kodi. Development of this addon has been stopped!
http://elementum.surge.sh
MIT License
471 stars 157 forks source link

[Request] Allow to run daemon on an external device (pc, nas etc.) #2

Open Znuff opened 6 years ago

Znuff commented 6 years ago

Hello,

I realize it's very early for feature requests before you release a stable version, but I would like to propose factoring in the possibility of running the "Elementum" daemon on a different device than the one that runs Kodi (and plugin.video.elementum).

I have already tried to do this in the past with Pulsar, but here are the issues I run into:

A lot of places have 127.0.0.1 hardcoded for the communication with the torrent binary.

The binary always sends RPC commands to 127.0.0.1. It should probably figure out what device made the request then issue the play command to the RPC-port.

This makes it so, that, for example, even if you manage to run the binary separately (I did this with Kodi running on my PC as a "server" and on an Android tv box as a "client"), even if you manage to initiate a download on the "server' device, from the "client", the playback of the video will still be on the "server".

Hope you can consider this.

mike-sirs commented 2 years ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

ShlomiD83 commented 2 years ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Kodi needs to be installed separately on the pi? Or elementum will run as a standalone plugin on docker?

mike-sirs commented 2 years ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Kodi needs to be installed separately on the pi? Or elementum will run as a standalone plugin on docker?

you need kodi with elementum on one side and docker with elementum on the other

check this https://github.com/elgatito/plugin.video.elementum/issues/2#issuecomment-1137970110

ShlomiD83 commented 2 years ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Kodi needs to be installed separately on the pi? Or elementum will run as a standalone plugin on docker?

you need kodi with elementum on one side and docker with elementum on the other

check this #2 (comment)

So you need the path of the client?

mike-sirs commented 2 years ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Kodi needs to be installed separately on the pi? Or elementum will run as a standalone plugin on docker?

you need kodi with elementum on one side and docker with elementum on the other check this #2 (comment)

So you need the path of the client?

not gonna work, the path will include your username like /home/USER_NAME/.kodi/addons/plugin.video.elementum

so it must be either a pre-build with ELEMENTUM_PATH=/home/USER_NAME/.kodi/addons/plugin.video.elementum or entry_point script that takes ENV var e.g KODI_USER=USER_NAME or ELEMENTUM_PATH=/home/USER_NAME/... and create symlink for that on start

ShlomiD83 commented 2 years ago

So it's not possible?

mike-sirs commented 2 years ago

So it's not possible?

you can try image: undead/elementum:0.1.83.1 setting env var ELEMENTUM_NEW_PATH=your plugin location

ShlomiD83 commented 2 years ago

I've built the image using "linux_arm64" and it works very well actually.

I've managed to run it on 2 android TV devices at the same time but not on windows as well. Is there a way to make it look for the plugin on multiple paths?

kovacicjanez commented 1 year ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Hi can you make image for aarch64 (arm64) /storage/.kodi/addons/plugin.video.elementum

or can you tell me how to create an image...

mike-sirs commented 1 year ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Hi can you make image for aarch64 (arm64) /storage/.kodi/addons/plugin.video.elementum

or can you tell me how to create an image...

https://github.com/elgatito/plugin.video.elementum/issues/2#issuecomment-1137537635

ShlomiD83 commented 1 year ago

undead/elementum

can you make a image for Raspberry pi 4 aswell?

I would, but I don't have RPi to check

I can check for you.

I need a path where elementum plugin is located.

Hi can you make image for aarch64 (arm64) /storage/.kodi/addons/plugin.video.elementum

or can you tell me how to create an image...

FROM alpine:latest as build

ENV ELEMENTUM_VER="0.1.86" ENV ELEMENTUM_URL="https://github.com/elgatito/plugin.video.elementum/releases/download/v$ELEMENTUM_VER/plugin.video.elementum-$ELEMENTUM_VER.linux_arm64.zip"

RUN wget "$ELEMENTUM_URL" -O /tmp/elementum.zip \ && unzip "/tmp/elementum.zip"

FROM ubuntu:jammy ENV ELEMENTUM_PATH="/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.elementum" RUN apt update \ && apt install ca-certificates -y \ && apt clean COPY --from=build /plugin.video.elementum "$ELEMENTUM_PATH"

RUN ln -s "$ELEMENTUM_PATH/resources/bin/linux_arm64/elementum" /usr/local/bin

CMD ["elementum"]

kovacicjanez commented 1 year ago

Hi. I am trying to run elementum binary in Alpine Linux and i get this error:

terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid

if i run under ubuntu it works... can some help me running it in alpine linux?

ShlomiD83 commented 1 year ago

Hi. I am trying to run elementum binary in Alpine Linux and i get this error:

terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_M_construct null not valid

if i run under ubuntu it works... can some help me running it in alpine linux?

maybe Alpine Linux is missing packages that Elementum needs in order to run via Docker.

Janhouse commented 1 year ago

I made a simple Dockerfile and docker-compose.yml together with readme to get it up and running quickly. Specify architecture, version and addresses in .env file and then just docker compose build && docker compose up https://github.com/Janhouse/elementum-docker

It does symlink default paths used on Android TV to avoid some errors, I guess those could also be parameterized. Just make a PR if necessary.

josser commented 1 year ago

Something is wrong with this setup but I can't understand is it something broken in plugin or in my configuration:

So, I have Kodi + Elementum installed on linux machine, works fine, but as it's has old cpu / gpu it can't handle hw acceleration for x265 playback.

So, I installed kodi + Elementum client on my xbox. On xbox I set 'Don't start binary' and set remote host to linux machine. On linux machine In Kodi services settings, I've enabled "Allow remote control from applications on other systems" Now If I open Elementum on xbox it can load Trakt playlists and I can do search. But when I select some video to play, nothing happens. I see on linux machine's screen that Burst is starting and looking for torrents but nothing more. Could somebody point me what is wrong with this setup or it's not intended to work?

mike-serchenia commented 1 year ago

You should have elementum plugin instead at the same location on both "client" and "server"

josser commented 1 year ago

@mike-serchenia What do you mean by 'location'? Some path or?

mike-sirs commented 1 year ago

@mike-serchenia What do you mean by 'location'? Some path or?

https://github.com/elgatito/plugin.video.elementum/issues/2#issuecomment-1137970110

so basically in my case, I have Firestick with Kodi and Elementum and NUC with dockerized Elementum
in the docker container I have elementum in

/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.elementum this path (location) is equal to what I have in my Firestick

On linux machine In Kodi

e.g You can create a symlink , just make sure your Linux machine has Elementum at the same location

josser commented 1 year ago

@mike-sirs looks like in my case (Xbox and Linux machine) I can't make any symlinks / mapping because path's are totally different

HobloBoblo commented 1 year ago

@mike-sirs looks like in my case (Xbox and Linux machine) I can't make any symlinks / mapping because path's are totally different

Surely you can create symlinks on linux side? That is enough.

Look at elementum log, it should be complaining about missing paths. Something like this (copied from some above message):

INFO config ▶ Reload Could not create temporary directory: &os.PathError{Op:"mkdir", Path:"\\storage\\emulated\\0\\Android\\data\\org.xbmc.kodi\\files\\.kodi\\temp\\elementum", Err:0x5}

Find out where your elementum directory is at linux box, then create a symlink at path where elementum is trying to open it.

You can usually just symlink the ".kodi" part, the rest of paths should match.

josser commented 1 year ago

@HobloBoblo But how I can symlink to C:/Program Files/ ... ?

BTW, even with

<advancedsettings>
    <loglevel>2</loglevel>  
</advancedsettings>

I don't see any complains about paths in the logs. Here is dump:

https://gist.github.com/josser/17d325137e4a798c795de42ef1e487a7

HobloBoblo commented 1 year ago

@josser elementum writes it's own log to standard output, you can redirect it to file if you like.

You don't need to be running Kodi in the Linux machine. Just run command:

.kodi/addons/plugin.video.elementum/resources/bin/linux_x64/elementum -remoteHost=192.168.0.123

where 192.168.0.123 is your xbox's IP address.

About the symlink part, "C:" is perfectly valid Linux directory name..:) But I'm not sure whether C: should be in root or inside .kodi directory. But you will see it when you look at the elementum output. Remember also that Linux requires that upper/lowercase is exactly correct in filenames.

josser commented 1 year ago

@HobloBoblo this looks a bit odd If I have xbox which can't run elemetum binary and I want that Elementum client on xbox to connect to Elementum daemon on linux machine. So xbox have to know address to connect and so, it looks more logical to specify linux ip in xbox settings

By this logic I set linux machine ip on xbox settings, and after that, it get ability to load Trakt playlist. So this steps looks correct.

Now, as I understand, I have to make some symlink on linux machine but to understand where this symlink have to be pointed I have to look into some log file. I have looked in:

Are you sure that logs from Elementum just don't go straight into main kodi.log? Because I see lines sometime related to plugin.video.elementum and this lines looks like log items from plugin.

josser commented 1 year ago

As for ability to run Elementum standalone on linux machine, I don't think it's possible:

 ./.kodi/addons/plugin.video.elementum/resources/bin/linux_x64/elementum -remoteHost=192.168.88.32
INFO  main         ▶ main             Starting Elementum daemon
INFO  main         ▶ main             Version: 0.1.87 LibTorrent: 1.1.14.0 Go: go1.19.4, Threads: 4
INFO  config       ▶ Reload           Reloading configuration...
INFO  config       ▶ Reload           Setting remote address to 192.168.88.32:65221
WARN  config       ▶ Reload           Can't continue because addon info is empty
ERRO  main         ▶ main             Could not get addon configuration: Could not get addon information from Kodi
josser commented 1 year ago

Ok! Looks like I understand the idea. We have two parts which have to know addresses to talk to each other. So, on xbox (the client) we have to specify linux ip, so It can know where is the server But client control all the settings so, linux (the server) have to know where to take this information.

The only thing I can't understand is how it supposed to work, as it looks like typical chicken-egg problem. client will not start until server is running server needs client to be running.

Znuff commented 1 year ago

Short story is that you can not really do that (xbox -> linux), as the paths have to match. Unfortunately this solution wasn't exactly designed for this scenario in mind.

As for running the binary on standalone linux, sure you can, it's just requires some tinkering.

Someone (@Janhouse) has provided a docker container somewhere, better to run that... but the paths still won't match because the Windows (or, Xbox in this case) uses different paths.

josser commented 1 year ago

@Znuff Hm, I can't find this right now but I definitely saw that this feature (remoteHost/localHost) was added explicitly for scenarios with xBox, it was explicitly mentioned in changelog

HobloBoblo commented 1 year ago

@josser I'm pretty sure you can get it working. I have similar setup with nvidia shield + Linux server, running for over a year now.

You need to start xbox Kodi first, then start elementum binary on Linux. Then it will fetch config and probably complain about the paths not matching, but then you can try to add symlinks until it works. :)

Once you have the server running, it will stay running even if you turn off xbox. But sometimes the server exits for some reason. You need some kind of a script or cronjob that restarts the server if the binary is not running.

josser commented 1 year ago

@HobloBoblo Your setup is very different 1) Both of your systems can run Elementum. In my case (Xbox - can't) So in your case, you can do something like:

But with xbox, it looks like there is no way to get elementum client up and running w/o elementum binary. You have to have binary already running somewhere.

2) The paths on linux starting from "/" so, if we want to have same paths on two different machines it's pretty easy to replicate any folder structure. On Windows, paths are starting from disk drive, i.e "C:" or "S:" (like on xBox) So, if we simplify a bit and we want to replicate path from windows: C:\Program Files\Kodi How this path should look on linux? /C:/Program Files/Kodi? (Notice, even slashes are different)

Anyway, with all this experiments I'm screwed up my small linux machine, so I give up. Elementum is unsupported and so, it's a road to nowhere. Even if I got new server with proper x265 hw encoding support, it's just a matter of time when elementum will stop working on current kodi. All this efforts are not worth, I can just download video and plug HDMI cable from my tv into my laptop.

antonsoroko commented 1 year ago

@josser

it looks like there is no way to get elementum client up and running w/o elementum binary.

iirc, you just need to enable "client mode" in settings, so python part of the plugin will not even try to run binary (golang) part of the plugin. https://github.com/elgatito/plugin.video.elementum/blob/7680e0bd365644a9cdae2e6b50bb55868f27593c/resources/site-packages/elementum/service.py#L21-L22 https://github.com/elgatito/plugin.video.elementum/blob/7680e0bd365644a9cdae2e6b50bb55868f27593c/resources/language/messages.pot#L1152-L1153

but about linux/windows paths differences - personally i do not know a magic trick to overcome that.

josser commented 1 year ago

@antonsoroko It will not run binary but it will try to connect too remote as specified in localHost field. And if there is nothing running on this host - it will not start.

saucepanlid commented 11 months ago

This seems to be working well for me for the most part. I am having trouble downloading subtitles though using the built in provider. It seems the path Elementum sends to Kodi to download the subtitle is incorrect. The path references the temp folder on the external nas and so when Kodi goes to download the subtitle to its local temp folder, it fails because it doesn't exist.

Any workaround for this? I'd imagine Elementum should instead send the Opensubtitle download url, so kodi can download the subtitle itself to its local temp folder?

Edit: Actually probably no point in fixing the existing implementation since Opensubtitles.org supposedly will deprecate their API by the end of this year. https://forum.opensubtitles.org/viewtopic.php?t=17930