tyrsarm / peertube-headless-seeder

This container uses Python, Selenium, and Firefox to monitor and seed live streams of a PeerTube channel headlessly.
17 stars 3 forks source link

[Discussion] Make the scripts so they call the API once instead of three times #10

Open tyrsarm opened 1 year ago

tyrsarm commented 1 year ago

Right now the scripts call the Peertube instance API three times every time the status of the channel is updated. I would like to only call the API once per status update and parse the necessary data from a single JSON output from the API. Currently, the scripts do not share the JSON data. I am thinking of maybe creating an environment variable that would update with the JSON data but I do not know what limitations environment variables have regarding the amount and type of data that they can hold. What would be the most efficient way to have the JSON data shared between the Python scripts?

CGBassPlayer commented 1 year ago

Is there anything wrong with passing the JSON data as a parameter? What I would do is have all the code in the other scripts into functions that way you can import the function call and pass the required parameters around. It also remove the need to use env vars or files for the isLive, isPlaying and things of the like.

tyrsarm commented 1 year ago

I did not think about using parameters for sharing the JSON data. Is there a way that the scripts can pull updated parameters while running? If so that would be the way to go.

tyrsarm commented 1 year ago

I missed the part of making the other scripts in to functions. That could actually work. I originally made separate scripts so that the PlayLive script can run and while the other scripts continued to get new information.

CGBassPlayer commented 1 year ago

You still could. Just instead if using the of using the exec on a file, you would just call the function instead

tyrsarm commented 1 year ago

After looking more into making the other scripts into functions in the main py, I think I can get it to work. I am thinking about calling the functions on a timer. For the PlayLive function I am thinking about using threading on it so that the variables get to update or need to figure out the logic necessary for stopping the Selenium instance when isLive turns from true to false. What would be the best way to go about this? I am starting to lean to monitor isLive as a separate function.

Strit commented 1 year ago

Any updates on this?

CGBassPlayer commented 1 year ago

No update from me. Life got busy quick so I have not looked through this like I originally anticipated. Commit history looks quiet as well so I doubt there has been much done here.

tyrsarm commented 1 year ago

I have no update as of right now. I am looking at rewriting most of the python structure to fix this issue and the text files to environment variables. Life has gotten in the way on my side but I have not forgotten nor given up on this project.