py_企鹅体育.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. import math
  8. import re
  9. class Spider(Spider):
  10. def getName(self):
  11. return "企鹅体育"
  12. def init(self,extend=""):
  13. pass
  14. def isVideoFormat(self,url):
  15. pass
  16. def manualVideoCheck(self):
  17. pass
  18. def homeContent(self,filter):
  19. result = {}
  20. cateManual = {
  21. "全部": "",
  22. "足球": "Football",
  23. "篮球": "Basketball",
  24. "NBA": "NBA",
  25. "台球": "Billiards",
  26. "搏击": "Fight",
  27. "网排": "Tennis",
  28. "游戏": "Game",
  29. "其他": "Others",
  30. "橄棒冰": "MLB"
  31. }
  32. classes = []
  33. for k in cateManual:
  34. classes.append({
  35. 'type_name': k,
  36. 'type_id': cateManual[k]
  37. })
  38. result['class'] = classes
  39. if (filter):
  40. result['filters'] = self.config['filter']
  41. return result
  42. def homeVideoContent(self):
  43. result = {}
  44. return result
  45. def categoryContent(self,tid,pg,filter,extend):
  46. result = {}
  47. url = 'https://live.qq.com/api/live/vlist?page_size=60&shortName={0}&page={1}'.format(tid, pg)
  48. rsp = self.fetch(url)
  49. content = rsp.text
  50. jo = json.loads(content)
  51. videos = []
  52. vodList = jo['data']['result']
  53. numvL = len(vodList)
  54. pgc = math.ceil(numvL/15)
  55. for vod in vodList:
  56. aid = (vod['room_id'])
  57. title = vod['room_name'].strip()
  58. img = vod['room_src']
  59. remark = (vod['game_name']).strip()
  60. videos.append({
  61. "vod_id": aid,
  62. "vod_name": title,
  63. "vod_pic": img,
  64. "vod_remarks": remark
  65. })
  66. result['list'] = videos
  67. result['page'] = pg
  68. result['pagecount'] = pgc
  69. result['limit'] = numvL
  70. result['total'] = numvL
  71. return result
  72. def detailContent(self,array):
  73. aid = array[0]
  74. url = "https://m.live.qq.com/{0}".format(aid)
  75. rsp = self.fetch(url)
  76. html = self.cleanText(rsp.text)
  77. if self.regStr(reg=r'\"show_status\":\"(\d)\"', src=html) == '1':
  78. title = self.regStr(reg=r'\"room_name\":\"(.*?)\"', src=html)
  79. pic = self.regStr(reg=r'\"room_src\":\"(.*?)\"', src=html)
  80. typeName = self.regStr(reg=r'\"game_name\":\"(.*?)\"', src=html)
  81. remark = self.regStr(reg=r'\"nickname\":\"(.*?)\"', src=html)
  82. purl = self.regStr(reg=r'\"hls_url\":\"(.*?)\"', src=html)
  83. else:
  84. return {}
  85. vod = {
  86. "vod_id": aid,
  87. "vod_name": title,
  88. "vod_pic": pic,
  89. "type_name": typeName,
  90. "vod_year": "",
  91. "vod_area": "",
  92. "vod_remarks": remark,
  93. "vod_actor": '',
  94. "vod_director":'',
  95. "vod_content": ''
  96. }
  97. playUrl = '{0}${1}#'.format(typeName, purl)
  98. vod['vod_play_from'] = '🌸荷城茶秀接口🌸企鹅线路'
  99. vod['vod_play_url'] = playUrl
  100. result = {
  101. 'list': [
  102. vod
  103. ]
  104. }
  105. return result
  106. def searchContent(self,key,quick):
  107. result = {}
  108. return result
  109. def playerContent(self,flag,id,vipFlags):
  110. result = {}
  111. url = id
  112. header = {
  113. 'Referer': 'https://m.live.qq.com/',
  114. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  115. }
  116. result["parse"] = 0
  117. result["playUrl"] = ''
  118. result["url"] = url
  119. result["header"] = header
  120. return result
  121. config = {
  122. "player": {},
  123. "filter": {}
  124. }
  125. header = {}
  126. def localProxy(self,param):
  127. action = {
  128. 'url':'',
  129. 'header':'',
  130. 'param':'',
  131. 'type':'string',
  132. 'after':''
  133. }
  134. return [200, "video/MP2T", action, ""]