Skip to content

Commit

Permalink
Added Support for downloads from text files and also added a lyrics p…
Browse files Browse the repository at this point in the history
…rovider. (#859)

* Added ability to download songs from a text file.

* Added Genius as a lyrics provider.

* Update songObj.py

* Fixed duplicates

* Used 're' to scrape lyrics and much more.

* autopep8 is a pain **

* autopep8 again :-(

* Made the necessary changes

* Minor Changes.

* Reverted back to C-Strings.

* Updated for readability.

Author: @s1as3r
  • Loading branch information
s1as3r authored Oct 19, 2020
1 parent 550746e commit 73c369c
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 70 deletions.
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:
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

0 comments on commit 73c369c

Please sign in to comment.