| 153 | return result |
| 154 | |
| 155 | def searchContent(self, key, quick): |
| 156 | header = { |
| 157 | "Referer": "https://www.bilibili.com", |
| 158 | "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36" |
| 159 | } |
| 160 | url = 'https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword={0}'.format(key) |
| 161 | if len(self.cookies) <= 0: |
| 162 | self.getCookie() |
| 163 | rsp = self.fetch(url, cookies=self.cookies,headers=header) |
| 164 | content = rsp.text |
| 165 | jo = json.loads(content) |
| 166 | if jo['code'] != 0: |
| 167 | rspRetry = self.fetch(url, cookies=self.getCookie()) |
| 168 | content = rspRetry.text |
| 169 | jo = json.loads(content) |
| 170 | videos = [] |
| 171 | vodList = jo['data']['result'] |
| 172 | for vod in vodList: |
| 173 | aid = str(vod['aid']).strip() |
| 174 | title = vod['title'].replace("<em class=\"keyword\">", "").replace("</em>", "").replace(""", '"') |
| 175 | img = 'https:' + vod['pic'].strip() |
| 176 | remark = str(vod['duration']).strip() |
| 177 | videos.append({ |
| 178 | "vod_id": aid, |
| 179 | "vod_name": title, |
| 180 | "vod_pic": img, |
| 181 | "vod_remarks": remark |
| 182 | }) |
| 183 | result = { |
| 184 | 'list': videos |
| 185 | } |
| 186 | return result |
| 187 | |
| 188 | def playerContent(self, flag, id, vipFlags): |
| 189 | result = {} |