| 78 | return rsp.cookies |
| 79 | |
| 80 | def categoryContent(self, tid, pg, filter, extend): |
| 81 | result = {} |
| 82 | url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}&page={1}'.format(tid, pg) |
| 83 | if len(self.cookies) <= 0: |
| 84 | self.getCookie() |
| 85 | rsp = self.fetch(url, cookies=self.cookies) |
| 86 | content = rsp.text |
| 87 | jo = json.loads(content) |
| 88 | videos = [] |
| 89 | vodList = jo['data']['result'] |
| 90 | for vod in vodList: |
| 91 | aid = str(vod['aid']).strip() |
| 92 | title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace(""", '"') |
| 93 | img = 'https:' + vod['pic'].strip() |
| 94 | remark = str(vod['duration']).strip() |
| 95 | videos.append({ |
| 96 | "vod_id": aid, |
| 97 | "vod_name": title, |
| 98 | "vod_pic": img, |
| 99 | "vod_remarks": remark |
| 100 | }) |
| 101 | result['list'] = videos |
| 102 | result['page'] = pg |
| 103 | result['pagecount'] = 9999 |
| 104 | result['limit'] = 90 |
| 105 | result['total'] = 999999 |
| 106 | return result |
| 107 | |
| 108 | def cleanSpace(self, str): |
| 109 | return str.replace('\n', '').replace('\t', '').replace('\r', '').replace(' ', '') |