miraclx / freyr-js

A tool for downloading songs from music streaming services like Spotify and Apple Music.
https://git.io/freyr-js
Apache License 2.0
1.54k stars 100 forks source link

Output directory #258

Closed Vitiligote closed 2 years ago

Vitiligote commented 2 years ago

Hello, Can we have two outputs when i dowload a song? Thanks

miraclx commented 2 years ago

Hey man, can you explain what you mean please?

You want to save one track download to two folders?

Can't you just copy the downloaded file after?

Vitiligote commented 2 years ago

It's quite complicated. I would like, when I download music, it automatically integrates into my songs from Apple music. First I tried dragging the download directly to iTunes' "Automatically add to iTunes" folder but that worked half the time because of embedding data. I figured I was going to download the music first, copy the music to a folder and then move it to the Automatically add to iTunes folder using the cp and mv function in Terminal. It works. To make it even easier, I decided to create a playlist on Apple music with all the new songs I need to download. As via Freyr, I just have to launch the same download of my playlist each time. The problem is that when I first download my playlist, I need my Freyr source folder to contain the old music already downloaded in order to avoid re-downloading them each time and I also need another folder containing only newly downloaded songs so as not to put old ones back in the Automatically Add to iTunes folder. I don't know if you followed me and I hope you can help me. Thanks in advance

miraclx commented 2 years ago

Two options, not sure which one resonates most with what you're trying to achieve.

  1. Tell freyr to save the songs directly into your iTunes music library. Freyr has the -d, --directory <DIR> flag, so you can use freyr in this manner:

    freyr -d /path/to/library <urls...>
  2. You can synchronize the freyr download folder to your iTunes music library. Using something like rsync. This would skip over the already-copied files, and copy new ones. But this would mean you'll be maintaining two different libraries, with a storage implication from this duplicity. One managed by freyr and the other by iTunes.
Vitiligote commented 2 years ago

For the first, as I said, the synchronization is not done well half the time because of the embedding data

For rsync, I just tried in iTunes music file, however the synchronization does not happen automatically, that's why I used the automatically add folder to iTunes

miraclx commented 2 years ago

Yeah, I'm not sure what I can do to aid this, I don't use iTunes anymore. And if anything, it'd be out of scope of this project.

miraclx commented 2 years ago

Hi @Vitiligote, I just got a MacBook and this makes sense now 😆

Hm, it's a tricky case. But I'll find a workaround.

I'm thinking I can make the -d, --directory flag a bit more sophisticated than it currently is.

Maybe instead of taking one argument that is a folder path, it can take multiple folder paths, delimited by :

So in the case of: freyr -d ./a:./b <url>

It would check if the track exists in either ./a or ./b, and if it doesn't exist, it downloads it into the last directory ./b.

Vitiligote commented 2 years ago

Hi, Excellent idea, I have since been able to solve my problem by fiddling a bit, but if you can do it, it would simplify my code!!

miraclx commented 2 years ago

@Vitiligote, can you share your solution?

Vitiligote commented 2 years ago

Hi, of course. I work with apple script. I created a playlist on apple music on which I add the new songs that I want to download. I launch the Freyr script of my playlist and at the end of the download I launch an apple script to move the downloaded music to another playlist in order to avoid the music already downloaded for the next times. It's a bit tedious but it works. However, it doesn't work with spotify playlists because I can't delete or move the music already downloaded...

freyr -d ~/Music/Freyr apple_music:playlist:pl.u-76oNPjetv34qPAN -s gb;
cp -R ~/Music/Freyr/*/*/*.m4a ~/Music/Musique; 
ls -tr ~/Music/Musique | while read LREAD
do;
mv ~/Music/Musique/${LREAD} ~/Music/iTunes/iTunes\ Media/Automatically\ Add\ to\ Music.localized ; 
sleep 10;
echo "Ajout de la musique" ${LREAD} "à la bibliothèque";
done;
osascript /Users/Simon/Downloads/move_tracks_playlist_freyr.scpt

move_tracks_playlist_freyr.scpt -->

tell application "Music"
    move tracks of playlist "Freyr" to playlist "Test"
end tell
miraclx commented 2 years ago

Implemented in #350. Took a different approach than I mentioned earlier. Should be more intuitive.