央视综艺.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. "中华情":"TOPC1451541564922207",
  23. "回声嘹亮":"TOPC1451535575561597",
  24. "你好生活第三季":"TOPC1627961377879898",
  25. "我的艺术清单":"TOPC1582272259917160",
  26. "黄金100秒":"TOPC1451468496522494",
  27. "非常6+1":"TOPC1451467940101208",
  28. "向幸福出发":"TOPC1451984638791216",
  29. "幸福账单":"TOPC1451984801613379",
  30. "中国文艺报道":"TOPC1601348042760302",
  31. "舞蹈世界":"TOPC1451547605511387",
  32. "艺览天下":"TOPC1451984851125433",
  33. "天天把歌唱":"TOPC1451535663610626",
  34. "金牌喜剧班":"TOPC1611826337610628",
  35. "环球综艺秀":"TOPC1571300682556971",
  36. "挑战不可能第五季":"TOPC1579169060379297",
  37. "我们有一套":"TOPC1451527089955940",
  38. "为了你":"TOPC1451527001597710",
  39. "朗读者第一季":"TOPC1487120479377477",
  40. "挑战不可能第二季":"TOPC1474277421637816",
  41. "精彩一刻":"TOPC1451464786232149",
  42. "挑战不可能之加油中国":"TOPC1547519813971570",
  43. "挑战不可能第一季":"TOPC1452063816677656",
  44. "机智过人第三季":"TOPC1564019920570762",
  45. "经典咏流传第二季":"TOPC1547521714115947",
  46. "挑战不可能第三季":"TOPC1509500865106312",
  47. "经典咏流传第一季":"TOPC1513676755770201",
  48. "欢乐中国人第二季":"TOPC1516784350726581",
  49. "故事里的中国第一季":"TOPC1569729252342702",
  50. "你好生活第二季":"TOPC1604397385056621",
  51. "喜上加喜":"TOPC1590026042145705",
  52. "走在回家的路上":"TOPC1577697653272281",
  53. "综艺盛典":"TOPC1451985071887935",
  54. "艺术人生":"TOPC1451984891490556",
  55. "全家好拍档":"TOPC1474275463547690",
  56. "大魔术师":"TOPC1451984047073332",
  57. "欢乐一家亲":"TOPC1451984214170587",
  58. "开心辞典":"TOPC1451984378754815",
  59. "综艺星天地":"TOPC1451985188986150",
  60. "激情广场":"TOPC1451984341218765",
  61. "笑星大联盟":"TOPC1451984731428297",
  62. "天天乐":"TOPC1451984447718918",
  63. "欢乐英雄":"TOPC1451984242834620",
  64. "欢乐中国行":"TOPC1451984301286720",
  65. "我爱满堂彩":"TOPC1451538709371329",
  66. "综艺头条":"TOPC1569226855085860",
  67. "中华情":"TOPC1451541564922207",
  68. "魔法奇迹":"TOPC1451542029126607"
  69. }
  70. classes = []
  71. for k in cateManual:
  72. classes.append({
  73. 'type_name':k,
  74. 'type_id':cateManual[k]
  75. })
  76. result['class'] = classes
  77. if(filter):
  78. result['filters'] = self.config['filter']
  79. return result
  80. def homeVideoContent(self):
  81. result = {
  82. 'list':[]
  83. }
  84. return result
  85. def categoryContent(self,tid,pg,filter,extend):
  86. result = {}
  87. extend['id'] = tid
  88. extend['p'] = pg
  89. filterParams = ["id", "p", "d"]
  90. params = ["", "", ""]
  91. for idx in range(len(filterParams)):
  92. fp = filterParams[idx]
  93. if fp in extend.keys():
  94. params[idx] = '{0}={1}'.format(filterParams[idx],extend[fp])
  95. suffix = '&'.join(params)
  96. url = 'https://api.cntv.cn/NewVideo/getVideoListByColumn?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  97. if not tid.startswith('TOPC'):
  98. url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?{0}&n=20&sort=desc&mode=0&serviceId=tvcctv&t=json'.format(suffix)
  99. rsp = self.fetch(url,headers=self.header)
  100. jo = json.loads(rsp.text)
  101. vodList = jo['data']['list']
  102. videos = []
  103. for vod in vodList:
  104. guid = vod['guid']
  105. title = vod['title']
  106. img = vod['image']
  107. brief = vod['brief']
  108. videos.append({
  109. "vod_id":guid+"###"+img,
  110. "vod_name":title,
  111. "vod_pic":img,
  112. "vod_remarks":''
  113. })
  114. result['list'] = videos
  115. result['page'] = pg
  116. result['pagecount'] = 9999
  117. result['limit'] = 90
  118. result['total'] = 999999
  119. return result
  120. def detailContent(self,array):
  121. aid = array[0].split('###')
  122. tid = aid[0]
  123. url = "https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}".format(tid)
  124. rsp = self.fetch(url,headers=self.header)
  125. jo = json.loads(rsp.text)
  126. title = jo['title'].strip()
  127. link = jo['hls_url'].strip()
  128. vod = {
  129. "vod_id":tid,
  130. "vod_name":title,
  131. "vod_pic":aid[1],
  132. "type_name":'',
  133. "vod_year":"",
  134. "vod_area":"",
  135. "vod_remarks":"",
  136. "vod_actor":"",
  137. "vod_director":"",
  138. "vod_content":""
  139. }
  140. vod['vod_play_from'] = 'CCTV'
  141. vod['vod_play_url'] = title+"$"+link
  142. result = {
  143. 'list':[
  144. vod
  145. ]
  146. }
  147. return result
  148. def searchContent(self,key,quick):
  149. result = {
  150. 'list':[]
  151. }
  152. return result
  153. def playerContent(self,flag,id,vipFlags):
  154. result = {}
  155. rsp = self.fetch(id,headers=self.header)
  156. content = rsp.text.strip()
  157. arr = content.split('\n')
  158. urlPrefix = self.regStr(id,'(http[s]?://[a-zA-z0-9.]+)/')
  159. url = urlPrefix + arr[-1]
  160. result["parse"] = 0
  161. result["playUrl"] = ''
  162. result["url"] = url
  163. result["header"] = ''
  164. return result
  165. config = {
  166. "player": {},
  167. "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"}]}]}
  168. }
  169. header = {
  170. "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"
  171. }
  172. def localProxy(self,param):
  173. return [200, "video/MP2T", action, ""]