Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Ability to show upcoming #43

Open
bonelifer opened this issue Mar 20, 2024 · 8 comments
Open

[Feature] Ability to show upcoming #43

bonelifer opened this issue Mar 20, 2024 · 8 comments

Comments

@bonelifer
Copy link

The ability to show upcoming track.

@Doug-Wyman
Copy link

I hadn't notices that pianobar had a -u command. If I can (or anyone else) this would be nice. It is most all Javascript which I've only dabbled at but we will see..

@bonelifer
Copy link
Author

Yes, it displays the next two Tracks.

@Doug-Wyman
Copy link

@bonelifer Yes, I just did an experiment. However to get this information one would have to be screen-scraping the output of pianobar and I don't think Patiobar is doing that. I think thy do as my mqtt interface does and passes keystrokes and watches the config for the four files of information kept there. I haven't done screen scraping since the 80s but it is possible. One would I presume have to run pianobar inside a shell or pipe the output to a program.

@bonelifer
Copy link
Author

bonelifer commented Mar 21, 2024

I may add a feature request to pianobar's repo. Done, see what happens: PromyLOPh/pianobar#746

@Doug-Wyman
Copy link

I just had a brain flash. I will try it but one should be able to use pianobar > myprog.py and have myprog.py either

  1. write to a ,config file as pianobar does, over writing previous send a mosquitto message of the new line from Pianobar. Then any other person's app could read line. I fear returns from pianobar that are multi-line might be missed so...
  2. Send a mosquitto message of the line than anyone else's app could process that line. One could also monitor that mqtt for one of Pianobar's failures to connect errors

@Doug-Wyman
Copy link

Doug-Wyman commented Mar 23, 2024

Ok, quick and dirty check on feasibility shows the added benefit of mqtt as it will chirp once a second showing the time remaining on the song: [AI code]

`import subprocess.

Define your command (e.g., 'ls' to list files)

my_cmd = 'pianobar'

Run the command and capture the output in real time

with subprocess.Popen(my_cmd, shell=True, stdout=subprocess.PIPE, text=True) as process:
for line in process.stdout:
# Process each line (for demonstration, just printing them)
print(f"Received: {line.strip()}")
`

@Doug-Wyman
Copy link

Doug-Wyman commented Mar 23, 2024

I have the following so far. I am going to formalize it a bit and make a repository for it.
The upcoming format is the same as station list it seems more work needed
There are probably a lot better ways to parse out the info and hints are welcome:
`import subprocess
my_cmd = 'pianobar'

with subprocess.Popen(my_cmd, shell=True, stdout=subprocess.PIPE, text=True) as process:
for line in process.stdout:
line = line[4:]
if line[0:1] == "#":
print("TIME: " + line[4:], end = "\r")
elif line[0:19] == "(i) Control fifo at":
print("*** cmd location: " + line[19:len(line) -7])
elif line[0:2] == "|>":
print("Song Info: " + line[4:])
elif line.find("0)") > -1:
print("Upcoming: " + line[2:])
elif line.find("1)") > -1 :
print("Upcoming1: " + line[2:])
elif line.find("2)") > -1 :
print("Upcoming2: " + line[2:])
else:
print(f"Received: {line[2:]}")
`

@Doug-Wyman
Copy link

@kylejohnson I've published my MQTT Pianobar https://github.com/Doug-Wyman/MQTT_Pianobar I hope I have given you the credit you deserve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants