26 Feb 2010
12 Feb 2010
Love songs
#!/usr/bin/env python
# python script to download love songs from mp3.zing.vn
# hungnv
# license: Public Domain
from urllib2 import urlopen
from urllib import urlretrieve
from os import mkdir
from os.path import join, isdir
import sys
mp3_dir = "/home/hungnv/Music/"
html_source = "http://mp3.zing.vn/mp3/nghe-album/album-hot/love-song.html"
if not isdir(mp3_dir):
try:
mkdir(mp3_dir)
except:
print "cannot create directory %s" %mp3_dir
sys.exit(1)
def getlink():
try:
response = urlopen(html_source)
except:
print "connection error"
response = urlopen(html_source)
content = response.readlines()
response.close()
for line in content:
a = line.find('http://dl.mp3.kapsule.info')
b = line.find('?')
if a <> -1 and b <> -1:
link = line[a:b]
c = line.find('filename') + 9
d = line.find('alt') - 2
filename = line[c:d]
print "Song named %s will be downloaded at url %s" % (filename,link)
print "Downloading.....\n"
abs_path = join(mp3_dir,filename)
urlretrieve(link,abs_path)
else:
continue
if __name__ == '__main__':
getlink()
exit()
Subscribe to:
Comments (Atom)