def sab(self): from NXSpider.bin.models import album_mo if self.param_check(['album'], sys._getframe().f_code.co_name) is False: return download_type = self.parse_download() albums = self.app.pargs.album.split(',') # type: list for pid in albums: album_detail = api.get_album_detail(pid) if album_detail is None: continue log.print_info(u"{} artist:{}".format( "<" + album_detail['name'] + ">", album_detail['artist']['name'], )) album_mo.parse_model( album_detail, download_type=download_type, file_check=Config().get_file_check(), shortcuts_stack=[] if Config().get_shortcut() else None) log.print_info("spider complete!~") pass
def sar_albums(self): from NXSpider.bin.models import artist_album_mo if self.param_check(['artist'], sys._getframe().f_code.co_name) is False: return download_type = self.parse_download() artists = self.app.pargs.artist.split(',') # type: list for arid in artists: detail = api.get_artist_album(arid, offset=self.app.pargs.offset or 0, limit=self.app.pargs.limit or 50) if detail is None: continue artist_detail = detail['artist'] album_details = [ api.get_album_detail(d['id']) for d in detail['hotAlbums'] ] album_details = [d for d in album_details if d] artist_detail['albums'] = album_details from terminaltables import AsciiTable table = AsciiTable([["ID", "Album", "Artist", "ArtistID"]]) table_data = [[ str(item['id']), item['name'], ','.join([ar['name'] for ar in item['artists']]), ','.join([str(ar['id']) for ar in item['artists']]), ] for item in artist_detail['albums']] table.table_data.extend(table_data) log.print_info(u"<{}>".format(artist_detail['name'])) log.print_info("albums bellow will be crawled") print(table.table) artist_album_mo.parse_model(artist_detail, download_type=download_type, file_check=Config().get_file_check()) log.print_info("spider complete!~") pass
def sar_albums(self): from NXSpider.bin.models import artist_album_mo if self.param_check(['artist'], sys._getframe().f_code.co_name) is False: return download_type = self.parse_download() artists = self.app.pargs.artist.split(',') # type: list for arid in artists: detail = api.get_artist_album(arid, offset=self.app.pargs.offset or 0, limit=self.app.pargs.limit or 50) if detail is None: continue artist_detail = detail['artist'] album_details = [ api.get_album_detail(d['id']) for d in detail['hotAlbums'] ] album_details = [d for d in album_details if d] artist_detail['albums'] = album_details log.print_info(u"<{}>".format(artist_detail['name'])) log.print_info("albums bellow will be crawled") print_albums(artist_detail['albums']) artist_album_mo.parse_model( artist_detail, download_type=download_type, file_check=Config().get_file_check(), shortcuts_stack=[] if Config().get_shortcut() else None) log.print_info("spider complete!~") pass
s = requests.Session() test = login('15302663382', p, s) test = user_playlist(92024088, session=s) test = get_playlist_detail(107020750) test = search('周杰伦', stype=100) test = top_artists() test = get_playlist_classes() test = get_mp3_details([412902496, 412902496, 412902496]) test = get_artists_songs(9621) test = get_artist_album(9621) test = top_artists() # test = playlist_classes() test = get_top_playlists() test = get_album_detail(32324) # test = get_mp3_link(412902496) # playlist_by_id(466225104) tests = get_mp3_links([412902496, 326904]) # http://music.163.com/api/song/detail?ids=[412902496,326904] work # http://music.163.com/api/album/32324 don't work # http://music.163.com/#/artist?id=9621 # http://music.163.com/api/artist/9621 don't work # playlist_all_page() print('a')