music apis
Project description
music_api
some apis to fetch music
it includes
examples
fetch song
import asyncio
from music_api import Template, mg
async def main() -> None:
api = mg.API()
songs = await api.search("enemy")
assert songs
song = songs[0]
assert type(song) is Template.Song
# Song object has fields:
# desc: simple description of the song
# url: url of song
# fetch: function to fetch song url
# owner: owner of the song, instance of Template
assert song.url == ""
status, url = await song.fetch()
if status is Template.Song.Status.Success:
print(url)
assert song.url == url
elif status is Template.Song.Status.NeedVIP:
print("need vip")
elif status is Template.Song.Status.NeedLogin:
print("need log in")
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
log in
import asyncio
from io import BytesIO
from music_api import Template, mg
from PIL import Image
async def show_img(img: bytes) -> None:
f = BytesIO(img)
img = Image.open(f)
img.show()
async def main() -> None:
api = mg.API()
assert api.login.QR is not None
login_by_qr = api.login.QR
await login_by_qr(show_img)
assert api.login.SMS is not None
cellphone = input("cellphone is:")
fetch_captcha, send_sms, login_by_sms = api.login.SMS
captcha = ""
if fetch_captcha is not None:
await fetch_captcha()
captcha = input("captcha is:")
await send_sms(cellphone, captcha)
verify_code = input("verify code is:")
await login_by_sms(cellphone, verify_code, captcha)
assert api.login.PWD is not None
cellphone = input("cellphone is:")
password = input("password is:")
fetch_captcha, login_by_pwd = api.login.PWD
captcha = ""
if fetch_captcha is not None:
await fetch_captcha()
captcha = input("captcha is:")
await login_by_pwd(cellphone, password, captcha)
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymusicapi-0.1.1.tar.gz
(16.5 kB
view details)
Built Distribution
File details
Details for the file pymusicapi-0.1.1.tar.gz
.
File metadata
- Download URL: pymusicapi-0.1.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f91739b74cc940707b8039d65e7121c3f9b331c1cbb0e50443a0090a4e7f662 |
|
MD5 | 3c904e73dafd6e86468fdf55b4550156 |
|
BLAKE2b-256 | 8067f8a43b9bcbf42b8e0a9556a6ae7aeffd100a4182c9ddba190bce95cb16e5 |
File details
Details for the file pymusicapi-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pymusicapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c6deed23dd27c49614e980426ed657f5bf867e3bda4b9ad62989688e84b4688 |
|
MD5 | d2123bed214049528ffa2a561caf5ab9 |
|
BLAKE2b-256 | 5665c9f79e54947f1e45a9500fcb52ff6b566f6ecb4a6a88eec95446c219d433 |