-
-
Save clockworkpc/30f80893cfd752d5a836fc3d1ccf08d3 to your computer and use it in GitHub Desktop.
Music Fetcher for freemusicarchive.org (Created 2011-04-02)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#musicfetcher_v03.py | |
#Released under a GPLv3 Licence by Clockwork PC | |
import os | |
import fileinput | |
import string | |
number = int(raw_input(""" | |
1 = Blues | |
2 = Classical | |
3 = Country | |
4 = Electronic | |
5 = Experimental | |
6 = Folk | |
7 = Hip-Hop | |
8 = International | |
9 = Jazz | |
10 = Novelty | |
11 = Old Time | |
12 = Rock | |
13 = Soul and R&B | |
14 = Spoken | |
""")) | |
#List the music genres that are available from freemusicarchive.org | |
if number == 1: | |
genre = 'Blues' | |
url = 'http://freemusicarchive.org/genre/Blues/' | |
if number == 2: | |
genre = 'Classical' | |
url = 'http://freemusicarchive.org/genre/Classical/' | |
if number == 3: | |
genre = 'Country' | |
url = 'http://freemusicarchive.org/genre/Country/' | |
if number == 4: | |
genre = 'Electronic' | |
url = 'http://freemusicarchive.org/genre/Electronic/' | |
if number == 5: | |
genre = 'Experimental' | |
url = 'http://freemusicarchive.org/genre/Experimental/' | |
if number == 6: | |
genre = 'Folk' | |
url = 'http://freemusicarchive.org/genre/Folk/' | |
if number == 7: | |
genre = 'Hip-Hop' | |
url = 'http://freemusicarchive.org/genre/Hip-Hop/' | |
if number == 8: | |
genre = 'International' | |
url = 'http://freemusicarchive.org/genre/International/' | |
if number == 9: | |
genre = 'Jazz' | |
url = 'http://freemusicarchive.org/genre/Jazz/' | |
if number == 10: | |
genre = 'Novelty' | |
url = 'http://freemusicarchive.org/genre/Novelty/' | |
if number == 11: | |
genre = 'Old-time' | |
url = 'http://freemusicarchive.org/genre/Old-time/' | |
if number == 12: | |
genre = 'Rock' | |
url = 'http://freemusicarchive.org/genre/Rock/' | |
if number == 13: | |
genre = 'Soul_and_RnB' | |
url = 'http://freemusicarchive.org/genre/Soul_and_RnB/' | |
if number == 14: | |
genre = 'Spoken' | |
url = 'http://freemusicarchive.org/genre/Spoken/' | |
folder = os.getenv("HOME")+"/"+"Music/freemusicarchive.org/"+genre+"/" | |
os.system("mkdir -pv " + folder) | |
os.system("gnome-terminal -x mplayer ~/Downloads/dj-scratch-1.wav & xcowsay " + folder) | |
print url | |
os.system("wget " + url) | |
os.system("mv index.html " + folder + "index.html") | |
source = folder+"index.html" | |
print folder | |
print source | |
os.system('echo "#!/bin/bash" | tee ' + folder + "musicfetcher.sh") | |
os.system('echo "#musicfetcher.sh" | tee -a ' + folder + "musicfetcher.sh") | |
os.system('echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a ' + folder + "musicfetcher.sh") | |
musicfetcher = folder + "musicfetcher.sh" | |
print musicfetcher | |
f=open(musicfetcher,"a") | |
for line in open(source): | |
if "http://freemusicarchive.org/music/download" in line: | |
print line | |
line=line.replace(' <a href="http', 'gnome-terminal -x wget "http') | |
line=line.replace('class="icn-arrow" title="Download"></a>', "-P " + folder) | |
f.write(line) | |
f.close() | |
os.system("chmod +x " + musicfetcher) | |
os.system("/bin/bash " + musicfetcher) | |
os.system("xcowsay 'Your music is being downloaded'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment