py_freezb.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. url = "http://www.freezb.live/tv/{0}.html".format(uid)
  99. rsp = self.fetch(url)
  100. root = self.html(rsp.text)
  101. phpurl = root.xpath("//div[@class='media']/iframe/@src")[0]
  102. purl = purl + '{0}${1}@@@{2}'.format(title,phpurl,uid) + '#'
  103. vod['vod_play_from'] = '体育直播'
  104. vod['vod_play_url'] = purl
  105. result = {
  106. 'list': [
  107. vod
  108. ]
  109. }
  110. return result
  111. def searchContent(self,key,quick):
  112. result = {}
  113. return result
  114. def playerContent(self,flag,id,vipFlags):
  115. result = {}
  116. ids = id.split('@@@')
  117. url = ids[0]
  118. vid = ids[1]
  119. headers = {
  120. "referer": "http://www.freezb.live/tv/{0}.html".format(vid),
  121. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  122. }
  123. rsp = self.fetch(url,headers=headers)
  124. aurl = self.regStr(reg=r'\"../(.*?)\"', src=rsp.text)
  125. if aurl =='':
  126. url = self.regStr(reg=r"url: \'(.*?)\'", src=rsp.text)
  127. else:
  128. pheaders = {
  129. "referer": url,
  130. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  131. }
  132. purl = self.regStr(reg=r'(.*)/', src=url) + '/' + aurl
  133. prsp = self.fetch(purl, headers=pheaders)
  134. url = self.regStr(reg=r"url: \'(.*?)\'", src=prsp.text)
  135. result["parse"] = 0
  136. result["playUrl"] = ''
  137. result["url"] = url
  138. result["header"] = ''
  139. return result
  140. config = {
  141. "player": {},
  142. "filter": {}
  143. }
  144. header = {}
  145. def localProxy(self,param):
  146. action = {
  147. 'url':'',
  148. 'header':'',
  149. 'param':'',
  150. 'type':'string',
  151. 'after':''
  152. }
  153. return [200, "video/MP2T", action, ""]