Skip to content

Instantly share code, notes, and snippets.

@cosven
Last active July 2, 2019 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosven/2a0af2998483628572edbb46a2128a3c to your computer and use it in GitHub Desktop.
Save cosven/2a0af2998483628572edbb46a2128a3c to your computer and use it in GitHub Desktop.
简单的让 feeluown 支持下载 DEMO(请自行安装 feeluown-download)
# -*- 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)
@cosven
Copy link
Author

cosven commented Jul 2, 2019

可能存在以下问题:

  1. 重复下载
  2. 进程会创建很多线程,并且没有回收

不建议直接使用,这只是一个 DEMO...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment