企鹅体育.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. 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. "足球": "Football",
  22. "篮球": "Basketball",
  23. "NBA": "NBA",
  24. "台球": "Billiards",
  25. "搏击": "Fight",
  26. "网排": "Tennis",
  27. "游戏": "Game",
  28. "其他": "Others",
  29. "橄棒冰": "MLB"
  30. }
  31. classes = []
  32. for k in cateManual:
  33. classes.append({
  34. 'type_name': k,
  35. 'type_id': cateManual[k]
  36. })
  37. result['class'] = classes
  38. if (filter):
  39. result['filters'] = self.config['filter']
  40. return result
  41. def homeVideoContent(self):
  42. result = {}
  43. return result
  44. def categoryContent(self,tid,pg,filter,extend):
  45. result = {}
  46. url = 'https://live.qq.com/api/live/vlist?page_size=60&shortName={0}&page={1}'.format(tid, pg)
  47. rsp = self.fetch(url)
  48. content = rsp.text
  49. jo = json.loads(content)
  50. videos = []
  51. vodList = jo['data']['result']
  52. numvL = len(vodList)
  53. pgc = math.ceil(numvL/15)
  54. for vod in vodList:
  55. aid = (vod['room_id'])
  56. title = vod['room_name'].strip()
  57. img = vod['room_src']
  58. remark = (vod['game_name']).strip()
  59. videos.append({
  60. "vod_id": aid,
  61. "vod_name": title,
  62. "vod_pic": img,
  63. "vod_remarks": remark
  64. })
  65. result['list'] = videos
  66. result['page'] = pg
  67. result['pagecount'] = pgc
  68. result['limit'] = numvL
  69. result['total'] = numvL
  70. return result
  71. def detailContent(self,array):
  72. aid = array[0]
  73. url = "https://m.live.qq.com/{0}".format(aid)
  74. rsp = self.fetch(url)
  75. html = self.cleanText(rsp.text)
  76. if self.regStr(reg=r'\"show_status\":\"(\d)\"', src=html) == '1':
  77. title = self.regStr(reg=r'\"room_name\":\"(.*?)\"', src=html)
  78. pic = self.regStr(reg=r'\"room_src\":\"(.*?)\"', src=html)
  79. typeName = self.regStr(reg=r'\"game_name\":\"(.*?)\"', src=html)
  80. remark = self.regStr(reg=r'\"nickname\":\"(.*?)\"', src=html)
  81. purl = self.regStr(reg=r'\"hls_url\":\"(.*?)\"', src=html)
  82. else:
  83. return {}
  84. vod = {
  85. "vod_id": aid,
  86. "vod_name": title,
  87. "vod_pic": pic,
  88. "type_name": typeName,
  89. "vod_year": "",
  90. "vod_area": "",
  91. "vod_remarks": remark,
  92. "vod_actor": '',
  93. "vod_director":'',
  94. "vod_content": ''
  95. }
  96. playUrl = '{0}${1}#'.format(typeName, purl)
  97. vod['vod_play_from'] = '企鹅体育'
  98. vod['vod_play_url'] = playUrl
  99. result = {
  100. 'list': [
  101. vod
  102. ]
  103. }
  104. return result
  105. def searchContent(self,key,quick):
  106. result = {}
  107. return result
  108. def playerContent(self,flag,id,vipFlags):
  109. result = {}
  110. url = id
  111. result["parse"] = 0
  112. result["playUrl"] = ''
  113. result["url"] = url
  114. result["header"] = ''
  115. return result
  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, ""]