def _get_song_json(self, url): """ 获取json数据 Args: :param url: 请求json数据的url Return: j: 返回的json数据 """ res = XiamiHttp.send_request(url) j = XiamiHttp.get_res_json(res) return j
def _download(self, type='mp3', download_call=None): """ 下载入口 Args: :param type: 下载类型,默认为下载 mp3 音频 """ # 文件名 file_name = self.song_id entry = self.category.get(type) # 文件扩展名 extension_name = entry[1] req_url = self.song_info.get(entry[0]) # 目录名 download_directory = os.path.join(self._downdir, file_name) # 检查新建目录 self._checkout_directory(download_directory) filename = os.path.join(download_directory, file_name) # 保存的文件完整路径 file_name = '{filename}.{extension_name}'.\ format(filename=filename, extension_name=extension_name) # 下载并保存文件 download_info = XiamiHttp.save(req_url, file_name, download_call) return download_info