spotify-web-helper
spotify-web-helper copied to clipboard
Get listening port directly
Just discovered this project; great work!
Was just looking at how you find the port and thought you could get it directly by looking at listening ports by process ID, rather than by sequential scan, e.g.:
netstat -lptn 2>/dev/null |sed -n -e 's/^.*127.0.0.1:\([[:digit:]]\+\)\s.*spotify.*$/\1/p'
I've tested this on Linux; I would have thought it would work unmodified on MacOS, but might need some work on Windows.
Hi atatadot!
Thank you! This sounds like great potential to optimize. For me it does not seem to work on macOS. The command does not fail, but the output is empty.
The issue is either with netstat or with sed. I believe sed is a bit variable between between systems. Can you paste the whole output of netstat -lptn
and I'll have a look? With spotify web helper running, obviously!
Sure, we can remote debug this.
This is what I see:
Try this instead; should work on both Linux and Mac OS:
lsof -iTCP@localhost -sTCP:LISTEN |sed -n -e 's/^spotify.*localhost:\([[:digit:]]\+\)\s.*$/\1/p'
Unfortunately not..