Why Can't I Play The MIDI Files I Have Downloaded Programmatically, But I Can Play Them When I Download Them Manually?
I want to download the MIDI files from this website for a project. I have written the following code to download the files: from bs4 import BeautifulSoup import requests import re,
Solution 1:
Your code works fine, just change base_url to
base_url = "http://www.midiworld.com/download/"
Right now, i.e. "1.mid" contains the HTML for this site: http://www.midiworld.com/files/1 (You can open it with a text editor.)
The MIDI-files can be downloaded the url http://www.midiworld.com/download/{insert number}
I downloaded the first 100 but it seems there are currently 4992 downloadable midi files, so if you want more files, just change
for i in range(1,4992):
As a side-note, the site gives you download "_-_.mid" which is 0 bytes, if the requested .mid doesn't exist. So, if you are going to repeat downloading the files and you want all the files they have, consider setting range to for example 100 000 and break the loop if downloaded file-size is 0 bytes.
for i in range(1,100000):
if (urllib.request.urlopen(base_url+str(i)).length == 0):
break
Post a Comment for "Why Can't I Play The MIDI Files I Have Downloaded Programmatically, But I Can Play Them When I Download Them Manually?"