| 6 | import json |
| 7 | |
| 8 | class Spider(Spider): |
| 9 | def getName(self): |
| 10 | return "斗鱼" |
| 11 | def init(self,extend=""): |
| 12 | pass |
| 13 | def isVideoFormat(self,url): |
| 14 | pass |
| 15 | def manualVideoCheck(self): |
| 16 | pass |
| 17 | def homeContent(self,filter): |
| 18 | result = {} |
| 19 | cateManual = { |
| 20 | "热门游戏": "热门游戏", |
| 21 | "主机游戏": "主机游戏", |
| 22 | "原创IP": "原创IP" |
| 23 | } |
| 24 | classes = [] |
| 25 | for k in cateManual: |
| 26 | classes.append({ |
| 27 | 'type_name': k, |
| 28 | 'type_id': cateManual[k] |
| 29 | }) |
| 30 | |
| 31 | result['class'] = classes |
| 32 | if (filter): |
| 33 | result['filters'] = self.config['filter'] |
| 34 | return result |
| 35 | def homeVideoContent(self): |
| 36 | result = {} |
| 37 | return result |
| 38 | def categoryContent(self,tid,pg,filter,extend): |
| 39 | result = {} |
| 40 | url = 'http://live.yj1211.work/api/live/getRecommendByPlatformArea?platform=douyu&size=20&area={0}&page={1}'.format(tid, pg) |
| 41 | rsp = self.fetch(url) |
| 42 | content = rsp.text |
| 43 | jo = json.loads(content) |
| 44 | videos = [] |
| 45 | vodList = jo['data'] |
| 46 | for vod in vodList: |
| 47 | aid = (vod['roomId']).strip() |
| 48 | title = vod['roomName'].strip() |
| 49 | img = vod['roomPic'].strip() |
| 50 | remark = (vod['ownerName']).strip() |
| 51 | videos.append({ |
| 52 | "vod_id": aid, |
| 53 | "vod_name": title, |
| 54 | "vod_pic": img, |
| 55 | "vod_remarks": remark |
| 56 | }) |
| 57 | result['list'] = videos |
| 58 | result['page'] = pg |
| 59 | result['pagecount'] = 9999 |
| 60 | result['limit'] = 90 |
| 61 | result['total'] = 999999 |
| 62 | return result |
| 63 | def detailContent(self,array): |
| 64 | aid = array[0] |
| 65 | url = "http://live.yj1211.work/api/live/getRoomInfo?platform=douyu&roomId={0}".format(aid) |
nothing calls this directly
no outgoing calls
no test coverage detected