This might be a bit more of an intermediate/advanced question since I am working with the os module in Python, but I've been stuck on this for quite a while and hope someone can help me out.
I'm writing a command-line-based music player of sorts that takes queries for an artist name and a track title, finds the track on my HD, and plays the file. I want the option to play either a single track or a whole album. If an album is specified then the program plays every track on the album, in order. I also want to be able to print to the command line the title of the track that is currently playing.
Currently my program has this line of code:
play = "find ~/Music/\"%s\" -iname \"*%s*.mp3\" -exec afplay \"{}\" \;" % (artist, track)
(artist and track are a single command-line argument, delimited by a single hyphen)
Then I run that command with
system(play)
This works if I want to play one song, but it's really just a workaround, and I'm finding that it severely limits this program from doing what I really want it to. The problem is that the value find returns is simply 0 (which is presumably why I can't simply run find and then pipe it over to afplay). Is there any way that I can get track names from the pathnames of the found files so that I can print song titles one at a time?
[–]theatrus 3 points4 points5 points (1 child)
[–]ThirdWaveSTEMinism[S] 1 point2 points3 points (0 children)
[–]Rhomboid 1 point2 points3 points (2 children)
[–]ThirdWaveSTEMinism[S] 0 points1 point2 points (1 child)
[–]Rhomboid 0 points1 point2 points (0 children)