def crawl_user(crawl_obj): temp_user = cloudmusic.getUser(crawl_obj.id) music_list = temp_user.getRecord(1) user = User(temp_user.nickname, temp_user.id) for value in range(0, 100): user.songs.append( Song(music_list[value]['music'].name, music_list[value]['music'].id)) os.chdir("cache/users") if not os.path.exists(os.getcwd() + '/' + user.name + '/'): os.mkdir(os.getcwd() + '/' + user.name + '/') os.chdir(os.getcwd() + '/' + user.name + '/') for index in range(0, len(user.songs)): lyrics_save(user.songs[index].id) #os.chdir("../../../") #user.print_info() return user
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2020/05/26 下午 9:44 # @Author : 殇夜殇雪 import cloudmusic import time 用户 = cloudmusic.getUser(1804446467) print(type(用户)) print(f"用户等级:{用户.level}") print(f"累计听歌数量:{用户.listenSongs}") print(f"所在城市行政区代码:{用户.city}") print(f"所在省份行政区代码:{用户.province}") print(f"用户头像:{用户.avatarUrl}") print(f"用户昵称:{用户.nickname}") print(f"粉丝数量:{用户.fans}") print(f"个性签名:{用户.signature}") print(f"关注的用户数量:{用户.follows}") print(f"动态数量:{用户.eventCount}") print(f"创建歌单数量:{用户.playlistCount}") print(f"是否开通VIP(0=未开通,11=黑胶,10=开通音乐包):{用户.vipType}") birthday_stamp = int((用户.birthday)) / 1000 b = abs(birthday_stamp) timearray = time.localtime(b) birthday_time = time.strftime("%Y-%m-%d %H:%M:%S", timearray) print(f"生日时间:{birthday_time}") print(用户.birthday)
def getmusic(): choice = ['1.获取歌单信息', '2.获取个人信息', '3.退出本系统'] choose = e.buttonbox('请选择操作', '网易云音乐系统', choice) if choose == choice[0]: list_id = e.integerbox('请输入歌单的id', '网易云音乐系统', upperbound=999999999) try: play_list = cloudmusic.getPlaylist(list_id) except: e.msgbox('获取失败,请输入正确的歌单id') getmusic() choice1 = ['1.下载歌单', '2.退出本程序'] msg = '' for each in play_list: msg += each.name + '\n' choose = e.buttonbox('歌曲名如下:\n' + msg, '请选择接下来的操作', choice1) if choose == choice1[0]: dir = e.diropenbox('请选择存放地址') os.chdir(dir) e.msgbox('点确定以开始下载', '网易云音乐系统') for music in play_list: music.download(level='lossless') e.msgbox('下载完成') elif choose == choice1[1]: pass elif choose == choice[1]: id = e.integerbox('请输入要查找的id', '网易云音乐系统', '515694669', upperbound=999999999) if id == None: getmusic() user = cloudmusic.getUser(id) msg = '' dict1 = { 'id': '用户id', 'level': '用户等级', 'listenSongs': '累计听歌数量', 'createTime': '账号创建时间', 'nickname': '用户昵称', 'avatarUrl': '头像url', 'city': '所在城市的行政区划代码', 'province': '所在省份的行政区划代码', 'vipType': 'vip类型', 'birthday': '生日时间戳', 'signature': '个性签名', 'fans': '粉丝数量', 'follows': '关注的用户数量', 'eventCount': '动态数量', 'playlistCount': '创建的歌单数量' } for key, value in dict1.items(): msg += str(value) + ':' + str(eval('user.' + str(key))) + '\n' choice = ['1.获取用户的歌单(下载)', '2.退出本程序'] choose = e.buttonbox('信息如下:\n' + msg, '网易云音乐系统', choice) if choose == choice[0]: msg = '' playlist = user.getPlaylist() n = 0 for each in playlist: msg += str(n) + '.' + each['name'] + '\n' n += 1 choice = ['1.下载歌单', '2.退出本程序'] choose = e.buttonbox('歌单名称:\n' + msg, '网易云音乐系统', choice) #515694669 if choose == choice[0]: tips = '请选择下载的范围\n' list_range = e.enterbox( tips + msg + '(请用“,”将各歌单分割,如“1-2,3,4”)', '网易云音乐系统') print(list_range) if list_range == None: getmusic() list1 = [] if ',' or ',' in list_range: #将范围分割 list_range = list_range.replace(',', ',') list_range = list_range.split(',') print(list_range) for each in list_range: if '-' in each: a, b = each.split('-') list_range.remove(each) for i in range(int(a), int(b) + 1): list1.append(i) else: list1.append(int(each)) elif '-' in list_range: a, b = list_range.split('-') for i in range(int(a), int(b) + 1): list1.append(i) else: list1.append(int(list_range)) list1 = list(set(list1)) if e.ccbox('歌单范围是%s,点按continue开始下载' % str(list1)): try: dir = e.diropenbox('请选择存放地址') for i in list1: dirname = playlist[int(i)]['name'] dirs = os.path.join(dir, dirname) os.mkdir(dirs) os.chdir(dirs) download_music(playlist[int(i)]['id']) os.chdir(dir) except: getmusic() elif choose == choice[1]: pass show()
import re import urllib.request # playlist = api.getSong(445702291) # 601776277 是我的一个歌单id # print(playlist) # [<Music object - 445702291>, <Music object - 27198683>, <Music object - 27198679>, <Music object - 1868496>, <Music object - 26857076>, <Music object - 27198673>, <Music object - 27198672>, <Music object - 27198671>, <Music object - 1868520>, <Music object - 1868553>, <Music object - 486069583>, <Music object - 27198663>, <Music object - 1869285>, <Music object - 27198691>, <Music object - 1868483>] # 每个Music object包含属性:url(音频文件链接),level(品质),tyoe(格式),id(歌曲id),name(歌曲名),aitist(歌手),album(所属专辑),size(音频文件大小) # 每个Music object包含方法:1.download()下载到本地 2.review()获取详细评论 # music = cloudmusic.getMusic(1381755293) # print(music.getCommentCount()) # comments = music.getHotComments() # for com in comments: # print(com['content']) # print(com['likeCount']) user = cloudmusic.getUser(11898913) print(user.getRecord(1)) # loader = api.createLoader() # loader.data = musicList # if __name__ == "__main__": # loader.start()