Displaying information about the current print on a stream
 
Avisos
Vaciar todo

Displaying information about the current print on a stream  

  RSS
Scott Gartner
(@scott-gartner)
Eminent Member
Displaying information about the current print on a stream

I am running a Twitch stream reflecting my current print ( https://www.twitch.tv/omnius42) and on that stream I'm using OBS.  I couldn't find a better way to show the current print status than to display a portion of the Prusa Connect dashboard.  Unfortunately, this really doesn't work consistently because the image doesn't get updated properly if a user isn't using the web browser, and it's pretty fragile (using that desktop for any other work can end up displaying part of a web page unintentionally through the stream).

I tried loading the dashboard in an iFrame and then pulling out the parts I wanted, but the website doesn't allow that to happen (which I totally get).

Is there another way I can get this information to display in OBS?  An API, or a URL on Prusa Connect that only shows the print status, or something?  The only API I could find documentation for was about using a camera to supply photo frames to the connect web application.

To be clear, we use this stream to share the print status among ourselves as well as to the person who requested the print.  The information I really want to be able to display is the name of the print, the expected completion time, and the percentage complete.  Anything else would be gravy.

Thanks!

Best Answer by Scott Gartner:

Just updating here that I was able to write the proxy that I intimated I would.  I have published the code here: https://github.com/42degrees/PrusaPrinterApiForObs

Feel free to use it if you find it helpful.  This shows the output of the proxy dynamically updating on my video stream.

Respondido : 09/12/2023 9:01 pm
Scott Gartner
(@scott-gartner)
Eminent Member
Topic starter answered:
RE: Displaying information about the current print on a stream

I'm going to give this another try.  I can see that the printer has an API, since the embedded web application is calling that API.  The API that I want to call is:

http://192.168.1.40/api/v1/status

I tried calling this from the browser and it works fine, returns a nice piece of JSON that I can parse.  So, I then tried calling it from Postman, and it just returns 408 (Request Timeout).  I tried writing a simple C# program to call the API.  I get the same 408 (Request Timeout).  If I don't include the Basic auth header then I get 401 unauthorized, so I'm getting to the printer's API, it's just not returning the JSON block.  From reading forums I also tried setting a custom header "X-Api-Key" with my API key from connect.prusa3d.com but that doesn't change the behavior at all.  Can anyone shed light on this for me?

 

Respondido : 25/01/2024 5:11 am
Scott Gartner
(@scott-gartner)
Eminent Member
Topic starter answered:
RE: Displaying information about the current print on a stream

OK, I noticed that the embedded web application is using digest authentication.  If I copy the current digest and use it in my C# program, I can get into the API.  This isn't a real solution because the digest expires fairly quickly and so my program only works for a short time with the digest in there.  

However, I used Epic browser (that doesn't have any history and has never used the embedded web application) and it works to use a URL encoded with user and password.  I'm calling the API with the username and password in the url like this (not my real password):

http://maker:[email protected]/api/v1/status

This works just fine in the browser, but doesn't work elsewhere.  Now, this notation should be functionally equivalent using Basic auth, so I'm still confused.  Does anyone have an example of the "right" way to call the printer's API?

Respondido : 25/01/2024 5:43 am
Scott Gartner
(@scott-gartner)
Eminent Member
Topic starter answered:
RE: Displaying information about the current print on a stream

I neglected to mention that I was able to get Postman to work now that I know it requires digest authorization. However, I still have not been able to get my C# application to work with Digest Auth (I get the error, "Cannot load all required data from authenticateHeader"). So, I'm still stuck there.

I don't think there's a plugin for OBS that supports digest auth either, but I may be able to write a proxy that talks to the printer on one side and the OBS plug-in on the other.

Respondido : 25/01/2024 7:08 am
Scott Gartner
(@scott-gartner)
Eminent Member
Topic starter answered:
RE: Displaying information about the current print on a stream

Just updating here that I was able to write the proxy that I intimated I would.  I have published the code here: https://github.com/42degrees/PrusaPrinterApiForObs

Feel free to use it if you find it helpful.  This shows the output of the proxy dynamically updating on my video stream.

Respondido : 02/02/2024 3:27 am
ssmith me gusta
Compartir: