Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for downloads from text files and also added a lyrics provider. #859

Merged
12 commits merged into from
Oct 19, 2020
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,10 @@ you use spotDL v3 and open issues for problems that you come across.
$pip install spotdl
```

2. For v3,
- Clone this repo
```
$git clone https://github.com/spotDL/spotify-downloader.git
```
- Run setup.py
```
$ cd spotify-downloader
$ python setup.py install
```
2. For v3, (latest version)
```
$pip install https://github.com/spotDL/spotify-downloader/archive/master.zip
```

3. Voila !

Expand All @@ -62,7 +56,7 @@ To download a song run,
# spotdl $trackUrl
spotdl https://open.spotify.com/track/08mG3Y1vljYA6bvDt4Wqkj?si=SxezdxmlTx-CaVoucHmrUA

To download a album run,
To download an album run,

# spotdl $albumUrl
spotdl https://open.spotify.com/album/2YMWspDGtbDgYULXvVQFM6?si=gF5dOQm8QUSo-NdZVsFjAQ
Expand Down Expand Up @@ -99,3 +93,7 @@ tracks for more speed.
1. [@ritiek](https://github.com/ritiek) for creating and maintaining spotDL for 4 years
2. [@rocketinventor](https://github.com/rocketinventor) for figuring out the YouTube Music querying
3. [@Mikhail-Zex](https://github.com/Mikhail-Zex) for, never mind...

# A few interesting forks
1. [aasmpro/spotify/downloader](https://github.com/aasmpro/spotify-downloader)
- Sets metadata for songs that are already downloaded (v2 only.)
25 changes: 18 additions & 7 deletions spotdl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def console_entry_point():
sys.stderr = quiet()

initialize(
clientId='4fe3fecfe5334023a1472516cc99d805',
clientSecret='0f02b7c483c04257984695007a4a8d5c'
clientId = '4fe3fecfe5334023a1472516cc99d805',
clientSecret = '0f02b7c483c04257984695007a4a8d5c'
)

downloader = DownloadManager()

for request in cliArgs[1:]:
Expand All @@ -98,11 +98,22 @@ def console_entry_point():
songObjList = get_playlist_tracks(request)

downloader.download_multiple_songs(songObjList)


elif request.endswith('.txt'):
print('Fetching songs from %s...' % request)
songObjList = []

with open(request, 'r') as songFile:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CliArgs is a list, it's much more simpler to add the links to CliArgs - that way, the .txt file can have song, playlist and album links and still work.

From a maintenance standpoint, fewer lines of code is always better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, there's a catch, if the .txt file is the last argument, spotdl will just skip the songs. And it won't be able to take advantage of parallel downloads.

for songLink in songFile.readlines():
song = SongObj.from_url(songLink)
songObjList.append(song)

downloader.download_multiple_songs(songObjList)

elif request.endswith('.spotdlTrackingFile'):
print('Preparing to resume download...')
downloader.resume_download_from_tracking_file(request)

else:
print('Searching for song "%s"...' % request)
try:
Expand All @@ -111,10 +122,10 @@ def console_entry_point():

except Exception:
print('No song named "%s" could be found on spotify' % request)

downloader.close()

if __name__ == '__main__':
freeze_support()

console_entry_point()
console_entry_point()
9 changes: 9 additions & 0 deletions spotdl/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from spotdl.patches.pyTube import YouTube

from mutagen.easyid3 import EasyID3, ID3
from mutagen.id3 import USLT
from mutagen.id3 import APIC as AlbumCover

from urllib.request import urlopen
Expand Down Expand Up @@ -217,6 +218,14 @@ def download_song(songObj: SongObj, displayManager: DisplayManager = None,
data = rawAlbumArt
)

#! adding lyrics
try:
lyrics = songObj.get_song_lyrics()
USLTOutput = USLT(encoding=3, lang=u'eng', desc=u'desc', text=lyrics)
audioFile["USLT::'eng'"] = USLTOutput
except:
pass

audioFile.save(v2_version = 3)

# Do the necessary cleanup
Expand Down
Loading