Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

扩展功能 #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ $ cd music-dl
$ pip3 install -r requirements.txt
$ ./music-dl

# 或 python3 music-dl
# 或 python3 -m music-dl
```

在以下环境测试通过:
Expand Down
21 changes: 19 additions & 2 deletions music_dl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def run():
@click.option("--lyrics", default=False, is_flag=True, help=_("同时下载歌词"))
@click.option("--cover", default=False, is_flag=True, help=_("同时下载封面"))
@click.option("--nomerge", default=False, is_flag=True, help=_("不对搜索结果列表排序和去重"))
@click.option("-f", "--filename", default="search_list.txt", help=_("从指定文件中搜索"))
def main(
keyword,
url,
Expand All @@ -110,12 +111,13 @@ def main(
lyrics,
cover,
nomerge,
filename,
):
"""
Search and download music from netease, qq, kugou, baidu and xiami.
Example: music-dl -k "周杰伦"
"""
if sum([bool(keyword), bool(url), bool(playlist)]) != 1:
if sum([bool(keyword), bool(url), bool(playlist)]) != 1 and not filename:
# click.echo(_("ERROR: 必须指定搜索关键字、歌曲的URL或歌单的URL中的一个") + "\n", err=True)
# ctx = click.get_current_context()
# click.echo(ctx.get_help())
Expand Down Expand Up @@ -147,10 +149,25 @@ def main(
)

try:
run()
if filename:
click.echo(f"从文件中下载音乐列表: {filename}")
search_list = []
with open(file=filename, mode="r", encoding="utf-8") as f:
search_list = [line for line in f.readlines() if line.strip()]
if search_list:
process_song_list(search_list)
else:
run()
except (EOFError, KeyboardInterrupt):
sys.exit(0)


def process_song_list(song_list):
ms = MusicSource()
for keyword in song_list:
songs_list = ms.search(keyword, config.get("source").split())
menu(songs_list)


if __name__ == "__main__":
main()
80 changes: 80 additions & 0 deletions search_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
上海滩
风的季节
漫步人生路
万里长城永不倒
几许风雨
世间始终你好
铁血丹心
偏偏喜欢你
朋友
遥远的她
当年情
倩女幽魂
敢爱敢做
月半小夜曲
让一切随风
每段路
情感的禁区
喜欢你
大地
祝福
人生何处不相逢
傻女
堆积情感
沉默是金
千千阙歌
夕阳之歌
谁明浪子心
一生不变
一生何求
难得有情人
真的爱你
忘情冷雨夜
我恨我痴心
友谊太阳
我曾用心爱着你
沧海一声笑
光辉岁月
灰色轨迹
天若有情
相逢何必曾相识
相逢在雨中
随缘
只愿一生爱一人
半点心
一起走过的日子
一生中最爱
初恋情人
片片枫叶情
你的浅笑
护花使者
不再犹豫
男儿当自强
红日
情人知己
雨中的恋人们
封锁我一生
我的亲爱
容易受伤的女人
相思风雨中
飘雪
海阔天空
情人
等你等到我心痛
只愿一生跟你走
暗里着迷
一人有一个梦想
最爱
痴心换情深
开心的马骝
夏日倾情
饿狼传说
讲不出再见
爱的故事上集
笑看风云
一生所爱
神话情话
难念的经
友情岁月
约定
都是你的错