From 47098a7920e2e3985c2bdc65891e76dd117ed944 Mon Sep 17 00:00:00 2001 From: nichuanfang Date: Wed, 11 Oct 2023 01:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=B0=86=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BAmk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- {mtk => mk}/__init__.py | 0 {mtk => mk}/__main__.py | 19 ++++++++++++------- {mtk => mk}/mp3_util.py | 0 setup.py | 7 ++++--- 5 files changed, 19 insertions(+), 13 deletions(-) rename {mtk => mk}/__init__.py (100%) rename {mtk => mk}/__main__.py (89%) rename {mtk => mk}/mp3_util.py (100%) diff --git a/README.md b/README.md index 6d52e3f..fd0861d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ pip install -U music-tool-kit - 音乐下载 ```bash -musictool 网址 [输出] [封面url] +mk 网址 [输出] [封面url] ``` > tips: 输出格式为 歌曲名[-歌手] 输出歌曲格式为 mp3 可选, 封面 url 也可选 @@ -19,7 +19,7 @@ musictool 网址 [输出] [封面url] - 音乐剪辑 ```bash -musictool -clip 输入的文件 开始时间 结束时间 +mk -c 输入的文件 开始时间 结束时间 ``` > tips: 时间格式为: 00:00:00 @@ -27,5 +27,5 @@ musictool -clip 输入的文件 开始时间 结束时间 - 音乐伴奏提取 ```bash -musictool -extract 输入的文件 +mk -e 输入的文件 ``` diff --git a/mtk/__init__.py b/mk/__init__.py similarity index 100% rename from mtk/__init__.py rename to mk/__init__.py diff --git a/mtk/__main__.py b/mk/__main__.py similarity index 89% rename from mtk/__main__.py rename to mk/__main__.py index 5281f0e..e807cff 100644 --- a/mtk/__main__.py +++ b/mk/__main__.py @@ -1,8 +1,7 @@ # !/usr/bin/env python3 import sys -import requests -from mtk.mp3_util import MP3 +from mk.mp3_util import MP3 from yt_dlp import YoutubeDL # 提取yt_dlp信息 @@ -48,6 +47,11 @@ def download(url:str,title:str=None,cover_url:str=None): mp3.add_title(title) if cover_url != None: mp3.add_cover(cover_url) + else: + info = extract_info(url) + if 'thumbnail' in info: + thumbnail = info['thumbnail'] + mp3.add_cover(thumbnail) mp3.save() else: info = extract_info(url) @@ -57,8 +61,9 @@ def download(url:str,title:str=None,cover_url:str=None): if cover_url != None: mp3.add_cover(cover_url) else: - thumbnail = info['thumbnail'] - mp3.add_cover(thumbnail) + if 'thumbnail' in info: + thumbnail = info['thumbnail'] + mp3.add_cover(thumbnail) mp3.save() print('下载完成!') @@ -80,9 +85,9 @@ def main(args=None): if len(args) == 0: print('configuration:\n\n' '---------------------------------------------\n'+ - '下载: musictool url [title] [cover_url]\n'+ - '剪辑: musictool -clip path start end\n' - '提取伴奏: musictool -extract path\n' + '下载: mk url [title] [cover_url]\n'+ + '剪辑: mk -c path start end\n' + '提取伴奏: mk -e path\n' '---------------------------------------------\n' ) return diff --git a/mtk/mp3_util.py b/mk/mp3_util.py similarity index 100% rename from mtk/mp3_util.py rename to mk/mp3_util.py diff --git a/setup.py b/setup.py index 002db24..cf806d9 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='music-tool-kit', - version='0.0.9', + version='0.1.1', description='A tool kit for music download and clip', long_description_content_type='text/markdown', long_description=readme, @@ -18,6 +18,7 @@ license='MIT', platforms='any', keywords=[ + 'mk' 'mtk' 'music', 'musictool', @@ -28,13 +29,13 @@ ], packages=find_packages(exclude=['tests']), package_data={ - 'mtk': ['*.txt'], + 'mk': ['*.txt'], }, require_python='>=3.8', install_requires=requirements, entry_points={ 'console_scripts': [ - 'musictool = mtk.__main__:main', + 'mk = mk.__main__:main', ] }, classifiers=[