Comments (4)
@patrickbolle This feature is actually included already, but it's kind of experimental and I don't really call it out in the documentation. But if you start the script with -f, it will dump all of the song titles to the file /tmp/somafm_tracks.txt (or wherever temporary files are on your OS). If you're pulling the script from Git (rather than downloading it via pip), you can change the location of this file on line 68.
I used this to show track info from within the i3 window manager with a simple script, but if it's something other people would find useful, it could certainly be polished up a bit.
P.S.
Sorry for the delay in responding, for some reason I never get email notifications for new Issues of my own repos, still trying to figure out what the problem is.
from somafm.
I was also interested in the specific functionality OP is looking for. I think the key bit is the "push a button to save the current song". It's akin to the "love/thumbsup" functionality found on streaming services.
My use case is that sometimes I hear some great new artist that I want to look into later more deeply. Having a list of every song is not all that helpful for this as I probably won't remember specifically which songs I liked. A text or json or whatever file with just the liked ones though would be ideal.
I did look briefly into doing this but it would be invasive on a technical level, we would need to add an additional thread or multiprocessing to handle UI inputs. I'm happy to do it but it's such an big change I imagine I'll architect it in a different way to how you would - if you would like to me to anyway, let me know and if you've got some thoughts on how.
I was thinking of keeping something similar to what is there now, but the display functionality of streamInfo is moved into it's own thread. The "main" thread now pumps the line info through a queue into streamInfo. Still need to solve keypress handling though, so possibly it would be easier using something like Textualize (heavy dependency though).
from somafm.
Yeah, it would be tricky to capture key presses with the way things work now. Anything that seems like interactivity (such as changing the volume or quitting the player) aren't actually being done by the script, but it's the background player reacting to the input.
I wouldn't be against trying to implement something like this, but it would have to be optional. I don't want to get into a situation where a UI framework is a required dependency just for one feature.
from somafm.
So I actually had a bit of inspiration last night, and figured out how to implement this in a fairly straightforward way, although as of right now it only works when using MPlayer as the backend.
Basically, going on the idea that all the key presses are being passed to MPlayer invisibly and the script is just looking for strings in the output, I started pressing keys and looking to see if there was something we could latch onto for a feature like this. As luck would have it MPlayer has a capture option that's triggered by pressing C, but since it's not configured on the command line, it just prints something like "Capture not configured" in the output.
Long story short, by listening for this line in the output, we can detect when C is being pressed and it doesn't impact playback!
Here you can see a quick demo of what I'm working on right now: when you press C, a little floppy icon shows up next to the currently playing song and the track info is written to "favorites.txt" in the current directory:
I'll push the changes I've made shortly, would appreciate any testing/feedback.
from somafm.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from somafm.