def crawler(self, singer_name): self.savedir, page, infos = singer_name, 0, [] while True: page += 1 self.config['page'] = page api = musicdl.musicdl(config=self.config) results = api.search(singer_name, self.target_srcs) if len(results[self.target_srcs[0]]) < 1: break infos.append(results) self.save(infos) return infos
def download(): if request.method == 'POST': s = request.get_json() print(s) config = { 'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': get_or_session(), 'proxies': {} } client = musicdl.musicdl(config=config) client.download(s) return '' else: return 'Method Not AlloweddataidatVjvuuuida'
def __init__(self): self.target_srcs = [ 'baiduFlac', 'kugou', 'qianqian', 'migu', 'xiami', 'joox', 'yiting', ] self.config = { 'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': 5, 'proxies': {} } self.client = musicdl.musicdl(config=self.config)
def post(request): # print(request.d.musicname) # print(request.d.targetsrcs) searchsize = request.d.searchsize config = {'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': searchsize, 'proxies': {}} target_srcs = request.d.targetsrcs client = musicdl.musicdl(config=config) search_results = client.search(request.d.musicname, target_srcs) items = [] idx = 0 for key, values in search_results.items(): for value in values: print("singer: "+value["singers"] + "download_url" + value["download_url"]) items.append(value) idx += 1 # print(search_results) return dict(items=items)
def search(): if request.method == 'POST': s = request.get_json() get_or_session(s.get('search_size_per_source')) print(get_or_session()) config = { 'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': get_or_session(), 'proxies': {} } target_srcs = s.get('target_srcs') client = musicdl.musicdl(config=config) search_results = client.search(s.get('search_data'), target_srcs) print(search_results) return jsonify({'result': search_results}) else: return 'Method Not Allowed'
def run(name): time.sleep(10) config = {'logfilepath': '/content/drive/MyDrive/Musics/musicdl.log', 'savedir': '/content/drive/MyDrive/Musics', 'search_size_per_source': 5, 'proxies': {}} target_srcs = ['qq', 'netease', 'migu'] client = musicdl.musicdl(config=config) search_results = client.search(name, target_srcs) # for key, value in search_results.items(): # client.download(value) # print(search_results) try: if search_results['migu'] != None: for i in range(len(search_results['migu'])): if name in search_results['migu'][i]['songname']: client.download([search_results['migu'][i]]) except: pass try: if search_results['qq'] != None: for i in range(len(search_results['qq'])): if name in search_results['qq'][i]['songname']: client.download([search_results['qq'][i]]) except: pass try: if search_results['netease'] != None: for i in range(len(search_results['qq'])): if name in search_results['qq'][i]['songname']: client.download([search_results['netease'][i]]) except: pass try: client.download([search_results['migu'][0]]) except: pass
def __init__(self, parent=None): super(MusicdlGUI, self).__init__() # 初始化 config = { 'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': 2, 'proxies': {} } self.music_api = musicdl.musicdl(config=config) self.setWindowTitle('音乐下载器GUI界面 —— Charles的皮卡丘') self.setWindowIcon( QIcon(os.path.join(os.path.dirname(__file__), 'icon.ico'))) self.setFixedSize(900, 480) self.initialize() # 搜索源 self.src_names = ['QQ音乐', '酷我音乐', '咪咕音乐', '千千音乐', '酷狗音乐', '网易云音乐'] self.label_src = QLabel('搜索源:') self.check_boxes = [] for src in self.src_names: cb = QCheckBox(src, self) cb.setCheckState(QtCore.Qt.Checked) self.check_boxes.append(cb) # 输入框 self.label_keyword = QLabel('搜索关键字:') self.lineedit_keyword = QLineEdit('微信公众号: Charles的皮卡丘') self.button_keyword = QPushButton('搜索') # 搜索结果表格 self.results_table = QTableWidget() self.results_table.setColumnCount(7) self.results_table.setHorizontalHeaderLabels( ['序号', '歌手', '歌名', '大小', '时长', '专辑', '来源']) self.results_table.horizontalHeader().setStyleSheet( "QHeaderView::section{background:skyblue;color:black;}") self.results_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.results_table.setSelectionBehavior(QAbstractItemView.SelectRows) # 鼠标右键点击的菜单 self.context_menu = QMenu(self) self.action_download = self.context_menu.addAction('下载') # 进度条 self.bar_download = QProgressBar(self) self.label_download = QLabel('歌曲下载进度:') # 布局 grid = QGridLayout() grid.addWidget(self.label_src, 0, 0, 1, 1) for idx, cb in enumerate(self.check_boxes): grid.addWidget(cb, 0, idx + 1, 1, 1) grid.addWidget(self.label_keyword, 1, 0, 1, 1) grid.addWidget(self.lineedit_keyword, 1, 1, 1, len(self.src_names) - 1) grid.addWidget(self.button_keyword, 1, len(self.src_names), 1, 1) grid.addWidget(self.label_download, 2, 0, 1, 1) grid.addWidget(self.bar_download, 2, 1, 1, len(self.src_names)) grid.addWidget(self.results_table, 3, 0, len(self.src_names), len(self.src_names) + 1) self.grid = grid self.setLayout(grid) # 绑定事件 self.button_keyword.clicked.connect(self.search) self.results_table.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.results_table.customContextMenuRequested.connect(self.mouseclick) self.action_download.triggered.connect(self.download)
from musicdl import musicdl config = { 'logfilepath': 'musicdl.log', 'savedir': 'downloaded', 'search_size_per_source': 5, 'proxies': {} } target_srcs = [ 'baiduFlac', 'kugou', 'kuwo', 'qq', 'qianqian', 'netease', 'migu', 'xiami', 'joox' ] client = musicdl.musicdl(config=config) client.run(target_srcs)