2
0

py_freezb.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import re
  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. }
  22. classes = []
  23. for k in cateManual:
  24. classes.append({
  25. 'type_name': k,
  26. 'type_id': cateManual[k]
  27. })
  28. result['class'] = classes
  29. if (filter):
  30. result['filters'] = self.config['filter']
  31. return result
  32. def homeVideoContent(self):
  33. result = {}
  34. return result
  35. def categoryContent(self,tid,pg,filter,extend):
  36. result = {}
  37. url = 'http://www.freezb.live/'
  38. rsp = self.fetch(url)
  39. html = self.html(rsp.text)
  40. aList = html.xpath("//tr[@class='match_main']")
  41. videos = []
  42. img = 'https://s1.ax1x.com/2022/10/07/x3NPUO.png'
  43. for a in aList:
  44. urlList = a.xpath("./td[@class='update_data live_link']/a")
  45. stat = a.xpath("./td[contains(@style, 'font-weight:bold')]/sapn/@title")[0]
  46. time = a.xpath("./td[contains(@style, 'font-weight:bold')]/sapn/text()")[0]
  47. if '比分' not in urlList[0].xpath("./text()")[0] and stat == '直播中':
  48. remark = a.xpath(".//p[@class='raceclass matchcolor']/@title")[0].replace('直播','') + '|' + time
  49. name = a.xpath("string(./td[4])").replace(' ','').replace('\tVS','VS')
  50. if 'VS' not in name:
  51. names = name.split('\t')
  52. remark = names[0] + '|' + time
  53. name = names[-1].replace('vs','VS')
  54. aid = ''
  55. for url in urlList:
  56. title = url.xpath("./text()")[0]
  57. aurl = url.xpath("./@href")[0]
  58. #aurl = self.regStr(reg=r'/tv/(.*?).html', src=aurl)
  59. if '比分' not in title:
  60. aid = aid + title + '@@@' + aurl + '#'
  61. videos.append({
  62. "vod_id": name + '###' + remark.split('|')[0] + '###' + aid,
  63. "vod_name": name,
  64. "vod_pic": img,
  65. "vod_remarks": remark
  66. })
  67. numvL = len(videos)
  68. pgc = math.ceil(numvL/15)
  69. result['list'] = videos
  70. result['page'] = pg
  71. result['pagecount'] = pgc
  72. result['limit'] = numvL
  73. result['total'] = numvL
  74. return result
  75. def detailContent(self,array):
  76. aid = array[0]
  77. aids = aid.split('###')
  78. name = aids[0]
  79. typeName = aids[1]
  80. tus = aids[2].strip('#').split('#')
  81. pic = 'https://s1.ax1x.com/2022/10/07/x3NPUO.png'
  82. vod = {
  83. "vod_id": name,
  84. "vod_name": name,
  85. "vod_pic": pic,
  86. "type_name": typeName,
  87. "vod_year": "",
  88. "vod_area": "",
  89. "vod_remarks": '',
  90. "vod_actor": '',
  91. "vod_director":'',
  92. "vod_content": ''
  93. }
  94. purl = ''
  95. for tu in tus:
  96. title = tu.split('@@@')[0]
  97. uid = tu.split('@@@')[1]
  98. purl = purl + '{0}${1}'.format(title,uid) + '#'
  99. vod['vod_play_from'] = '体育直播'
  100. vod['vod_play_url'] = purl
  101. result = {
  102. 'list': [
  103. vod
  104. ]
  105. }
  106. return result
  107. def searchContent(self,key,quick):
  108. result = {}
  109. return result
  110. def playerContent(self,flag,id,vipFlags):
  111. result = {}
  112. url = id.strip('#')
  113. rsp = self.fetch(url)
  114. root = self.html(rsp.text)
  115. phpurl = root.xpath("//div[@class='media']/iframe/@src")[0]
  116. headers = {
  117. "Referer": url,
  118. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  119. }
  120. rsp = self.fetch(phpurl,headers=headers,cookies=rsp.cookies)
  121. if 'm3u8' in rsp.text:
  122. if 'm3u8.html?id=' in rsp.text:
  123. purl = re.search(r'm3u8\.html\?id=(.*?m3u8.*?)\"', rsp.text).group(1)
  124. else:
  125. purl = re.search(r"url: \'(.*?)\'", rsp.text).group(1)
  126. if not purl.startswith('http'):
  127. purl = re.search(r"(.*)/", phpurl).group(1) + purl
  128. else:
  129. aurl = re.search(r"(.*)/", phpurl).group(1) + re.search(r'src=\"..(.*?)\"', rsp.text).group(1)
  130. aheaders = {
  131. "Referer": phpurl,
  132. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  133. }
  134. r = self.fetch(aurl, headers=aheaders, cookies=rsp.cookies)
  135. purl = re.search(r"url: \'(.*?)\'", r.text)
  136. if purl == None:
  137. purl = re.search(r'm3u8\.html\?id=(.*?)\"', r.text)
  138. purl = purl.group(1)
  139. result["parse"] = 0
  140. result["playUrl"] = ''
  141. result["url"] = purl
  142. result["header"] = ''
  143. return result
  144. config = {
  145. "player": {},
  146. "filter": {}
  147. }
  148. header = {}
  149. def localProxy(self,param):
  150. action = {
  151. 'url':'',
  152. 'header':'',
  153. 'param':'',
  154. 'type':'string',
  155. 'after':''
  156. }
  157. return [200, "video/MP2T", action, ""]