Comments (1)
Hi
I had the same problem and I figure it out why this is happening. This is because the spotify API can only do 100 tracks at a time and if your playlist have more then 100 it will crash. You can make multiple playlist with 100 songs and do them one by one. I fixed the problem in the code by creating a counter to go from 100 to 0 so it will still download and not crash but will only download the first 100 songs. The problem is in write_tracks and this is the code that I have:
def write_tracks(text_file: str, tracks: dict):
# This includins the name, artist, and spotify URL. Each is delimited by a comma.
with open(text_file, 'w+', encoding='utf-8') as file_out:
count = 100 #this is the counter from 100
while count > 0: #will run until is 0
for item in tracks['items']:
count = -1 #subtract one from it each time
if 'track' in item:
track = item['track']
else:
track = item
try:
track_url = track['external_urls']['spotify']
track_name = track['name']
track_artist = track['artists'][0]['name']
album_art_url = track['album']['images'][0]['url']
csv_line = track_name + "," + track_artist + "," + track_url + "," + album_art_url + "\n"
try:
file_out.write(csv_line)
except UnicodeEncodeError: # Most likely caused by non-English song names
print("Track named {} failed due to an encoding error. This is \
most likely due to this song having a non-English name.".format(track_name))
except KeyError:
print(u'Skipping track {0} by {1} (local only?)'.format(
track['name'], track['artists'][0]['name']))
# 1 page = 50 results, check if there are more pages
if tracks['next']:
tracks = spotify.next(tracks)
else:
break
I will try to make it download more then that but I don't have time now:)
I hope the creator of this will fix this soon:)
Hope it "helps" a bit:)
from spotify-to-mp3-python.
Related Issues (13)
- YoutubeSearch returns 'url_suffix' insteal of 'link' for video watch address HOT 1
- Problem: Only valid bearer authentication supported HOT 2
- Only valid bearer authentication supported, reason: None HOT 1
- HTTP Error for GET to https://api.spotify.com/v1/playlists/ returned 400 due to Only valid bearer authentication supported HOT 6
- This playlist not download HOT 1
- Can't seem to figure out how this works HOT 4
- <playlistname>.txt already exists HOT 1
- 'charmap' codec can't encode characters HOT 2
- ffprobe and ffmpeg not found. HOT 1
- Doesn't add album art
- Got error: HTTP Error 403: Forbidden
- Nothing happening
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spotify-to-mp3-python.