mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Test spotify generated songname
This commit is contained in:
1
.cache/v/cache/lastfailed
vendored
Normal file
1
.cache/v/cache/lastfailed
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
__pycache__/
|
__pycache__/
|
||||||
/Music/
|
Music/
|
||||||
/*.txt
|
/*.txt
|
||||||
|
|||||||
19
spotdl.py
19
spotdl.py
@@ -19,7 +19,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import urllib.request as urllib2
|
import urllib.request as urllib2
|
||||||
|
|
||||||
# decode spotify link to "[artist] - [song]"
|
# "[artist] - [song]"
|
||||||
def generate_songname(raw_song):
|
def generate_songname(raw_song):
|
||||||
if misc.is_spotify(raw_song):
|
if misc.is_spotify(raw_song):
|
||||||
tags = generate_metadata(raw_song)
|
tags = generate_metadata(raw_song)
|
||||||
@@ -105,7 +105,7 @@ def go_pafy(raw_song):
|
|||||||
return pafy.new(trackURL)
|
return pafy.new(trackURL)
|
||||||
|
|
||||||
# title of the YouTube video
|
# title of the YouTube video
|
||||||
def get_YouTube_title(content, number):
|
def get_YouTube_title(content, number=None):
|
||||||
title = misc.fix_encoding(content.title)
|
title = misc.fix_encoding(content.title)
|
||||||
if number is None:
|
if number is None:
|
||||||
return title
|
return title
|
||||||
@@ -259,18 +259,21 @@ def grab_single(raw_song, number=None):
|
|||||||
else:
|
else:
|
||||||
print('No audio streams available')
|
print('No audio streams available')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
class Args(object):
|
||||||
|
manual = False
|
||||||
os.chdir(sys.path[0])
|
|
||||||
|
|
||||||
misc.filter_path('Music')
|
|
||||||
|
|
||||||
|
args = Args()
|
||||||
# token is mandatory when using Spotify's API
|
# token is mandatory when using Spotify's API
|
||||||
# https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/
|
# https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/
|
||||||
token = misc.generate_token()
|
token = misc.generate_token()
|
||||||
spotify = spotipy.Spotify(auth=token)
|
spotify = spotipy.Spotify(auth=token)
|
||||||
|
|
||||||
# set up arguments
|
misc.filter_path('Music')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
os.chdir(sys.path[0])
|
||||||
|
|
||||||
args = misc.get_arguments()
|
args = misc.get_arguments()
|
||||||
|
|
||||||
if args.song:
|
if args.song:
|
||||||
|
|||||||
3
test/.cache/v/cache/lastfailed
vendored
Normal file
3
test/.cache/v/cache/lastfailed
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"test_youtube.py": true
|
||||||
|
}
|
||||||
9
test/test_spotify.py
Normal file
9
test/test_spotify.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
|
import spotdl
|
||||||
|
|
||||||
|
def test_songname():
|
||||||
|
song = "http://open.spotify.com/track/2e0jnySVkYF1pvBlpoNX1Y"
|
||||||
|
expected_title = "David André Østby - Tilbake (SAEVIK Remix)"
|
||||||
|
title = spotdl.generate_songname(song)
|
||||||
|
assert title == expected_title
|
||||||
Reference in New Issue
Block a user