Skip to content

Commit

Permalink
✨ feat: 完成了音乐下载功能
Browse files Browse the repository at this point in the history
  • Loading branch information
nichuanfang committed Oct 10, 2023
1 parent 7aac9d4 commit e0d63f6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ pip install -U music-tool-kit
- 音乐下载

```bash
mtk 网址 [输出] [封面url]
musictool 网址 [输出] [封面url]
```

> tips: 输出格式为 歌曲名[-歌手] 输出歌曲格式为 mp3 可选, 封面 url 也可选
- 音乐剪辑

```bash
mtk -clip 输入的文件 开始时间 结束时间
musictool -clip 输入的文件 开始时间 结束时间
```

> tips: 时间格式为: 00:00:00
- 音乐伴奏提取

```bash
mtk -extract 输入的文件 输出的文件
musictool -extract 输入的文件
```
9 changes: 6 additions & 3 deletions mtk/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# !/usr/bin/env python3

import sys
import requests
from mtk.mp3_util import MP3
Expand All @@ -9,7 +11,7 @@ def extract_info(url):
info = ydl.extract_info(url, download=False)
return info

def download(url:str,title:str|None=None,cover_url:str|None=None):
def download(url:str,title:str=None,cover_url:str=None):
"""下载mp3格式的音乐
Args:
url (str): 歌曲网址
Expand Down Expand Up @@ -78,8 +80,9 @@ def main(args=None):
if len(args) == 0:
print('configuration:\n\n'
'---------------------------------------------\n'+
'下载: mtk url [title] [cover_url]\n'+
'剪辑: mtk --clip path start end\n'
'下载: musictool url [title] [cover_url]\n'+
'剪辑: musictool -clip path start end\n'
'提取伴奏: musictool -extract path\n'
'---------------------------------------------\n'
)
return
Expand Down
1 change: 1 addition & 0 deletions mtk/mp3_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# !/usr/bin/env python3
import requests
import os
from mutagen.id3 import ID3, APIC, TIT2, TPE1, TALB
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
yt-dlp>=2023.10.7
ffmpeg>=1.4
requests>=2.26.0
mutagen>=1.47.0
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='music-tool-kit',
version='0.0.4',
version='0.0.9',
description='A tool kit for music download and clip',
long_description_content_type='text/markdown',
long_description=readme,
Expand All @@ -31,12 +31,10 @@
'mtk': ['*.txt'],
},
require_python='>=3.8',
install_requires=[
'requests'
],
install_requires=requirements,
entry_points={
'console_scripts': [
'mtk = mtk.__main__:main',
'musictool = mtk.__main__:main',
]
},
classifiers=[
Expand Down

0 comments on commit e0d63f6

Please sign in to comment.