There are many good reasons for having an alternative to your smartphone when you want to listen to music: Maybe you don’t want to have to check your notifications when choosing another song. Maybe you don’t want to be distracted from what you’re doing while listening to music. Maybe you want the freedom to ditch your smartphone for a while, without having the option to listen to music be gone with it.
These reasons and more are why I keep my Sony Walkman around and still use it regularly. You might associate the name with portable cassette players, but that’s not what I’m talking about here. Sony simply kept the recognizable name when moving on into the digital realm and gave it to their line of portable media players. I have a Sony Walkman NWZ-A15 from 2014, which can play hi-res “.flac” files, has a feature OS, no wifi, but bluetooth (surprisingly), a SD-card slot and a headphone jack. In the last two aspects it even beats my current smartphone. I have a 512 GB Micro SD card installed there that can fit all my music, which sadly can’t be said for my smartphone. Of course, the Walkman product line continued after that, newer devices even have Android on them. That might be useful for streaming services, but I’m unsure if the concept works and never personally used the successors to my device.
What I can’t really do with my Walkman is create playlists. Smartphones are simply better in that aspect. But it can theoretically use playlists, as long as they were created on a PC and transferred over USB. Because playlists are an important thing to have, I looked into that option. Maybe there is some proprietary Windows software from Sony for the task, but I never looked into that, because you can simply create playlists in your music playing software and then copy them to the device. You just have to make sure about two things: Firstly you have to create the playlists from the music files that are on your Walkman. And secondly, you have to use Windows. The second one is a problem in my case: I’m very happy with using Fedora Linux, but I still want to be able to listen to playlists on my Walkman. So what do I do?
Playlists created under Linux won’t work. But why is that? .m3u files aren’t Windows-exclusive. But they look a bit different when created on different platforms and the reason for that is path structure.
The paths to a music file look like this under Windows:
C:\music\sample.mp3
and like this under Linux:
/home/user/music/sample.mp3
The problem looks to be quite easy to figure out. The paths in the playlist files work differently when created under Linux and the Walkman only recognizes Windows-style paths, which is a bit sad, but I can’t really change that. But how do I make Linux-created playlists work then on my Walkman? The solution: I write some Python code to convert them, before copying them over onto the Walkman. This could work!
My small Python project is called “walkman_playlists” and the script can read playlists, understand the content by parsing it and converts the paths into “Windows-style”. After that, it writes a new playlist file, which can be understood by the Walkman. Some things need to be considered: Firstly, the root (beginnings) of the paths are different, so I have to replace the Linux path to the Walkman home folder with a drive letter (which one doesn’t seem to matter). Secondly, the VLC media player under Linux applies URL encoding to the paths, for example a space character becomes “%20” in the middle of the path. I took care of that with the function “parse” of the Python library urllib, writing spaces and special characters plainly into the playlist files, so the Walkman can understand them. Finally, just replace all backward-slashes with forward-slashes. And done! I figured all this out by trial and error, by the way.
With this code, I can already create working playlists for my Walkman, even though I’m using Linux, and that’s my reward. But since it’s my own code and not some proprietary software and I fully understand it, I can easily add new features and functions now, improving the process!
As I mentioned before, the Walkman normally needs to be connected to the PC to create and save playlist files and these won’t work without the Walkman either, because the files referenced in the playlists are the ones on the Walkman. That’s more than a bit inconvenient and it made me think.
What I already do is mirror my music library to the SD Card inserted into the Walkman (using the command line tool rysnc). This means that the folder structure and files are the exact same, just the beginning of the path is different, pointing either to the files on my PC or to the files on the Walkman. So what I did is modify the code so that it can account for that. When I’m converting playlist files from my PC, I can also change the beginning of each path to point the Walkman. A simple change really, but it took some ingenuity to come up with something like that.
But the end result is the following: I can create playlists using my local library, without having the Walkman connected to the PC and the script can still make them work. With this done, I wrote a second script using this function to automatically sync my local playlist directory to the Walkman while converting them and attached it to the script which I use to sync files anyway.
And that’s most of what my “walkman_playlists” Python project is doing! I wanted to write this down for people interested in details about what I code privately. But more importantly, I hope it inspires people to come up with use cases for their own code in their daily lives. The second part of the blog post, about making code even do even more than initially planned, demonstrates how fun and useful it can be to write code for your own use case, instead for looking for proprietary solutions every time, or simply giving up because of software barriers. This project is also important to me because it is my main private project and it has been in development over several years. Every time I learned something new about Python or software development, I applied it here, improving my skills and improving the software.
Code created because of individual interests is the start of many important FOSS (Free and Open Source Software) projects out there which play a huge part in our lives in the internet age. However, I doubt some other person has use for my specific solution here. Please let me know if that’s wrong though. I might even take the time to polish & publish the code, so that other people can use it to make playlists work on their Walkman.
Thank you for reading!