央视体育.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 time
  8. import base64
  9. class Spider(Spider): # 元类 默认的元类 type
  10. def getName(self):
  11. return "央视体育"
  12. def init(self,extend=""):
  13. print("============{0}============".format(extend))
  14. pass
  15. def isVideoFormat(self,url):
  16. pass
  17. def manualVideoCheck(self):
  18. pass
  19. def homeContent(self,filter):
  20. result = {}
  21. cateManual = {
  22. "运动大不同":"TOPC1451552002869953",
  23. "天下足球":"TOPC1451551777876756",
  24. "篮球公园":"TOPC1451549958391444",
  25. "体育新闻":"TOPC1451551426170389",
  26. "足球之夜":"TOPC1451552481492403",
  27. "北京2022":"TOPC1462860742367700",
  28. "体坛快讯":"TOPC1451550970356385",
  29. "体育世界":"TOPC1451551371554333",
  30. "欧冠开场哨":"TOPC1451550484638864",
  31. "棋牌乐":"TOPC1451550531682936",
  32. "健身动起来":"TOPC1451549599140203",
  33. "体育晨报":"TOPC1451551258388672",
  34. "体谈":"TOPC1451551830518827",
  35. "ATP周刊":"TOPC1551324792732798",
  36. "冰球冰球":"TOPC1551323337921620",
  37. "冰天雪地":"TOPC1551323403033398",
  38. "约战果岭":"TOPC1551324843068553",
  39. "艺术里的奥林匹克":"TOPC1634807797280923",
  40. "逐冰追雪":"TOPC1634807873035403",
  41. "五环纪事":"TOPC1634807936107991",
  42. "奥秘无穷":"TOPC1634808174904190",
  43. "奥林匹克人":"TOPC1634808300961576",
  44. "体育在线":"TOPC1451540777295250",
  45. "运动大不同":"TOPC1451552002869953",
  46. "NBA最前线":"TOPC1451548615930237",
  47. "冠军欧洲":"TOPC1451549411228903",
  48. "巅峰时刻":"TOPC1451549547540149",
  49. "赛车时代":"TOPC1451550589995997",
  50. "体育人间":"TOPC1451551310742737",
  51. "武林大会":"TOPC1451551891055866",
  52. "谁是球王":"TOPC1451550868295303"
  53. }
  54. classes = []
  55. for k in cateManual:
  56. classes.append({
  57. 'type_name':k,
  58. 'type_id':cateManual[k]
  59. })
  60. result['class'] = classes
  61. if(filter):
  62. result['filters'] = self.config['filter']
  63. return result
  64. def homeVideoContent(self):
  65. result = {
  66. 'list':[]
  67. }
  68. return result
  69. def categoryContent(self,tid,pg,filter,extend):
  70. result = {}
  71. extend['id'] = tid
  72. extend['p'] = pg
  73. filterParams = ["id", "p", "d"]
  74. params = ["", "", ""]
  75. for idx in range(len(filterParams)):
  76. fp = filterParams[idx]
  77. if fp in extend.keys():
  78. params[idx] = '{0}={1}'.format(filterParams[idx],extend[fp])
  79. suffix = '&'.join(params)
  80. url = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  81. if not tid.startswith('TOPC'):
  82. url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  83. rsp = self.fetch(url,headers=self.header)
  84. jo = json.loads(rsp.text)
  85. vodList = jo['data']['list']
  86. videos = []
  87. for vod in vodList:
  88. guid = vod['guid']
  89. title = vod['title']
  90. img = vod['image']
  91. brief = vod['brief']
  92. videos.append({
  93. "vod_id":guid+"###"+img,
  94. "vod_name":title,
  95. "vod_pic":img,
  96. "vod_remarks":''
  97. })
  98. result['list'] = videos
  99. result['page'] = pg
  100. result['pagecount'] = 9999
  101. result['limit'] = 90
  102. result['total'] = 999999
  103. return result
  104. def detailContent(self,array):
  105. aid = array[0].split('###')
  106. tid = aid[0]
  107. url = "https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}".format(tid)
  108. rsp = self.fetch(url,headers=self.header)
  109. jo = json.loads(rsp.text)
  110. title = jo['title'].strip()
  111. link = jo['hls_url'].strip()
  112. vod = {
  113. "vod_id":tid,
  114. "vod_name":title,
  115. "vod_pic":aid[1],
  116. "type_name":'',
  117. "vod_year":"",
  118. "vod_area":"",
  119. "vod_remarks":"",
  120. "vod_actor":"",
  121. "vod_director":"",
  122. "vod_content":""
  123. }
  124. vod['vod_play_from'] = 'CCTV'
  125. vod['vod_play_url'] = title+"$"+link
  126. result = {
  127. 'list':[
  128. vod
  129. ]
  130. }
  131. return result
  132. def searchContent(self,key,quick):
  133. result = {
  134. 'list':[]
  135. }
  136. return result
  137. def playerContent(self,flag,id,vipFlags):
  138. result = {}
  139. rsp = self.fetch(id,headers=self.header)
  140. content = rsp.text.strip()
  141. arr = content.split('\n')
  142. urlPrefix = self.regStr(id,'(http[s]?://[a-zA-z0-9.]+)/')
  143. url = urlPrefix + arr[-1]
  144. result["parse"] = 0
  145. result["playUrl"] = ''
  146. result["url"] = url
  147. result["header"] = ''
  148. return result
  149. config = {
  150. "player": {},
  151. "filter": {"TOPC1451557970755294": [{"key": "d", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"}, {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"}, {"n": "2009", "v": "2009"}]}]}
  152. }
  153. header = {
  154. "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.54 Safari/537.36"
  155. }
  156. def localProxy(self,param):
  157. return [200, "video/MP2T", action, ""]