bleuzen / spotrec Goto Github PK
View Code? Open in Web Editor NEWSpotify desktop client recorder for PulseAudio
License: MIT License
Spotify desktop client recorder for PulseAudio
License: MIT License
I'd like to use this script with qobuz instead of spotify.
Would You be so kind to modify it for me (and maybe others)?
The option to save artwork to file instead would be nice.
This is the output when I run the command 'spotrec' in terminal ( endeavour os )
output:
Traceback (most recent call last):
File "/usr/bin/spotrec", line 22, in
import requests
ModuleNotFoundError: No module named 'requests'
How do I solve that issue?
Let me start off by saying that I love your tool, honestly!
I ran into an issue though when I tried to clone this repo and run it in a debugger, because I can't figure out which libraries I need to install. The Deps:
list in the script itself isn't that helpful to be honest:
python-dbus
is actually called dbus-python
python
in this list just mean that the interpreter has to be installed?bash
: Does this mean we rely on running the script in a surrounding that can be controlled via bash syntax or is that a pyhton library with the same name? pulseaudio
analogously.requests
is a library, I happen to know that at leastAll of this could be solved with a requirements.txt
file or whatever sort of dependency management appeals to you.
Keep up the good work, I appreciate it!
when I try to use SpotRec under EndlessOS (a OSTree/flatpak based Debian derivate), the ffmpeg command issued by by spotrec fails miserably with error: Unknown input format: 'pulse'
. I tried it with the static ffmpeg executable provided by John van Sickle, apparently it does not work with it, but I don't know if this is the reason for the failure or the cause is by insufficient rights in the flatpak sandbox. I guess that I might be able to use ffmpeg from your FFaudioConverter flatpak, but I don't know how to do that. So any hints are welcome. A --debug
output is here: spotrec.log.
At the moment, it just overwrites a file if it already exists.
I think it would be cool to have a command line option to skip these songs entirely and resume with the next song in the queue.
@Bleuzen if you agree with the feature request, I would give it a try to implement this by myself.
In my opinion, this is probably a pretty trivial fix, since we'd just have to use send_dbus_cmd("Next")
in case the file exist, right?
Hi,
I just tested SpotRec with a few songs and everything works fine. Thanks for that!
It's more a question but an issue:
Is it possible to disable the function that SpotRec records a little longer at the end?
If I'm recording a whole album, I sometimes have the problem, that the first chords of the song are in the flac-file of the previous song.
Best regards
J.
The recordings start a fraction of a second too late. This is especially noticeable in songs that start directly with a clear sound. Part of the sound is then missing from the recording, so that it is noticeable when listening to it. An example is the following song: https://open.spotify.com/track/6b7WHomwS4t8uNo9zAVqfr?si=c9e1ce747484405c ... There are several such songs on the album that start directly with a sound. Therefore, the problem can be reproduced.
My system is a Manjaro Linux with KDE Plasma Version 5.23.4, spotrec 0.15.1 and Spotify 1.1.72.439
Hi,
Would it be possible to remove ":" or "*" from name of title or artist?
These special characters prevent the file writing.
Thank you.
To allow greater automation for people who want to just set it and go, like myself. It's possible to make a playlist of all the songs you want with a silent track separating them.
You could then have an optional mode where you would read this as an end of track message and close ffmpeg.
This would also eliminate the pause > previous > play commands between each song. Simply start the next recording then send the next song command.
A nice 10 second example titled "Silent Track" from artist "Silent Track" is here:
http://open.spotify.com/track/5XSKC4d0y0DfcGbvDOiL93?si=V6UuIOkYRl2XrJOzhVHlIA
However, since this would then just shift the tedium from post processing to playlist creation, I've found a lovely playlist creator with conditionals, combiners and other goodies:
http://smarterplaylists.playlistmachinery.com/examples.html
I created a massive playlist of the silent track by continually copying its tracks into itself. I stopped at 8192. Then I used the "alternate" combiner to combine that playlist with my saved tracks. It stops once one list is exhausted. When run, it quickly spits out a nice silence gapped playlist =D.
What do you think?
When using -a and -c together the cover will not saved.
Excample command:
spotrec -o ./spotify --skip-intro -a --debug
gives this error:
2021-10-27 22:36:33,655 - DEBUG - [FFmpeg] [2075] Successfully renamed .04 - RAINASH - Dark Blue Sky.flac
2021-10-27 22:36:33,656 - DEBUG - [FFmpeg] Cover art is on server for ./spotify/04 - RAINASH - Dark Blue Sky.flac
2021-10-27 22:36:33,658 - DEBUG - Starting new HTTPS connection (1): i.scdn.co:443
2021-10-27 22:36:33,949 - DEBUG - https://i.scdn.co:443 "GET /image/ab67616d0000b2734eeb84104895cc348c822c44 HTTP/1.1" 200 127803
Exception in thread Thread-12:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.parent.add_cover_art()
self.run()
File "/usr/bin/spotrec", line 528, in run
File "/usr/bin/spotrec", line 577, in add_cover_art
with open(cover_file, "wb") as fd:
FileNotFoundError: [Errno 2] No such file or directory: './spotify/./spotify/04 - RAINASH - Dark Blue Sky.jpeg'
It looks like the script is messing up the path as it adds ./spotify/ , that is provided by the --output-directory, twice.
I have tried both the original and updated version, and the recording just loops around one or two songs.
By the way, have you looked at Audio Recorder as when the source is set to spotify it does what you are trying to achieve.
After the change to pipewire (ubuntu 22.04) everything worked as expected! But suddenly - maybe because of a general ubuntu update - spotrec only generates empty files. When running with -d debug messages I get:
2022-10-03 19:12:39,508 - INFO - [Spotify] Song changed: Amongst Liars - Amongst Liars/01 - Amongst Liars - Cut It
2022-10-03 19:12:44,510 - INFO - [SpotRec] Starting recording
2022-10-03 19:12:44,511 - DEBUG - [Shell] run: dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause
method return time=1664817164.562944 sender=:1.543 -> destination=:1.550 serial=95 reply_serial=2
2022-10-03 19:12:44,563 - DEBUG - [Shell] run: dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
method return time=1664817164.567402 sender=:1.543 -> destination=:1.551 serial=96 reply_serial=2
2022-10-03 19:12:44,568 - DEBUG - [Shell] Popen: ffmpeg -hide_banner -y -f pulse -ac 2 -ar 44100 -fragment_size 8820 -i spotrec.monitor -metadata artist='Amongst Liars' -metadata album='Amongst Liars' -metadata track=1 -metadata title='Cut It' -acodec mp3 -vn -b:a 192k './Amongst Liars - Amongst Liars/.01 - Amongst Liars - Cut It.mp3'
2022-10-03 19:12:44,568 - INFO - [FFmpeg] [115717] Recording started
2022-10-03 19:12:44,634 - INFO - [Spotify] State changed: Paused
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'spotrec.monitor':
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
2022-10-03 19:12:44,819 - DEBUG - [Shell] run: dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Play
method return time=1664817164.822670 sender=:1.543 -> destination=:1.552 serial=101 reply_serial=2
2022-10-03 19:12:44,857 - INFO - [Spotify] State changed: Playing
spotrec.monitor: Generic error in an external library
Output #0, mp3, to './Amongst Liars - Amongst Liars/.01 - Amongst Liars - Cut It.mp3':
Metadata:
TPE1 : Amongst Liars
TALB : Amongst Liars
TRCK : 1
TIT2 : Cut It
TSSE : Lavf58.76.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
Metadata:
encoder : Lavc58.134.100 libmp3lame
size= 1kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
Unfortunately the color get lost here. There is the line "spotrec.monitor: Generic error in an external library" that is marked red. I can also NOT find a recording stream in pavucontrol, but I guess this is a subsequent issue because of the generic error above.
Any glue how to debug deeper?
It would be fabulous if there was an option to turn off automatic pausing between recording different tracks. So that, for example, a playlist or an album is recorded in one piece. The background is that there are albums that are divided into individual titles but are actually related. The automatic pauses between the titles then create an untypical silence between the sections.
Why did you choose 2 seconds after the song stops?
https://github.com/Bleuzen/SpotRec/blob/master/spotrec.py#L48
Isnt a smaller value also working? With the current setup you must always cut the track, which is annoying. I know that recording to less is also not the best idea. Maybe this can be automated with ffmpeg? Did you check that already? Or what about also using 0.2 or 0.5 seconds?
Hi, first of all thanks for this gem.
Would it be possible to select output options of ffmpeg, or even simpler just a general selection of the output quality. e.g. for Audiobooks the quality could be mp3/96, not neccessary to have flac.
Cheers.
what is the intended way to run spotify? I mean I have the web player running as I am not aware of any native spotify client on linux. I even tried spotify-qt which also gets identified by pavucontrol as "Chrome". Pulseaudio is running ofc.. What do I miss here?
Package has been installed from AUR (running Manjaro Linux here)
spotrec --debug -s -u -o /home/foo/Musik/
2020-09-25 17:24:25,840 - DEBUG - Logger initialized
2020-09-25 17:24:25,842 - ERROR - Failed to connect to Spotify. (Maybe it's not running yet?)
as you can see it looks like there is no recording device which would be spotrec I guess. but as that cannot be started.. :
realized that maybe I need to install the package spotifyd and I did that as well - looking correctly connected:
but even now -- nothing changed at all. everything still the same. same error by spotrec and screens look identical.
While I like the flac format, for some cases, MP3 oder M4A would be great options. Shouldn't ffmpeg be capable to record to other formats easily?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.