央视综合.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. "中国缘":"TOPC1571646819318596",
  23. "见证":"TOPC1451542933238628",
  24. "我有传家宝":"TOPC1451525396109388",
  25. "天下财经":"TOPC1451531385787654",
  26. "正点财经":"TOPC1453100395512779",
  27. "收藏传奇":"TOPC1451526640730841",
  28. "分秒必争":"TOPC1451379074008632",
  29. "记住乡愁第八季":"TOPC1640330887412898",
  30. "动画城":"TOPC1451542209144770",
  31. "动漫世界":"TOPC1451559448233349",
  32. "周末动画片":"TOPC1451559836238828",
  33. "快乐驿站":"TOPC1451542273075862",
  34. "动画城":"TOPC1451542209144770",
  35. "动漫星空":"TOPC1451559936284927",
  36. "动画剧场":"TOPC1451559414465320",
  37. "走遍中国":"TOPC1451542134053698",
  38. "生活提示":"TOPC1451526037568184",
  39. "人口":"TOPC1451466072378425",
  40. "生活圈":"TOPC1451546588784893",
  41. "是真的吗":"TOPC1451534366388377",
  42. "生活家":"TOPC1593419181674791",
  43. "远方的家":"TOPC1451541349400938",
  44. "美食中国":"TOPC1571034804976375",
  45. "味道":"TOPC1482483166133803",
  46. "生活早参考":"TOPC1451525302140236",
  47. "走遍中国":"TOPC1451542134053698"
  48. }
  49. classes = []
  50. for k in cateManual:
  51. classes.append({
  52. 'type_name':k,
  53. 'type_id':cateManual[k]
  54. })
  55. result['class'] = classes
  56. if(filter):
  57. result['filters'] = self.config['filter']
  58. return result
  59. def homeVideoContent(self):
  60. result = {
  61. 'list':[]
  62. }
  63. return result
  64. def categoryContent(self,tid,pg,filter,extend):
  65. result = {}
  66. extend['id'] = tid
  67. extend['p'] = pg
  68. filterParams = ["id", "p", "d"]
  69. params = ["", "", ""]
  70. for idx in range(len(filterParams)):
  71. fp = filterParams[idx]
  72. if fp in extend.keys():
  73. params[idx] = '{0}={1}'.format(filterParams[idx],extend[fp])
  74. suffix = '&'.join(params)
  75. url = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  76. if not tid.startswith('TOPC'):
  77. url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  78. rsp = self.fetch(url,headers=self.header)
  79. jo = json.loads(rsp.text)
  80. vodList = jo['data']['list']
  81. videos = []
  82. for vod in vodList:
  83. guid = vod['guid']
  84. title = vod['title']
  85. img = vod['image']
  86. brief = vod['brief']
  87. videos.append({
  88. "vod_id":guid+"###"+img,
  89. "vod_name":title,
  90. "vod_pic":img,
  91. "vod_remarks":''
  92. })
  93. result['list'] = videos
  94. result['page'] = pg
  95. result['pagecount'] = 9999
  96. result['limit'] = 90
  97. result['total'] = 999999
  98. return result
  99. def detailContent(self,array):
  100. aid = array[0].split('###')
  101. tid = aid[0]
  102. url = "https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}".format(tid)
  103. rsp = self.fetch(url,headers=self.header)
  104. jo = json.loads(rsp.text)
  105. title = jo['title'].strip()
  106. link = jo['hls_url'].strip()
  107. vod = {
  108. "vod_id":tid,
  109. "vod_name":title,
  110. "vod_pic":aid[1],
  111. "type_name":'',
  112. "vod_year":"",
  113. "vod_area":"",
  114. "vod_remarks":"",
  115. "vod_actor":"",
  116. "vod_director":"",
  117. "vod_content":""
  118. }
  119. vod['vod_play_from'] = 'CCTV'
  120. vod['vod_play_url'] = title+"$"+link
  121. result = {
  122. 'list':[
  123. vod
  124. ]
  125. }
  126. return result
  127. def searchContent(self,key,quick):
  128. result = {
  129. 'list':[]
  130. }
  131. return result
  132. def playerContent(self,flag,id,vipFlags):
  133. result = {}
  134. rsp = self.fetch(id,headers=self.header)
  135. content = rsp.text.strip()
  136. arr = content.split('\n')
  137. urlPrefix = self.regStr(id,'(http[s]?://[a-zA-z0-9.]+)/')
  138. url = urlPrefix + arr[-1]
  139. result["parse"] = 0
  140. result["playUrl"] = ''
  141. result["url"] = url
  142. result["header"] = ''
  143. return result
  144. config = {
  145. "player": {},
  146. "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"}]}]}
  147. }
  148. header = {
  149. "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"
  150. }
  151. def localProxy(self,param):
  152. return [200, "video/MP2T", action, ""]