Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #/home/clockworkpc/Documents/bin/ccmixter.py
- # Released under a GPLv3 Licence by Clockwork PC 2011
- #
- # www.clockworkpc.com.au
- #
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what
- # you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- #
- # Please do not denigrate free or open source software. It powers the internet and is at the heart of everything that is good in computing.
- #
- # Share the love.
- import os
- import string
- import re
- import urllib
- number = int(raw_input("""
- 1 = Instrumental Music for Film and Video (Free for commercial use)
- """))
- # I'll utilise JSON when I've developed the skills. In the meantime, I've crudely listed all of the pages that this particular search lists on the website. I know, it's an ugly hack, but I'm learning...
- if number == 1:
- genre = 'Soundtrack1'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe'
- if number == 2:
- genre = 'Soundtrack2'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=10'
- if number == 3:
- genre = 'Soundtrack3'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=20'
- if number == 4:
- genre = 'Soundtrack4'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=30'
- if number == 5:
- genre = 'Soundtrack5'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=40'
- if number == 6:
- genre = 'Soundtrack6'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=50'
- if number == 7:
- genre = 'Soundtrack7'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=60'
- if number == 8:
- genre = 'Soundtrack8'
- if number == 9:
- genre = 'Soundtrack9'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=70'
- if number == 10:
- genre = 'Soundtrack10'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=80'
- if number == 11:
- genre = 'Soundtrack11'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=90'
- if number == 12:
- genre = 'Soundtrack12'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=100'
- if number == 13:
- genre = 'Soundtrack13'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=110'
- if number == 14:
- genre = 'Soundtrack14'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=120'
- if number == 15:
- genre = 'Soundtrack15'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=130'
- if number == 16:
- genre = 'Soundtrack16'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=140'
- if number == 17:
- genre = 'Soundtrack17'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=150'
- if number == 18:
- genre = 'Soundtrack18'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=160'
- if number == 19:
- genre = 'Soundtrack19'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=170'
- if number == 20:
- genre = 'Soundtrack20'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=180'
- if number == 21:
- genre = 'Soundtrack21'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=190'
- if number == 22:
- genre = 'Soundtrack22'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=200'
- if number == 23:
- genre = 'Soundtrack23'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=210'
- if number == 24:
- genre = 'Soundtrack24'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=220'
- if number == 25:
- genre = 'Soundtrack25'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=230'
- if number == 26:
- genre = 'Soundtrack26'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=240'
- if number == 27:
- genre = 'Soundtrack'
- url = 'http://dig.ccmixter.org/music_for_film_and_video?dig-lic=safe&offset=250'
- folder = os.getenv("HOME")+"/"+"Music/dig.ccmixter.org/"+genre+"/"
- os.system("mkdir -pv " + folder)
- os.system("gnome-terminal -x mplayer ~/Downloads/dj-scratch-1.wav & xcowsay " + folder)
- os.system("xcowsay " + url)
- index = "index.html"
- # Tried this, but it didn't work:
- #urllib.urlretrieve (url, folder + index)
- os.system("wget -O " + folder + "index.html" + " " + url)
- sourcefile = folder + "index.html"
- os.system("xcowsay" + folder)
- os.system("xcowsay" + sourcefile )
- #It's just easier to use BASH to create the file, then I can manipulate it in Python
- os.system('echo "#!/bin/bash" | tee ' + folder + "musicfetcher.sh")
- targetfile = folder + "musicfetcher.sh"
- os.system("xcowsay " + targetfile)
- os.system('echo "#musicfetcher.sh" | tee -a ' + targetfile)
- os.system('echo "#Released under a GPLv3 Licence by Clockwork PC" | tee -a ' + targetfile)
- print sourcefile
- f = open(sourcefile)
- g = open(targetfile, 'a')
- strToSearch=''
- for line in f:
- strToSearch += line
- patFinder1 = re.compile('http://ccmixter.org/content/\S+'+'mp3')
- findPat1 = re.findall(patFinder1,strToSearch)
- for i in findPat1:
- print(i)
- i=i.replace('http', 'gnome-terminal -x wget -P' + folder + ' http')
- g.write(i+'\n')
- g.close()
- os.system("chmod +x " + targetfile)
- os.system("gnome-terminal -x /bin/bash " + targetfile)
- os.system("nautilus " + folder)
- os.system("xcowsay 'Your music is being downloaded, my good friend'")
Add Comment
Please, Sign In to add comment