Last active
July 2, 2019 09:45
-
-
Save cosven/2a0af2998483628572edbb46a2128a3c to your computer and use it in GitHub Desktop.
简单的让 feeluown 支持下载 DEMO(请自行安装 feeluown-download)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: Python; -*- | |
# vi: ft=python | |
import os | |
# 自定义配置 | |
# config.THEME = 'dark' | |
config.COLLECTIONS_DIR = '~/Dropbox/public/music' | |
config.AUDIO_SELECT_POLICY = '>>>' | |
# config.LOCAL_LIBRARY_PATH = '~/Music' | |
# 一个小插件:切换歌曲时,发送系统通知 | |
def notify_song_changed(song): | |
if song is not None: | |
pass | |
# def update_netease_request_headers(*args, **kwargs): | |
# from fuo_netease import provider | |
# | |
# # 海外用户可以给它设置 IP,避免被 block | |
# provider.api.headers.update({'X-Real-Ip': '...'}) | |
def download_song(song): | |
import os | |
from fuo_dl import download, cook_filepath | |
if not song: | |
return | |
filename = cook_filepath(song) | |
filepath = os.path.join(os.path.expanduser('~/Music'), | |
filename) | |
if song.meta.support_multi_quality: | |
media, _ = song.select_media() | |
url = media.url | |
else: | |
url = song.url | |
if url: | |
download(url, filepath) | |
print('create download task: {}'.format(filepath)) | |
when('app.player.playlist.song_changed', notify_song_changed) | |
when('app.player.playlist.song_changed', download_song) | |
# when('app.initialized', update_netease_request_headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
可能存在以下问题:
不建议直接使用,这只是一个 DEMO...