fm16191 / spotify-recorder

Recorder for Spotify. Not a YouTube downloader !!!
32 stars 6 forks source link

Feature request: Record playlist #2

Closed kaigiessen closed 1 year ago

kaigiessen commented 2 years ago

Would be awesome to implement a feature that allows recording of entire spotify playlists.

fm16191 commented 2 years ago

That's indeed the best case scenario for the tool. I'll let you know when it's done.

rockstar2020 commented 1 year ago

Hi @fm16191 , I'm also very interested to use the playlist feature. Looking forward to hear some updates about this wonderful addition to your already fantastic code. Happy Holiday!

Cheers

fm16191 commented 1 year ago

Hi @kaigiessen, @rockstar2020, and sorry for the late update.

This feature should now be supported. I'm looking forward to hear about what you think of it, and if you encounter any difficulties or issues when using it.

Happy holidays!

rockstar2020 commented 1 year ago

Hi @fm16191 , I can confirm that the feature seem to be working fine so millions of thanks for adding this feature. However I have few issues which I think is related to my setup but I'm gonna share them with you hoping you can give me some troubleshooting hints. First of all I'm running this code on a Ubuntu 22.04 Desktop with all latest updates/upgrades.

Issues that I'm facing:

  1. I believe I should only run your code on the host PC because it requires to open Spotify app, correct? Is there a way to run it from command line remotely? I was planning to automate the download through a cron job. The issue is that spotify command throws "Segmentation Error" if it is run trhough a remote terminal. Any thoughts?
  2. Sometimes Spotify opens properly and the recording starts but at times it crashes so for playlist download this is going to be tricky. Is there a workaround?
  3. While recording, the playback volume is at 100% which is annoying if you run it at night. Can the recording also take place without the speaker out? Is there a setting in Pulse Audio?

Lastly, two more requests for future enhancements:

  1. Any plans to update the ID3 tags by adding the album artwork?
  2. Have you checked if it is possible to have Spotify playback in 2x or 5x speed so that the recording gets done faster? As you know there are many Windows applications out there which can record up to 10x speed.

Once again thanks for your great work and looking forward to your recommendations.

Cheers

fm16191 commented 1 year ago

Hi @rockstar2020 Great news, glad it does its job properly :)

  1. You can use xvfb to run it under a virtual display. Add xvfb-run right before spotify --uri ... in the spotdl.sh file as a short-term solution, an option to run it headlessly will be added soon
  2. Have you tried what I suggested in the "Recommended pulseaudio setup" section ? It might be worth taking a look if you haven't, otherwise, please open another issue providing more information, and I'll look into it.
  3. It can be done indeed, by adding another playing sink, which would only control the user audio output. I haven't decided to do it yet because it adds potential audio degradation factors, but it would be welcome, and I'm explicitly adding it to the to-do list

On the enhancements part :

  1. Definitively ! This one should be quick & easy. I'll do it too
  2. Well, I'm not sure how they manage to do that. This is not an option in pulseaudio as far as I know, nor in Spotify itself. I might end up looking further into it, but I would like the tool to be in a more complete structural state before :)
rockstar2020 commented 1 year ago

HI @fm16191 , Thanks for your response. In fact I was drafting a message to you but you beat me. :) I've got some updates for you:

  1. I fixed Spotify crashing issues by adding --no-zygote to Spotify CLI command in spotdl.sh. It now works flawlessly.
  2. Also I added my display's environmental variable (DISPLAY=:0) to the python command before executing api.py. Now I'm able to run the command via remote terminal enabling a GUI session. But unfortunately due to some permission errors I'm can't run the same command in cron but alternatively I can run it via ssh command in crontab from another PC. Not ideal for sure so still there's work to be done. I'll try what you suggested as well.
  3. I also added ID3 tagging feature within api.py file which works great but I did a quick and dirty work which needs a bit of cleaning.

And lastly I did follow your recommendations by changing the settings in pulse audio but since I didn't have the file "pulse.pa" I made the same changes into "default.pa" which I could find in /etc/pulse folder. Will that make any difference? Currently this is the only issue I'm focusing on to fix. Other cleanups can wait.

I general, your project pushed me to get closer to someting I was always looking for which was an automated recordinging of Spotify's songs in a playlist. So once agin thank you very much! Great work!

Any recommendations to fix Spotify/Pulse Audio issue would be highly appreciated.

Cheers

rockstar2020 commented 1 year ago

OK, now I managed to fix the audio output issue as well. :) All I did was to change the port from "Speaker" to "Headphones" which is basically unplugged and hence no audio coming out of speakers. FYI the command to run was pacmd set-sink-port 0 analog-output-headphones, or simply by adding set-sink-port 0 analog-output-headphones in the default.pa file. Obviously this may be different depending on the hardware you are running the code on. Cheers

fm16191 commented 1 year ago

Hi @rockstar2020, and sorry for the late answer.

  1. I have no real clue with what --no-zygote really does, but that seems to help sometimes indeed. As well, I've seen those options shared around --disable-gpu --disable-software-rasterizer that might help in similar cases.
  2. I did tried out back then, and I assume the issue was related to the environmental variable not being properly exported to the script, it must be an easier way to solve that issue
  3. ID3 tagging is now supported, for about two weeks via 4a1ca0b

I believe .pa filename depends on the OS, I guess that should do the trick.

The "switch to unplugged headphones" is a clever workaround ! I'll find an appropriate way to implement this feature in the future, but I haven't looked into it yet. :)

Thanks for the kind words, I'm glad it's (somewhat) functional and that it is helpful!

I'll be closing this, as the initial feature request has been fulfilled, and you have overcome all your issues. Thank you for you enthusiasm and your diagnoses, please don't hesitate to open a new one for any new problem/feature request !