key = raw_input() kr = False if key.startswith('kr'): kr = True url, txt = url_dict.get(key) sql_err = open('log/sql_err.log', 'a+') record = open('record/{}'.format(txt), 'a+') log = open('log/{}'.format(txt), 'a+') art = open('artist/{}'.format(txt), 'a+') down = open('down/{}'.format(txt), 'a+') init_schema() baidu = BaiduMusic(url) artist_list = baidu.get_artist_list() artist_list.sort() if key == 'cn_group': artist_list = artist_list[857:] elif key == 'cn_male': artist_list = artist_list[4891:] elif key == 'cn_female': artist_list = artist_list[384:] elif key == 'jp_group': artist_list = artist_list[153:] elif key == 'jp_male': artist_list = artist_list[66:] elif key == 'jp_female': artist_list = artist_list[95:]
(cn_male, cn_male_txt), (cn_female, cn_female_txt), (cn_group, cn_group_txt), (wt_male, wt_male_txt), (wt_female, wt_female_txt), (wt_group, wt_group_txt), (kr_male, kr_male_txt), (kr_female, kr_female_txt), (kr_group, kr_group_txt), (jp_male, jp_male_txt), (jp_female, jp_female_txt), (jp_group, jp_group_txt), (other, other_txt), ] url_dict = { 'cn_male': (cn_male, cn_male_txt), 'cn_female': (cn_female, cn_female_txt), 'cn_group': (cn_group, cn_group_txt), 'wt_male': (wt_male, wt_male_txt), 'wt_female': (wt_female, wt_female_txt), 'wt_group': (wt_group, wt_group_txt), 'kr_male': (kr_male, kr_male_txt), 'kr_female': (kr_female, kr_female_txt), 'kr_group': (kr_group, kr_group_txt), 'jp_male': (jp_male, jp_male_txt), 'jp_female': (jp_female, jp_female_txt), 'jp_group': (jp_group, jp_group_txt), 'other': (other, other_txt), } if __name__ == '__main__': for url, filename in url_file_list: baidu = BaiduMusic(url) artist_list = baidu.get_artist_list() wr = open(filename, 'a+') wr.write('\n'.join(artist_list)) wr.close()