anishathalye / seashells

The official client for seashells.io 🐚
https://seashells.io
MIT License
708 stars 20 forks source link

Know URL ahead of time #12

Closed RobinMalfait closed 6 years ago

RobinMalfait commented 6 years ago

It would be cool to have a way of knowing the url ahead of time or reserving a url.

A use case for this is:

  1. Know URL
  2. Post URL to Slack for example
  3. Start streaming output

If somebody knows a workaround to get the URL from the output programatically that would be cool.

anishathalye commented 6 years ago

Yeah, this is a neat idea, and it's something that's on the list for v2.0. It probably requires some kind of accounts system and some more infrastructure to prevent abuse, which is why this feature doesn't exist already. But I think eventually we might have (optional) named sessions like seashells.io/u/{username}/{session name}.

If all you want to do is get the URL from the output, that's pretty easy to do. The current Seashells protocol is very simple: you connect to a TCP socket and start dumping data into it, and the server replies back with the link. Getting this link programmatically should be easy.

RobinMalfait commented 6 years ago

Hello @anishathalye thanks for the quick reply!

We tried to get the url from the output but since we are dumping a lot of data into it we couldn't figure it out yet.

We use it for something else, but this is the essence. The seashells url does get dumped in the console. But I didn't find a way to read it yet.

cat /dev/random | seashells --delay 10
anishathalye commented 6 years ago

You need to read stderr from the seashells process.

Alternatively, you could just modify the seashells script itself. You could change this: https://github.com/anishathalye/seashells/blob/master/seashells/__init__.py#L100 so it gets the first line of output from the server (which is the URL) and then does something useful with it.

RobinMalfait commented 6 years ago

Great, thank you for clarifying @anishathalye ! Reading stderr did the trick, closing now!

🎉