Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- import os
- import sys
- from subprocess import call
- from pyquery import PyQuery as pq
- start = int(sys.argv[1]) if len(sys.argv) > 1 else 0
- base = 'http://dub-level.com/music/browse'
- dl = 'http://motionsharing.com/site/download/%s/chop'
- def get_total_pages():
- return int(pq(base)('#pagination a:last').attr('href').split('/')[-1]) / 10
- def get_page(n):
- return pq('%s/%d' % (base, 10 * n))
- def get_hashes(q):
- return list(q('body a[title=Download]').map(
- lambda i, e: pq(e).attr('href').split('/')[5]))
- if __name__ == "__main__":
- total = get_total_pages()
- print "Total number of page: %d" % total
- print "Starting at page: %d" % start
- for i in range(start, total + 1):
- print "Getting hashes on page %d" % i
- for hash in get_hashes(get_page(i)):
- if os.path.exists(hash + '.mp3'):
- print "Skipping %s.mp3" % hash
- else:
- print "Downloading %s.mp3" % hash
- call(['wget', dl % hash, '-O', hash + '.mp3.dl'])
- os.rename(hash + '.mp3.dl', hash + '.mp3')
- print "Done"
Advertisement
Add Comment
Please, Sign In to add comment