Skip to content

Commit 841cf06

Browse files
authored
Merge pull request #69 from luren-dc/master
feat: 获取歌单全部歌曲
2 parents 932576d + 4063c97 commit 841cf06

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pyncm/apis/playlist.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# -*- coding: utf-8 -*-
22
"""歌单 - Playlist APIs"""
3-
from . import EapiCryptoRequest, WeapiCryptoRequest
3+
44
import json
55

6+
from . import EapiCryptoRequest, WeapiCryptoRequest
7+
68

79
@WeapiCryptoRequest
810
def GetPlaylistInfo(playlist_id, offset=0, total=True, limit=1000):
@@ -26,6 +28,25 @@ def GetPlaylistInfo(playlist_id, offset=0, total=True, limit=1000):
2628
}
2729

2830

31+
def GetPlaylistAllTracks(playlist_id, offset=0, limit=1000):
32+
"""网页端 - 获取歌单所有歌曲
33+
34+
Args:
35+
playlist_id ([type]): 歌单 ID
36+
offset (int, optional): 获取偏移数. Defaults to 0.
37+
limit (int, optional): 单次获取量. Defaults to 1000.
38+
39+
Returns:
40+
dict
41+
"""
42+
data = GetPlaylistInfo(playlist_id, offset, True, limit)
43+
trackIds = [track["id"] for track in data["playlist"]["trackIds"]]
44+
id = trackIds[offset : offset + limit]
45+
from .track import GetTrackDetail
46+
47+
return GetTrackDetail(id)
48+
49+
2950
@WeapiCryptoRequest
3051
def GetPlaylistComments(playlist_id: str, offset=0, limit=20, beforeTime=0):
3152
"""网页端 - 获取歌单评论

0 commit comments

Comments
 (0)