<commit_before>#!/usr/bin/env python
# -*- coding=UTF-8 -*-
# Created at May 31 10:28 by <EMAIL>

import sys
if hasattr(sys, 'setdefaultencoding'):
	sys.setdefaultencoding('UTF-8')

from track import track
from BeautifulSoup import *
import urllib2

baseurl = r'http://www.xiami.com/song/playlist/id/'
albumurl_root = r'/type/1'
artisturl_root = r'/type/2'

def progress_bar(current, total):
	sys.stderr.write(str(current) + ' of ' + str(total)\
			+ ' Bytes downloaded.\r')

if __name__ == '__main__':
	if len(sys.argv) != 3 or sys.argv[1] not in ['song', 'album', 'artist']:
		print 'usage: ' + argv[0] + ' song|album|artist ID\n'
		sys.exit(-1)
	url = baseurl + sys.argv[2]
	if sys.argv[1] == 'album':
		url += albumurl_root
	if sys.argv[1] == 'artist':
		url += artisturl_root
	
	raw_data = urllib2.urlopen(url).read()
	tracks = BeautifulStoneSoup(raw_data).findAll(name='track')
	for i in tracks:
		song = track(i)
		song.download('./', ReportHook = progress_bar)
		sys.stderr.write('\n\n')<commit_msg>done!!<commit_after>#!/usr/bin/env python
# -*- coding=UTF-8 -*-
# Created at May 31 10:28 by <EMAIL>

import sys
if hasattr(sys, 'setdefaultencoding'):
	sys.setdefaultencoding('UTF-8')

from track import track
from BeautifulSoup import *
import urllib2

baseurl = r'http://www.xiami.com/song/playlist/id/'
albumurl_root = r'/type/1'
artisturl_root = r'/type/2'
save_path = '/home/blahgeek/Music/'

def progress_bar(current, total):
	sys.stderr.write(str(current) + ' of ' + str(total)\
			+ ' Bytes downloaded.\r')

if __name__ == '__main__':
	if len(sys.argv) != 3 or sys.argv[1] not in ['song', 'album', 'artist']:
		print 'usage: ' + argv[0] + ' song|album|artist ID\n'
		sys.exit(-1)
	url = baseurl + sys.argv[2]
	if sys.argv[1] == 'album':
		url += albumurl_root
	if sys.argv[1] == 'artist':
		url += artisturl_root
	
	raw_data = urllib2.urlopen(url).read()
	tracks = BeautifulStoneSoup(raw_data).findAll(name='track')
	for i in tracks:
		song = track(i)
		song.download(save_path, ReportHook = progress_bar)
		sys.stderr.write('\n\n')
{'fraction_non_alphanumeric': 0.17822265625, 'fraction_numerical': 0.0185546875, 'mean_word_length': 4.253846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3174209', 'n_tokens_mistral': 846, 'n_tokens_neox': 793, 'n_words': 171}