斗鱼.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import json
  7. class Spider(Spider):
  8. def getName(self):
  9. return "斗鱼"
  10. def init(self,extend=""):
  11. pass
  12. def isVideoFormat(self,url):
  13. pass
  14. def manualVideoCheck(self):
  15. pass
  16. def homeContent(self,filter):
  17. result = {}
  18. cateManual = {
  19. "原创IP": "原创IP"
  20. }
  21. classes = []
  22. for k in cateManual:
  23. classes.append({
  24. 'type_name': k,
  25. 'type_id': cateManual[k]
  26. })
  27. result['class'] = classes
  28. if (filter):
  29. result['filters'] = self.config['filter']
  30. return result
  31. def homeVideoContent(self):
  32. result = {}
  33. return result
  34. def categoryContent(self,tid,pg,filter,extend):
  35. result = {}
  36. url = 'http://live.yj1211.work/api/live/getRecommendByPlatformArea?platform=douyu&size=20&area={0}&page={1}'.format(tid, pg)
  37. rsp = self.fetch(url)
  38. content = rsp.text
  39. jo = json.loads(content)
  40. videos = []
  41. vodList = jo['data']
  42. for vod in vodList:
  43. aid = (vod['roomId']).strip()
  44. title = vod['roomName'].strip()
  45. img = vod['roomPic'].strip()
  46. remark = (vod['categoryName']).strip()
  47. videos.append({
  48. "vod_id": aid,
  49. "vod_name": title,
  50. "vod_pic": img,
  51. "vod_remarks": remark
  52. })
  53. result['list'] = videos
  54. result['page'] = pg
  55. result['pagecount'] = 9999
  56. result['limit'] = 90
  57. result['total'] = 999999
  58. return result
  59. def detailContent(self,array):
  60. aid = array[0]
  61. url = "http://live.yj1211.work/api/live/getRoomInfo?platform=douyu&roomId={0}".format(aid)
  62. rsp = self.fetch(url)
  63. jRoot = json.loads(rsp.text)
  64. jo = jRoot['data']
  65. title = jo['roomName']
  66. pic = jo['roomPic']
  67. desc = str(jo['online'])
  68. dire = jo['ownerName']
  69. typeName = jo['categoryName']
  70. remark = jo['categoryName']
  71. vod = {
  72. "vod_id": aid,
  73. "vod_name": title,
  74. "vod_pic": pic,
  75. "type_name": typeName,
  76. "vod_year": "",
  77. "vod_area": "",
  78. "vod_remarks": remark,
  79. "vod_actor": '在线人数:' + desc,
  80. "vod_director": dire,
  81. "vod_content": ""
  82. }
  83. playUrl = '原画' + '${0}#'.format(aid)
  84. vod['vod_play_from'] = '斗鱼直播'
  85. vod['vod_play_url'] = playUrl
  86. result = {
  87. 'list': [
  88. vod
  89. ]
  90. }
  91. return result
  92. def searchContent(self,key,quick):
  93. result = {}
  94. return result
  95. def playerContent(self,flag,id,vipFlags):
  96. result = {}
  97. url = 'http://live.yj1211.work/api/live/getRealUrl?platform=douyu&roomId={0}'.format(id)
  98. rsp = self.fetch(url)
  99. jRoot = json.loads(rsp.text)
  100. jo = jRoot['data']
  101. ja = jo['OD']
  102. url = ja
  103. result["parse"] = 0
  104. result["playUrl"] = ''
  105. result["url"] = url
  106. result["header"] = {
  107. "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"
  108. }
  109. result["contentType"] = 'video/x-flv'
  110. return result
  111. config = {
  112. "player": {},
  113. "filter": {}
  114. }
  115. header = {}
  116. config = {
  117. "player": {},
  118. "filter": {}
  119. }
  120. header = {}
  121. def localProxy(self,param):
  122. action = {
  123. 'url':'',
  124. 'header':'',
  125. 'param':'',
  126. 'type':'string',
  127. 'after':''
  128. }
  129. return [200, "video/MP2T", action, ""]