MCPcopy Create free account
hub / github.com/UndCover/PyramidStore / categoryContent

Method categoryContent

plugin/py_bilibili.py:56–86  ·  view source on GitHub ↗
(self,tid,pg,filter,extend)

Source from the content-addressed store, hash-verified

54 self.cookies = rsp.cookies
55 return rsp.cookies
56 def categoryContent(self,tid,pg,filter,extend):
57 result = {}
58 url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&duration=4&page={1}'.format(tid,pg)
59 if len(self.cookies) <= 0:
60 self.getCookie()
61 rsp = self.fetch(url,cookies=self.cookies)
62 content = rsp.text
63 jo = json.loads(content)
64 if jo['code'] != 0:
65 rspRetry = self.fetch(url,cookies=self.getCookie())
66 content = rspRetry.text
67 jo = json.loads(content)
68 videos = []
69 vodList = jo['data']['result']
70 for vod in vodList:
71 aid = str(vod['aid']).strip()
72 title = vod['title'].strip().replace("<em class=\"keyword\">","").replace("</em>","")
73 img = 'https:' + vod['pic'].strip()
74 remark = str(vod['duration']).strip()
75 videos.append({
76 "vod_id":aid,
77 "vod_name":title,
78 "vod_pic":img,
79 "vod_remarks":remark
80 })
81 result['list'] = videos
82 result['page'] = pg
83 result['pagecount'] = 9999
84 result['limit'] = 90
85 result['total'] = 999999
86 return result
87 def cleanSpace(self,str):
88 return str.replace('\n','').replace('\t','').replace('\r','').replace(' ','')
89 def detailContent(self,array):

Callers

nothing calls this directly

Calls 2

getCookieMethod · 0.95
fetchMethod · 0.95

Tested by

no test coverage detected