zingmp3-api 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zingmp3_api-1.0.0/PKG-INFO +162 -0
- zingmp3_api-1.0.0/README.md +153 -0
- zingmp3_api-1.0.0/pyproject.toml +17 -0
- zingmp3_api-1.0.0/setup.cfg +4 -0
- zingmp3_api-1.0.0/zingmp3_api/__init__.py +328 -0
- zingmp3_api-1.0.0/zingmp3_api.egg-info/PKG-INFO +162 -0
- zingmp3_api-1.0.0/zingmp3_api.egg-info/SOURCES.txt +8 -0
- zingmp3_api-1.0.0/zingmp3_api.egg-info/dependency_links.txt +1 -0
- zingmp3_api-1.0.0/zingmp3_api.egg-info/requires.txt +1 -0
- zingmp3_api-1.0.0/zingmp3_api.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: zingmp3-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python wrapper for Zing MP3 API
|
|
5
|
+
Author: Vinh LC
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
|
|
10
|
+
# zingmp3-api
|
|
11
|
+
|
|
12
|
+
Python wrapper for Zing MP3 API.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install zingmp3-api
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from zingmp3_api import ZingMp3
|
|
24
|
+
|
|
25
|
+
result = ZingMp3.search("sontungmtp")
|
|
26
|
+
print(result)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### Search
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from zingmp3_api import ZingMp3
|
|
35
|
+
|
|
36
|
+
data = ZingMp3.search("sontungmtp")
|
|
37
|
+
print(data)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Get Song Streaming URL
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from zingmp3_api import ZingMp3
|
|
44
|
+
|
|
45
|
+
data = ZingMp3.get_song("Z8U96AD8")
|
|
46
|
+
print(data)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Get Song Information
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from zingmp3_api import ZingMp3
|
|
53
|
+
|
|
54
|
+
data = ZingMp3.get_info_song("Z8U96AD8")
|
|
55
|
+
print(data)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Get Lyrics
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from zingmp3_api import ZingMp3
|
|
62
|
+
|
|
63
|
+
data = ZingMp3.get_lyric("Z8U96AD8")
|
|
64
|
+
print(data)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Get Playlist Details
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from zingmp3_api import ZingMp3
|
|
71
|
+
|
|
72
|
+
data = ZingMp3.get_detail_playlist("Z8U96AD8")
|
|
73
|
+
print(data)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Get Artist Information
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from zingmp3_api import ZingMp3
|
|
80
|
+
|
|
81
|
+
data = ZingMp3.get_artist("son-tung-mtp")
|
|
82
|
+
print(data)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Get Home Page Data
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from zingmp3_api import ZingMp3
|
|
89
|
+
|
|
90
|
+
data = ZingMp3.get_home()
|
|
91
|
+
print(data)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Available Methods
|
|
95
|
+
|
|
96
|
+
| Method | Description |
|
|
97
|
+
|----------|-------------|
|
|
98
|
+
| `get_song(song_id)` | Get streaming link for a song |
|
|
99
|
+
| `get_detail_playlist(playlist_id)` | Get detailed information and songs in a playlist |
|
|
100
|
+
| `get_home()` | Get data for the home page |
|
|
101
|
+
| `get_top100()` | Get Top 100 list |
|
|
102
|
+
| `get_chart_home()` | Get chart home data |
|
|
103
|
+
| `get_new_release_chart()` | Get new release chart |
|
|
104
|
+
| `get_info_song(song_id)` | Get basic information for a song |
|
|
105
|
+
| `get_list_artist_song(artist_id, page, count)` | Get list of songs by an artist |
|
|
106
|
+
| `get_artist(name)` | Get artist information by alias/name |
|
|
107
|
+
| `get_lyric(song_id)` | Get lyrics for a song |
|
|
108
|
+
| `search(name)` | Search for songs, artists, playlists, albums, videos |
|
|
109
|
+
| `get_list_mv(id, page, count)` | Get list of MVs by category/genre |
|
|
110
|
+
| `get_category_mv(id)` | Get info about a video category |
|
|
111
|
+
| `get_video(video_id)` | Get detailed information for a video/MV |
|
|
112
|
+
|
|
113
|
+
## Show Available Methods
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from zingmp3_api import ZingMp3
|
|
117
|
+
|
|
118
|
+
ZingMp3.help()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Output:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
Available methods in ZingMp3Api:
|
|
125
|
+
- get_song(song_id) : Get streaming link for a song
|
|
126
|
+
- get_detail_playlist(playlist_id) : Get detailed information and songs in a playlist
|
|
127
|
+
- get_home() : Get data for the home page
|
|
128
|
+
- get_top100() : Get Top 100 list
|
|
129
|
+
- get_chart_home() : Get chart home data
|
|
130
|
+
- get_new_release_chart() : Get new release chart
|
|
131
|
+
- get_info_song(song_id) : Get basic information for a song
|
|
132
|
+
- get_list_artist_song(artist_id, page, count) : Get list of songs by an artist
|
|
133
|
+
- get_artist(name) : Get artist information by alias/name
|
|
134
|
+
- get_lyric(song_id) : Get lyrics for a song
|
|
135
|
+
- search(name) : Search for songs, artists, playlists, etc
|
|
136
|
+
- get_list_mv(id, page, count) : Get list of MVs by category/genre
|
|
137
|
+
- get_category_mv(id) : Get info about a video category
|
|
138
|
+
- get_video(video_id) : Get detailed information for a video/MV
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Requirements
|
|
142
|
+
|
|
143
|
+
- Python 3.8+
|
|
144
|
+
- requests
|
|
145
|
+
|
|
146
|
+
## Install Dependencies
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install requests
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Original code
|
|
153
|
+
|
|
154
|
+
[phamhiep2506](https://github.com/phamhiep2506/zingmp3-api-full)
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT License
|
|
159
|
+
|
|
160
|
+
## Disclaimer
|
|
161
|
+
|
|
162
|
+
This project is an unofficial wrapper for Zing MP3 APIs and is intended for educational and research purposes only.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# zingmp3-api
|
|
2
|
+
|
|
3
|
+
Python wrapper for Zing MP3 API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install zingmp3-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from zingmp3_api import ZingMp3
|
|
15
|
+
|
|
16
|
+
result = ZingMp3.search("sontungmtp")
|
|
17
|
+
print(result)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Examples
|
|
21
|
+
|
|
22
|
+
### Search
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from zingmp3_api import ZingMp3
|
|
26
|
+
|
|
27
|
+
data = ZingMp3.search("sontungmtp")
|
|
28
|
+
print(data)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Get Song Streaming URL
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from zingmp3_api import ZingMp3
|
|
35
|
+
|
|
36
|
+
data = ZingMp3.get_song("Z8U96AD8")
|
|
37
|
+
print(data)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Get Song Information
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from zingmp3_api import ZingMp3
|
|
44
|
+
|
|
45
|
+
data = ZingMp3.get_info_song("Z8U96AD8")
|
|
46
|
+
print(data)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Get Lyrics
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from zingmp3_api import ZingMp3
|
|
53
|
+
|
|
54
|
+
data = ZingMp3.get_lyric("Z8U96AD8")
|
|
55
|
+
print(data)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Get Playlist Details
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from zingmp3_api import ZingMp3
|
|
62
|
+
|
|
63
|
+
data = ZingMp3.get_detail_playlist("Z8U96AD8")
|
|
64
|
+
print(data)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Get Artist Information
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from zingmp3_api import ZingMp3
|
|
71
|
+
|
|
72
|
+
data = ZingMp3.get_artist("son-tung-mtp")
|
|
73
|
+
print(data)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Get Home Page Data
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from zingmp3_api import ZingMp3
|
|
80
|
+
|
|
81
|
+
data = ZingMp3.get_home()
|
|
82
|
+
print(data)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Available Methods
|
|
86
|
+
|
|
87
|
+
| Method | Description |
|
|
88
|
+
|----------|-------------|
|
|
89
|
+
| `get_song(song_id)` | Get streaming link for a song |
|
|
90
|
+
| `get_detail_playlist(playlist_id)` | Get detailed information and songs in a playlist |
|
|
91
|
+
| `get_home()` | Get data for the home page |
|
|
92
|
+
| `get_top100()` | Get Top 100 list |
|
|
93
|
+
| `get_chart_home()` | Get chart home data |
|
|
94
|
+
| `get_new_release_chart()` | Get new release chart |
|
|
95
|
+
| `get_info_song(song_id)` | Get basic information for a song |
|
|
96
|
+
| `get_list_artist_song(artist_id, page, count)` | Get list of songs by an artist |
|
|
97
|
+
| `get_artist(name)` | Get artist information by alias/name |
|
|
98
|
+
| `get_lyric(song_id)` | Get lyrics for a song |
|
|
99
|
+
| `search(name)` | Search for songs, artists, playlists, albums, videos |
|
|
100
|
+
| `get_list_mv(id, page, count)` | Get list of MVs by category/genre |
|
|
101
|
+
| `get_category_mv(id)` | Get info about a video category |
|
|
102
|
+
| `get_video(video_id)` | Get detailed information for a video/MV |
|
|
103
|
+
|
|
104
|
+
## Show Available Methods
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from zingmp3_api import ZingMp3
|
|
108
|
+
|
|
109
|
+
ZingMp3.help()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Output:
|
|
113
|
+
|
|
114
|
+
```text
|
|
115
|
+
Available methods in ZingMp3Api:
|
|
116
|
+
- get_song(song_id) : Get streaming link for a song
|
|
117
|
+
- get_detail_playlist(playlist_id) : Get detailed information and songs in a playlist
|
|
118
|
+
- get_home() : Get data for the home page
|
|
119
|
+
- get_top100() : Get Top 100 list
|
|
120
|
+
- get_chart_home() : Get chart home data
|
|
121
|
+
- get_new_release_chart() : Get new release chart
|
|
122
|
+
- get_info_song(song_id) : Get basic information for a song
|
|
123
|
+
- get_list_artist_song(artist_id, page, count) : Get list of songs by an artist
|
|
124
|
+
- get_artist(name) : Get artist information by alias/name
|
|
125
|
+
- get_lyric(song_id) : Get lyrics for a song
|
|
126
|
+
- search(name) : Search for songs, artists, playlists, etc
|
|
127
|
+
- get_list_mv(id, page, count) : Get list of MVs by category/genre
|
|
128
|
+
- get_category_mv(id) : Get info about a video category
|
|
129
|
+
- get_video(video_id) : Get detailed information for a video/MV
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Requirements
|
|
133
|
+
|
|
134
|
+
- Python 3.8+
|
|
135
|
+
- requests
|
|
136
|
+
|
|
137
|
+
## Install Dependencies
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pip install requests
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Original code
|
|
144
|
+
|
|
145
|
+
[phamhiep2506](https://github.com/phamhiep2506/zingmp3-api-full)
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT License
|
|
150
|
+
|
|
151
|
+
## Disclaimer
|
|
152
|
+
|
|
153
|
+
This project is an unofficial wrapper for Zing MP3 APIs and is intended for educational and research purposes only.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zingmp3-api"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Python wrapper for Zing MP3 API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
dependencies = ["requests"]
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Vinh LC"}
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[tool.setuptools]
|
|
17
|
+
packages = ["zingmp3_api"]
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
import hmac
|
|
3
|
+
import time
|
|
4
|
+
import requests
|
|
5
|
+
|
|
6
|
+
class ZingMp3Api:
|
|
7
|
+
def __init__(self, version: str, url: str, secret_key: str, api_key: str, ctime: str = None):
|
|
8
|
+
self.VERSION = version
|
|
9
|
+
self.URL = url
|
|
10
|
+
self.SECRET_KEY = secret_key
|
|
11
|
+
self.API_KEY = api_key
|
|
12
|
+
self.CTIME = ctime if ctime else str(int(time.time()))
|
|
13
|
+
self.session = requests.Session()
|
|
14
|
+
self.cookie = None
|
|
15
|
+
|
|
16
|
+
def _get_ctime(self):
|
|
17
|
+
return str(int(time.time()))
|
|
18
|
+
|
|
19
|
+
def _get_hash256(self, string: str):
|
|
20
|
+
return hashlib.sha256(string.encode('utf-8')).hexdigest()
|
|
21
|
+
|
|
22
|
+
def _get_hmac512(self, string: str, key: str):
|
|
23
|
+
return hmac.new(key.encode('utf-8'), string.encode('utf-8'), hashlib.sha512).hexdigest()
|
|
24
|
+
|
|
25
|
+
def _hash_param_no_id(self, path: str, ctime: str):
|
|
26
|
+
return self._get_hmac512(
|
|
27
|
+
path + self._get_hash256(f"ctime={ctime}version={self.VERSION}"),
|
|
28
|
+
self.SECRET_KEY
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def _hash_param(self, path: str, id: str, ctime: str):
|
|
32
|
+
return self._get_hmac512(
|
|
33
|
+
path + self._get_hash256(f"ctime={ctime}id={id}version={self.VERSION}"),
|
|
34
|
+
self.SECRET_KEY
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def _hash_param_home(self, path: str, ctime: str):
|
|
38
|
+
return self._get_hmac512(
|
|
39
|
+
path + self._get_hash256(f"count=30ctime={ctime}page=1version={self.VERSION}"),
|
|
40
|
+
self.SECRET_KEY
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def _hash_category_mv(self, path: str, id: str, type: str, ctime: str):
|
|
44
|
+
return self._get_hmac512(
|
|
45
|
+
path + self._get_hash256(f"ctime={ctime}id={id}type={type}version={self.VERSION}"),
|
|
46
|
+
self.SECRET_KEY
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def _hash_list_mv(self, path: str, id: str, type: str, page: str, count: str, ctime: str):
|
|
50
|
+
return self._get_hmac512(
|
|
51
|
+
path + self._get_hash256(f"count={count}ctime={ctime}id={id}page={page}type={type}version={self.VERSION}"),
|
|
52
|
+
self.SECRET_KEY
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def _get_cookie(self):
|
|
56
|
+
if self.cookie:
|
|
57
|
+
return self.cookie
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
response = self.session.get(self.URL, timeout=10)
|
|
61
|
+
set_cookies = response.raw.headers.getlist('Set-Cookie')
|
|
62
|
+
if len(set_cookies) > 1:
|
|
63
|
+
self.cookie = set_cookies[1].split(';')[0]
|
|
64
|
+
elif len(set_cookies) > 0:
|
|
65
|
+
self.cookie = set_cookies[0].split(';')[0]
|
|
66
|
+
except Exception as e:
|
|
67
|
+
print(f"Error getting cookie: {e}")
|
|
68
|
+
|
|
69
|
+
return self.cookie
|
|
70
|
+
|
|
71
|
+
def _request_zing_mp3(self, path: str, params: dict):
|
|
72
|
+
ctime = self.CTIME
|
|
73
|
+
cookie = self._get_cookie()
|
|
74
|
+
|
|
75
|
+
full_params = {
|
|
76
|
+
**params,
|
|
77
|
+
"ctime": ctime,
|
|
78
|
+
"version": self.VERSION,
|
|
79
|
+
"apiKey": self.API_KEY
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
headers = {
|
|
83
|
+
"Cookie": cookie if cookie else ""
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
response = self.session.get(self.URL + path, params=full_params, headers=headers, timeout=10)
|
|
88
|
+
return response.json()
|
|
89
|
+
except Exception as e:
|
|
90
|
+
return {"err": -1, "msg": str(e)}
|
|
91
|
+
|
|
92
|
+
def get_song(self, song_id: str):
|
|
93
|
+
"""
|
|
94
|
+
Get streaming link for a song.
|
|
95
|
+
:param song_id: ID of the song (e.g., 'Z8U96AD8')
|
|
96
|
+
:return: JSON response containing streaming URL
|
|
97
|
+
"""
|
|
98
|
+
path = "/api/v2/song/get/streaming"
|
|
99
|
+
ctime = self._get_ctime()
|
|
100
|
+
return self._request_zing_mp3(path, {
|
|
101
|
+
"id": song_id,
|
|
102
|
+
"sig": self._hash_param(path, song_id, ctime),
|
|
103
|
+
"ctime": ctime
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
def get_detail_playlist(self, playlist_id: str):
|
|
107
|
+
"""
|
|
108
|
+
Get detailed information and songs in a playlist.
|
|
109
|
+
:param playlist_id: ID of the playlist
|
|
110
|
+
:return: JSON response containing playlist details
|
|
111
|
+
"""
|
|
112
|
+
path = "/api/v2/page/get/playlist"
|
|
113
|
+
ctime = self._get_ctime()
|
|
114
|
+
return self._request_zing_mp3(path, {
|
|
115
|
+
"id": playlist_id,
|
|
116
|
+
"sig": self._hash_param(path, playlist_id, ctime),
|
|
117
|
+
"ctime": ctime
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
def get_home(self):
|
|
121
|
+
"""
|
|
122
|
+
Get data for the home page.
|
|
123
|
+
:return: JSON response for home page
|
|
124
|
+
"""
|
|
125
|
+
path = "/api/v2/page/get/home"
|
|
126
|
+
ctime = self._get_ctime()
|
|
127
|
+
return self._request_zing_mp3(path, {
|
|
128
|
+
"page": 1,
|
|
129
|
+
"segmentId": "-1",
|
|
130
|
+
"count": "30",
|
|
131
|
+
"sig": self._hash_param_home(path, ctime),
|
|
132
|
+
"ctime": ctime
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
def get_top100(self):
|
|
136
|
+
"""
|
|
137
|
+
Get Top 100 list.
|
|
138
|
+
:return: JSON response for Top 100
|
|
139
|
+
"""
|
|
140
|
+
path = "/api/v2/page/get/top-100"
|
|
141
|
+
ctime = self._get_ctime()
|
|
142
|
+
return self._request_zing_mp3(path, {
|
|
143
|
+
"sig": self._hash_param_no_id(path, ctime),
|
|
144
|
+
"ctime": ctime
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
def get_chart_home(self):
|
|
148
|
+
"""
|
|
149
|
+
Get chart home data.
|
|
150
|
+
:return: JSON response for chart home
|
|
151
|
+
"""
|
|
152
|
+
path = "/api/v2/page/get/chart-home"
|
|
153
|
+
ctime = self._get_ctime()
|
|
154
|
+
return self._request_zing_mp3(path, {
|
|
155
|
+
"sig": self._hash_param_no_id(path, ctime),
|
|
156
|
+
"ctime": ctime
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
def get_new_release_chart(self):
|
|
160
|
+
"""
|
|
161
|
+
Get new release chart.
|
|
162
|
+
:return: JSON response for new release chart
|
|
163
|
+
"""
|
|
164
|
+
path = "/api/v2/page/get/newrelease-chart"
|
|
165
|
+
ctime = self._get_ctime()
|
|
166
|
+
return self._request_zing_mp3(path, {
|
|
167
|
+
"sig": self._hash_param_no_id(path, ctime),
|
|
168
|
+
"ctime": ctime
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
def get_info_song(self, song_id: str):
|
|
172
|
+
"""
|
|
173
|
+
Get basic information for a song.
|
|
174
|
+
:param song_id: ID of the song
|
|
175
|
+
:return: JSON response containing song info
|
|
176
|
+
"""
|
|
177
|
+
path = "/api/v2/song/get/info"
|
|
178
|
+
ctime = self._get_ctime()
|
|
179
|
+
return self._request_zing_mp3(path, {
|
|
180
|
+
"id": song_id,
|
|
181
|
+
"sig": self._hash_param(path, song_id, ctime),
|
|
182
|
+
"ctime": ctime
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
def get_list_artist_song(self, artist_id: str, page: str, count: str):
|
|
186
|
+
"""
|
|
187
|
+
Get list of songs by an artist.
|
|
188
|
+
:param artist_id: ID of the artist
|
|
189
|
+
:param page: Page number
|
|
190
|
+
:param count: Number of items per page
|
|
191
|
+
:return: JSON response containing list of songs
|
|
192
|
+
"""
|
|
193
|
+
path = "/api/v2/song/get/list"
|
|
194
|
+
ctime = self._get_ctime()
|
|
195
|
+
return self._request_zing_mp3(path, {
|
|
196
|
+
"id": artist_id,
|
|
197
|
+
"type": "artist",
|
|
198
|
+
"page": page,
|
|
199
|
+
"count": count,
|
|
200
|
+
"sort": "new",
|
|
201
|
+
"sectionId": "aSong",
|
|
202
|
+
"sig": self._hash_list_mv(path, artist_id, "artist", page, count, ctime),
|
|
203
|
+
"ctime": ctime
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
def get_artist(self, name: str):
|
|
207
|
+
"""
|
|
208
|
+
Get artist information by alias/name.
|
|
209
|
+
:param name: Artist alias (e.g., 'son-tung-mtp')
|
|
210
|
+
:return: JSON response for artist page
|
|
211
|
+
"""
|
|
212
|
+
path = "/api/v2/page/get/artist"
|
|
213
|
+
ctime = self._get_ctime()
|
|
214
|
+
return self._request_zing_mp3(path, {
|
|
215
|
+
"alias": name,
|
|
216
|
+
"sig": self._hash_param_no_id(path, ctime),
|
|
217
|
+
"ctime": ctime
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
def get_lyric(self, song_id: str):
|
|
221
|
+
"""
|
|
222
|
+
Get lyrics for a song.
|
|
223
|
+
:param song_id: ID of the song
|
|
224
|
+
:return: JSON response containing lyrics
|
|
225
|
+
"""
|
|
226
|
+
path = "/api/v2/lyric/get/lyric"
|
|
227
|
+
ctime = self._get_ctime()
|
|
228
|
+
return self._request_zing_mp3(path, {
|
|
229
|
+
"id": song_id,
|
|
230
|
+
"sig": self._hash_param(path, song_id, ctime),
|
|
231
|
+
"ctime": ctime
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
def search(self, name: str):
|
|
235
|
+
"""
|
|
236
|
+
Search for songs, artists, playlists, etc.
|
|
237
|
+
:param name: Search query
|
|
238
|
+
:return: JSON response for search results
|
|
239
|
+
"""
|
|
240
|
+
path = "/api/v2/search/multi"
|
|
241
|
+
ctime = self._get_ctime()
|
|
242
|
+
return self._request_zing_mp3(path, {
|
|
243
|
+
"q": name,
|
|
244
|
+
"sig": self._hash_param_no_id(path, ctime),
|
|
245
|
+
"ctime": ctime
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
def get_list_mv(self, id: str, page: str, count: str):
|
|
249
|
+
"""
|
|
250
|
+
Get list of MVs by category/genre.
|
|
251
|
+
:param id: Genre/Category ID
|
|
252
|
+
:param page: Page number
|
|
253
|
+
:param count: Number of items per page
|
|
254
|
+
:return: JSON response containing MV list
|
|
255
|
+
"""
|
|
256
|
+
path = "/api/v2/video/get/list"
|
|
257
|
+
ctime = self._get_ctime()
|
|
258
|
+
return self._request_zing_mp3(path, {
|
|
259
|
+
"id": id,
|
|
260
|
+
"type": "genre",
|
|
261
|
+
"page": page,
|
|
262
|
+
"count": count,
|
|
263
|
+
"sort": "listen",
|
|
264
|
+
"sig": self._hash_list_mv(path, id, "genre", page, count, ctime),
|
|
265
|
+
"ctime": ctime
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
def get_category_mv(self, id: str):
|
|
269
|
+
"""
|
|
270
|
+
Get info about a video category.
|
|
271
|
+
:param id: Category ID
|
|
272
|
+
:return: JSON response for category info
|
|
273
|
+
"""
|
|
274
|
+
path = "/api/v2/genre/get/info"
|
|
275
|
+
ctime = self._get_ctime()
|
|
276
|
+
return self._request_zing_mp3(path, {
|
|
277
|
+
"id": id,
|
|
278
|
+
"type": "video",
|
|
279
|
+
"sig": self._hash_category_mv(path, id, "video", ctime),
|
|
280
|
+
"ctime": ctime
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
def get_video(self, video_id: str):
|
|
284
|
+
"""
|
|
285
|
+
Get detailed information for a video/MV.
|
|
286
|
+
:param video_id: ID of the video
|
|
287
|
+
:return: JSON response for video details
|
|
288
|
+
"""
|
|
289
|
+
path = "/api/v2/page/get/video"
|
|
290
|
+
ctime = self._get_ctime()
|
|
291
|
+
return self._request_zing_mp3(path, {
|
|
292
|
+
"id": video_id,
|
|
293
|
+
"sig": self._hash_param(path, video_id, ctime),
|
|
294
|
+
"ctime": ctime
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
def help(self):
|
|
298
|
+
"""
|
|
299
|
+
Print available methods and their descriptions.
|
|
300
|
+
"""
|
|
301
|
+
methods = [
|
|
302
|
+
("get_song(song_id)", "Get streaming link for a song"),
|
|
303
|
+
("get_detail_playlist(playlist_id)", "Get detailed information and songs in a playlist"),
|
|
304
|
+
("get_home()", "Get data for the home page"),
|
|
305
|
+
("get_top100()", "Get Top 100 list"),
|
|
306
|
+
("get_chart_home()", "Get chart home data"),
|
|
307
|
+
("get_new_release_chart()", "Get new release chart"),
|
|
308
|
+
("get_info_song(song_id)", "Get basic information for a song"),
|
|
309
|
+
("get_list_artist_song(artist_id, page, count)", "Get list of songs by an artist"),
|
|
310
|
+
("get_artist(name)", "Get artist information by alias/name"),
|
|
311
|
+
("get_lyric(song_id)", "Get lyrics for a song"),
|
|
312
|
+
("search(name)", "Search for songs, artists, playlists, etc"),
|
|
313
|
+
("get_list_mv(id, page, count)", "Get list of MVs by category/genre"),
|
|
314
|
+
("get_category_mv(id)", "Get info about a video category"),
|
|
315
|
+
("get_video(video_id)", "Get detailed information for a video/MV"),
|
|
316
|
+
]
|
|
317
|
+
print("Available methods in ZingMp3Api:")
|
|
318
|
+
for method, desc in methods:
|
|
319
|
+
print(f" - {method:45} : {desc}")
|
|
320
|
+
|
|
321
|
+
# Default instance
|
|
322
|
+
ZingMp3 = ZingMp3Api(
|
|
323
|
+
version="1.6.34",
|
|
324
|
+
url="https://zingmp3.vn",
|
|
325
|
+
secret_key="2aa2d1c561e809b267f3638c4a307aab",
|
|
326
|
+
api_key="88265e23d4284f25963e6eedac8fbfa3",
|
|
327
|
+
ctime=str(int(time.time()))
|
|
328
|
+
)
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: zingmp3-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python wrapper for Zing MP3 API
|
|
5
|
+
Author: Vinh LC
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests
|
|
9
|
+
|
|
10
|
+
# zingmp3-api
|
|
11
|
+
|
|
12
|
+
Python wrapper for Zing MP3 API.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install zingmp3-api
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from zingmp3_api import ZingMp3
|
|
24
|
+
|
|
25
|
+
result = ZingMp3.search("sontungmtp")
|
|
26
|
+
print(result)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
|
|
31
|
+
### Search
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from zingmp3_api import ZingMp3
|
|
35
|
+
|
|
36
|
+
data = ZingMp3.search("sontungmtp")
|
|
37
|
+
print(data)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Get Song Streaming URL
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from zingmp3_api import ZingMp3
|
|
44
|
+
|
|
45
|
+
data = ZingMp3.get_song("Z8U96AD8")
|
|
46
|
+
print(data)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Get Song Information
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from zingmp3_api import ZingMp3
|
|
53
|
+
|
|
54
|
+
data = ZingMp3.get_info_song("Z8U96AD8")
|
|
55
|
+
print(data)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Get Lyrics
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from zingmp3_api import ZingMp3
|
|
62
|
+
|
|
63
|
+
data = ZingMp3.get_lyric("Z8U96AD8")
|
|
64
|
+
print(data)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Get Playlist Details
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from zingmp3_api import ZingMp3
|
|
71
|
+
|
|
72
|
+
data = ZingMp3.get_detail_playlist("Z8U96AD8")
|
|
73
|
+
print(data)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Get Artist Information
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from zingmp3_api import ZingMp3
|
|
80
|
+
|
|
81
|
+
data = ZingMp3.get_artist("son-tung-mtp")
|
|
82
|
+
print(data)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Get Home Page Data
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from zingmp3_api import ZingMp3
|
|
89
|
+
|
|
90
|
+
data = ZingMp3.get_home()
|
|
91
|
+
print(data)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Available Methods
|
|
95
|
+
|
|
96
|
+
| Method | Description |
|
|
97
|
+
|----------|-------------|
|
|
98
|
+
| `get_song(song_id)` | Get streaming link for a song |
|
|
99
|
+
| `get_detail_playlist(playlist_id)` | Get detailed information and songs in a playlist |
|
|
100
|
+
| `get_home()` | Get data for the home page |
|
|
101
|
+
| `get_top100()` | Get Top 100 list |
|
|
102
|
+
| `get_chart_home()` | Get chart home data |
|
|
103
|
+
| `get_new_release_chart()` | Get new release chart |
|
|
104
|
+
| `get_info_song(song_id)` | Get basic information for a song |
|
|
105
|
+
| `get_list_artist_song(artist_id, page, count)` | Get list of songs by an artist |
|
|
106
|
+
| `get_artist(name)` | Get artist information by alias/name |
|
|
107
|
+
| `get_lyric(song_id)` | Get lyrics for a song |
|
|
108
|
+
| `search(name)` | Search for songs, artists, playlists, albums, videos |
|
|
109
|
+
| `get_list_mv(id, page, count)` | Get list of MVs by category/genre |
|
|
110
|
+
| `get_category_mv(id)` | Get info about a video category |
|
|
111
|
+
| `get_video(video_id)` | Get detailed information for a video/MV |
|
|
112
|
+
|
|
113
|
+
## Show Available Methods
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from zingmp3_api import ZingMp3
|
|
117
|
+
|
|
118
|
+
ZingMp3.help()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Output:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
Available methods in ZingMp3Api:
|
|
125
|
+
- get_song(song_id) : Get streaming link for a song
|
|
126
|
+
- get_detail_playlist(playlist_id) : Get detailed information and songs in a playlist
|
|
127
|
+
- get_home() : Get data for the home page
|
|
128
|
+
- get_top100() : Get Top 100 list
|
|
129
|
+
- get_chart_home() : Get chart home data
|
|
130
|
+
- get_new_release_chart() : Get new release chart
|
|
131
|
+
- get_info_song(song_id) : Get basic information for a song
|
|
132
|
+
- get_list_artist_song(artist_id, page, count) : Get list of songs by an artist
|
|
133
|
+
- get_artist(name) : Get artist information by alias/name
|
|
134
|
+
- get_lyric(song_id) : Get lyrics for a song
|
|
135
|
+
- search(name) : Search for songs, artists, playlists, etc
|
|
136
|
+
- get_list_mv(id, page, count) : Get list of MVs by category/genre
|
|
137
|
+
- get_category_mv(id) : Get info about a video category
|
|
138
|
+
- get_video(video_id) : Get detailed information for a video/MV
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Requirements
|
|
142
|
+
|
|
143
|
+
- Python 3.8+
|
|
144
|
+
- requests
|
|
145
|
+
|
|
146
|
+
## Install Dependencies
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install requests
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Original code
|
|
153
|
+
|
|
154
|
+
[phamhiep2506](https://github.com/phamhiep2506/zingmp3-api-full)
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT License
|
|
159
|
+
|
|
160
|
+
## Disclaimer
|
|
161
|
+
|
|
162
|
+
This project is an unofficial wrapper for Zing MP3 APIs and is intended for educational and research purposes only.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
zingmp3_api
|