Skip to content

Commit

Permalink
访问云圈任务可手动填写ID
Browse files Browse the repository at this point in the history
  • Loading branch information
chen310 committed Mar 12, 2022
1 parent 81d8ed3 commit 8f1282b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
4 changes: 3 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@
"740005": {
"taskName": "访问自己的云圈",
"module": "visitMyCircle",
"enable": false
"enable": false,
/* 自己的云圈ID,可不填写,如果提示 resourceID 获取失败,则需要手动填写 */
"circleId": ""
},
/* 发布Mlog:根据填写的歌曲ID,自动下载歌曲的专辑图,并上传 */
"744005": {
Expand Down
39 changes: 21 additions & 18 deletions task/visitMyCircle.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
def start(user, task={}):
music = user.music

artistId = user.artistId
if not artistId:
user.taskInfo(task['taskName'], 'artistId 获取失败')
return
artist_resp = music.artist_homepage(artistId)
resourceId = ''
blocks = artist_resp['data']['blocks']
for block in blocks:
if block['showType'] == 'MY_CIRCLE_WITH_MORE':
creatives = block['creatives']
for creative in creatives:
resources = creative['resources']
for resource in resources:
if resource['resourceType'] == 'CIRCLE':
resourceId = resource['resourceId']
if 'circleId' in task and len(task['circleId']) > 0:
resourceId = task['circleId']
else:
artistId = user.artistId
if not artistId:
user.taskInfo(task['taskName'], 'artistId 获取失败')
return
artist_resp = music.artist_homepage(artistId)
blocks = artist_resp['data']['blocks']
for block in blocks:
if block['showType'] == 'MY_CIRCLE_WITH_MORE':
creatives = block['creatives']
for creative in creatives:
resources = creative['resources']
for resource in resources:
if resource['resourceType'] == 'CIRCLE':
resourceId = resource['resourceId']
break
if resourceId:
break
if resourceId:
break
if resourceId:
break
if resourceId:
break
if not resourceId:
user.taskInfo(task['taskName'], 'resourceId 获取失败')
return
Expand Down

0 comments on commit 8f1282b

Please sign in to comment.