cntv央视_test.py 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961
  1. # coding=utf-8
  2. # !/usr/bin/python
  3. import os.path
  4. import sys
  5. sys.path.append('..')
  6. try:
  7. # from base.spider import Spider as BaseSpider
  8. from base.spider import BaseSpider
  9. except ImportError:
  10. from t4.base.spider import BaseSpider
  11. import json
  12. import time
  13. import base64
  14. import datetime
  15. import re
  16. from urllib import request, parse
  17. from pathlib import Path
  18. import urllib
  19. import urllib.request
  20. """
  21. 配置示例:
  22. t4的配置里ext节点会自动变成api对应query参数extend,但t4的ext字符串不支持路径格式,比如./开头或者.json结尾
  23. api里会自动含有ext参数是base64编码后的选中的筛选条件
  24. 错误示例,ext含有json:
  25. {
  26. "key":"hipy_cntv央视",
  27. "name":"cntv央视(hipy_t4)",
  28. "type":4,
  29. "api":"http://192.168.31.49:5707/api/v1/vod/cntv央视?api_ext={{host}}/txt/hipy/cntv央视.json",
  30. "searchable":1,
  31. "quickSearch":1,
  32. "filterable":0,
  33. "ext":"cntv央视.json"
  34. }
  35. 正确示例。同时存在ext和api_ext会优先取ext作为extend加载init
  36. {
  37. "key":"hipy_t4_cntv央视",
  38. "name":"cntv央视(hipy_t4)",
  39. "type":4,
  40. "api":"http://192.168.31.49:5707/api/v1/vod/cntv央视?api_ext={{host}}/txt/hipy/cntv央视.json",
  41. "searchable":1,
  42. "quickSearch":0,
  43. "filterable":1,
  44. "ext":"cntv央视"
  45. },
  46. {
  47. "key": "hipy_t3_cntv央视",
  48. "name": "cntv央视(hipy_t3)",
  49. "type": 3,
  50. "api": "{{host}}/txt/hipy/cntv央视.py",
  51. "searchable": 1,
  52. "quickSearch": 0,
  53. "filterable": 1,
  54. "ext": "{{host}}/txt/hipy/cntv央视.json"
  55. },
  56. """
  57. class Spider(BaseSpider): # 元类 默认的元类 type
  58. module = None
  59. def getDependence(self):
  60. return ['base_spider']
  61. def getName(self):
  62. return "中央电视台" # 可搜索
  63. def init_api_ext_file(self):
  64. ext_file = __file__.replace('.py', '.json')
  65. print(f'ext_file:{ext_file}')
  66. # 特别节目网页: https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65
  67. # 特别节目分类筛选获取页面: https://tv.cctv.com/yxg/tbjm/index.shtml
  68. # 纪录片网页: https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65
  69. # 纪录片分类筛选获取页面:https://tv.cctv.com/yxg/jlp/index.shtml
  70. # ==================== 获取特别节目的筛选条件 ======================
  71. r = self.fetch('https://tv.cctv.com/yxg/tbjm/index.shtml')
  72. html = r.text
  73. html = self.html(html)
  74. filter_tbjm = []
  75. lis = html.xpath('//*[@id="pindao"]/li')
  76. li_value = []
  77. for li in lis:
  78. li_value.append({
  79. 'n': ''.join(li.xpath('./span//text()')),
  80. 'v': ''.join(li.xpath('@datacd')),
  81. })
  82. # print(li_value)
  83. filter_tbjm.append({
  84. "key": "datapd-channel",
  85. "name": "频道",
  86. "value": li_value
  87. })
  88. lis = html.xpath('//*[@id="fenlei"]/li')
  89. li_value = []
  90. for li in lis:
  91. li_value.append({
  92. 'n': ''.join(li.xpath('./span//text()')),
  93. 'v': ''.join(li.xpath('@datalx')),
  94. })
  95. # print(li_value)
  96. filter_tbjm.append({
  97. "key": "datafl-sc",
  98. "name": "类型",
  99. "value": li_value
  100. })
  101. lis = html.xpath('//*[@id="zimu"]/li')
  102. li_value = []
  103. for li in lis:
  104. li_value.append({
  105. 'n': ''.join(li.xpath('./span//text()')),
  106. 'v': ''.join(li.xpath('@datazm')),
  107. })
  108. # print(li_value)
  109. filter_tbjm.append({
  110. "key": "dataszm-letter",
  111. "name": "首字母",
  112. "value": li_value
  113. })
  114. print(filter_tbjm)
  115. # ==================== 纪录片筛选获取 ======================
  116. r = self.fetch('https://tv.cctv.com/yxg/jlp/index.shtml')
  117. html = r.text
  118. html = self.html(html)
  119. filter_jlp = []
  120. lis = html.xpath('//*[@id="pindao"]/li')
  121. li_value = []
  122. for li in lis:
  123. li_value.append({
  124. 'n': ''.join(li.xpath('./span//text()')),
  125. 'v': ''.join(li.xpath('@datacd')),
  126. })
  127. # print(li_value)
  128. filter_jlp.append({
  129. "key": "datapd-channel",
  130. "name": "频道",
  131. "value": li_value
  132. })
  133. lis = html.xpath('//*[@id="fenlei"]/li')
  134. li_value = []
  135. for li in lis:
  136. li_value.append({
  137. 'n': ''.join(li.xpath('./span//text()')),
  138. 'v': ''.join(li.xpath('@datalx')),
  139. })
  140. # print(li_value)
  141. filter_jlp.append({
  142. "key": "datafl-sc",
  143. "name": "类型",
  144. "value": li_value
  145. })
  146. lis = html.xpath('//*[@id="nianfen"]/li')
  147. li_value = []
  148. for li in lis:
  149. li_value.append({
  150. 'n': ''.join(li.xpath('./span//text()')),
  151. 'v': ''.join(li.xpath('@datanf')),
  152. })
  153. # print(li_value)
  154. filter_jlp.append({
  155. "key": "datanf-year",
  156. "name": "年份",
  157. "value": li_value
  158. })
  159. lis = html.xpath('//*[@id="zimu"]/li')
  160. li_value = []
  161. for li in lis:
  162. li_value.append({
  163. 'n': ''.join(li.xpath('./span//text()')),
  164. 'v': ''.join(li.xpath('@datazm')),
  165. })
  166. # print(li_value)
  167. filter_jlp.append({
  168. "key": "dataszm-letter",
  169. "name": "首字母",
  170. "value": li_value
  171. })
  172. print(filter_jlp)
  173. ext_file_dict = {
  174. "特别节目": filter_tbjm,
  175. "纪录片": filter_jlp,
  176. }
  177. # print(json.dumps(ext_file_dict,ensure_ascii=False,indent=4))
  178. with open(ext_file, mode='w+', encoding='utf-8') as f:
  179. # f.write(json.dumps(ext_file_dict,ensure_ascii=False,indent=4))
  180. f.write(json.dumps(ext_file_dict, ensure_ascii=False))
  181. def init(self, extend=""):
  182. def init_file(ext_file):
  183. ext_file = Path(ext_file).as_posix()
  184. # print(f'ext_file:{ext_file}')
  185. if os.path.exists(ext_file):
  186. # print('存在扩展文件')
  187. with open(ext_file, mode='r', encoding='utf-8') as f:
  188. try:
  189. ext_dict = json.loads(f.read())
  190. # print(ext_dict)
  191. self.config['filter'].update(ext_dict)
  192. except Exception as e:
  193. print(f'更新扩展筛选条件发生错误:{e}')
  194. print("============依赖列表:{0}============".format(extend))
  195. ext = self.extend
  196. print("============ext:{0}============".format(ext))
  197. if isinstance(ext, str) and ext:
  198. if ext.startswith('./'):
  199. ext_file = os.path.join(os.path.dirname(__file__), ext)
  200. init_file(ext_file)
  201. elif ext.startswith('http'):
  202. try:
  203. r = self.fetch(ext)
  204. self.config['filter'].update(r.json())
  205. except Exception as e:
  206. print(f'更新扩展筛选条件发生错误:{e}')
  207. elif not ext.startswith('./') and not ext.startswith('http'):
  208. ext_file = os.path.join(os.path.dirname(__file__), './' + ext + '.json')
  209. init_file(ext_file)
  210. # ==================== 栏目大全加载年月筛选 ======================
  211. lanmu_list = self.config['filter']['栏目大全']
  212. lanmu_keys_list = [lanmu['key'] for lanmu in lanmu_list]
  213. if 'year' not in lanmu_keys_list:
  214. currentYear = datetime.date.today().year
  215. yearList = [{"n": "全部", "v": ""}]
  216. for year in range(currentYear, currentYear - 10, -1):
  217. yearList.append({"n": year, "v": year})
  218. yearDict = {"key": "year", "name": "年份", "value": yearList}
  219. lanmu_list.append(yearDict)
  220. if 'month' not in lanmu_keys_list:
  221. monthList = [{"n": "全部", "v": ""}]
  222. for month in range(1, 13):
  223. text = str(month).rjust(2, '0')
  224. monthList.append({"n": text, "v": text})
  225. monthDict = {"key": "month", "name": "月份", "value": monthList}
  226. lanmu_list.append(monthDict)
  227. # 装载模块,这里只要一个就够了
  228. if isinstance(extend, list):
  229. for lib in extend:
  230. if '.Spider' in str(type(lib)):
  231. self.module = lib
  232. break
  233. def isVideoFormat(self, url):
  234. pass
  235. def manualVideoCheck(self):
  236. pass
  237. def homeContent(self, filter):
  238. result = {}
  239. cateManual = {
  240. "4K专区": "4K专区",
  241. "栏目大全": "栏目大全",
  242. "特别节目": "特别节目",
  243. "纪录片": "纪录片",
  244. "电视剧": "电视剧",
  245. "动画片": "动画片"
  246. }
  247. classes = []
  248. for k in cateManual:
  249. classes.append({
  250. 'type_name': k,
  251. 'type_id': cateManual[k]
  252. })
  253. result['class'] = classes
  254. if (filter):
  255. result['filters'] = self.config['filter']
  256. return result
  257. def homeVideoContent(self):
  258. result = {
  259. 'list': []
  260. }
  261. if self.module:
  262. result = self.module.homeVideoContent()
  263. return result
  264. def categoryContent(self, tid, pg, filter, extend):
  265. result = {}
  266. month = "" # 月
  267. year = "" # 年
  268. area = '' # 地区
  269. channel = '' # 频道
  270. datafl = '' # 类型
  271. letter = '' # 字母
  272. year_prefix = '' # 栏目大全的年月筛选过滤
  273. pagecount = 24
  274. if tid == '动画片':
  275. id = urllib.parse.quote(tid)
  276. if 'datadq-area' in extend.keys():
  277. area = urllib.parse.quote(extend['datadq-area'])
  278. if 'dataszm-letter' in extend.keys():
  279. letter = extend['dataszm-letter']
  280. if 'datafl-sc' in extend.keys():
  281. datafl = urllib.parse.quote(extend['datafl-sc'])
  282. url = 'https://api.cntv.cn/list/getVideoAlbumList?channelid=CHAL1460955899450127&area={0}&sc={4}&fc={1}&letter={2}&p={3}&n=24&serviceId=tvcctv&topv=1&t=json'.format(
  283. area, id, letter, pg, datafl)
  284. elif tid == '纪录片':
  285. id = urllib.parse.quote(tid)
  286. if 'datapd-channel' in extend.keys():
  287. channel = urllib.parse.quote(extend['datapd-channel'])
  288. if 'datafl-sc' in extend.keys():
  289. datafl = urllib.parse.quote(extend['datafl-sc'])
  290. if 'datanf-year' in extend.keys():
  291. year = extend['datanf-year']
  292. if 'dataszm-letter' in extend.keys():
  293. letter = extend['dataszm-letter']
  294. url = 'https://api.cntv.cn/list/getVideoAlbumList?channelid=CHAL1460955924871139&fc={0}&channel={1}&sc={2}&year={3}&letter={4}&p={5}&n=24&serviceId=tvcctv&topv=1&t=json'.format(
  295. id, channel, datafl, year, letter, pg)
  296. elif tid == '电视剧':
  297. id = urllib.parse.quote(tid)
  298. if 'datafl-sc' in extend.keys():
  299. datafl = urllib.parse.quote(extend['datafl-sc'])
  300. if 'datanf-year' in extend.keys():
  301. year = extend['datanf-year']
  302. if 'dataszm-letter' in extend.keys():
  303. letter = extend['dataszm-letter']
  304. url = 'https://api.cntv.cn/list/getVideoAlbumList?channelid=CHAL1460955853485115&area={0}&sc={1}&fc={2}&year={3}&letter={4}&p={5}&n=24&serviceId=tvcctv&topv=1&t=json'.format(
  305. area, datafl, id, year, letter, pg)
  306. elif tid == '特别节目':
  307. id = urllib.parse.quote(tid)
  308. if 'datapd-channel' in extend.keys():
  309. channel = urllib.parse.quote(extend['datapd-channel'])
  310. if 'datafl-sc' in extend.keys():
  311. datafl = urllib.parse.quote(extend['datafl-sc'])
  312. if 'dataszm-letter' in extend.keys():
  313. letter = extend['dataszm-letter']
  314. url = 'https://api.cntv.cn/list/getVideoAlbumList?channelid=CHAL1460955953877151&channel={0}&sc={1}&fc={2}&bigday=&letter={3}&p={4}&n=24&serviceId=tvcctv&topv=1&t=json'.format(
  315. channel, datafl, id, letter, pg)
  316. elif tid == '栏目大全':
  317. cid = '' # 频道
  318. if 'cid' in extend.keys():
  319. cid = extend['cid']
  320. fc = '' # 分类
  321. if 'fc' in extend.keys():
  322. fc = extend['fc']
  323. fl = '' # 字母
  324. if 'fl' in extend.keys():
  325. fl = extend['fl']
  326. year = extend.get('year') or ''
  327. month = extend.get('month') or ''
  328. if year:
  329. year_prefix = year + month
  330. url = 'https://api.cntv.cn/lanmu/columnSearch?&fl={0}&fc={1}&cid={2}&p={3}&n=20&serviceId=tvcctv&t=json&cb=ko'.format(
  331. fl, fc, cid, pg)
  332. pagecount = 20
  333. elif tid == '4K专区':
  334. cid = 'CHAL1558416868484111'
  335. url = 'https://api.cntv.cn/NewVideo/getLastVideoList4K?serviceId=cctv4k&cid={0}&p={1}&n={2}&t=json&cb=ko'.format(
  336. cid, pg, pagecount
  337. )
  338. else:
  339. url = 'https://tv.cctv.com/epg/index.shtml'
  340. videos = []
  341. htmlText = self.fetch(url).text
  342. if tid == '栏目大全':
  343. index = htmlText.rfind(');')
  344. if index > -1:
  345. htmlText = htmlText[3:index]
  346. videos = self.get_list1(html=htmlText, tid=tid, year_prefix=year_prefix)
  347. elif tid == '4K专区':
  348. index = htmlText.rfind(');')
  349. if index > -1:
  350. htmlText = htmlText[3:index]
  351. videos = self.get_list_4k(html=htmlText, tid=tid)
  352. else:
  353. videos = self.get_list(html=htmlText, tid=tid)
  354. # print(videos)
  355. result['list'] = videos
  356. result['page'] = pg
  357. result['pagecount'] = 9999 if len(videos) >= pagecount else pg
  358. result['limit'] = 90
  359. result['total'] = 999999
  360. return result
  361. def detailContent(self, array):
  362. result = {}
  363. year_prefix = ''
  364. did = array[0]
  365. if '$$$' in did:
  366. year_prefix = did.split('$$$')[0]
  367. did = did.split('$$$')[1]
  368. aid = did.split('||')
  369. tid = aid[0]
  370. logo = aid[3]
  371. lastVideo = aid[2]
  372. title = aid[1]
  373. id = aid[4]
  374. vod_year = aid[5]
  375. actors = aid[6] if len(aid) > 6 else ''
  376. brief = aid[7] if len(aid) > 7 else '' # get请求最长255,这个描述会有可能直接被干没了。
  377. fromId = 'CCTV'
  378. if tid == "栏目大全":
  379. lastUrl = 'https://api.cntv.cn/video/videoinfoByGuid?guid={0}&serviceId=tvcctv'.format(id)
  380. # htmlTxt = self.webReadFile(urlStr=lastUrl, header=self.header)
  381. htmlTxt = self.fetch(lastUrl).text
  382. topicId = json.loads(htmlTxt)['ctid']
  383. url = 'https://api.cntv.cn/NewVideo/getVideoListByColumn'
  384. # params = {
  385. # 'p': '1',
  386. # 'n': '100',
  387. # 't': 'json',
  388. # 'mode': '0',
  389. # 'sort': 'desc',
  390. # 'serviceId': 'tvcctv',
  391. # 'd': year_prefix,
  392. # 'id': topicId
  393. # }
  394. # htmlTxt = self.fetch(url,data=params).text
  395. Url = "{0}?id={1}&d=&p=1&n=100&sort=desc&mode=0&serviceId=tvcctv&t=json&d={2}".format(
  396. url, topicId, year_prefix)
  397. elif tid == "4K专区":
  398. Url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?id={0}&serviceId=cctv4k&p=1&n=100&mode=0&pub=1'.format(
  399. id)
  400. print(Url)
  401. else:
  402. Url = 'https://api.cntv.cn/NewVideo/getVideoListByAlbumIdNew?id={0}&serviceId=tvcctv&p=1&n=100&mode=0&pub=1'.format(
  403. id)
  404. jRoot = ''
  405. videoList = []
  406. try:
  407. if tid == "搜索":
  408. fromId = '中央台'
  409. videoList = [title + "$" + lastVideo]
  410. else:
  411. # htmlTxt = self.webReadFile(urlStr=Url, header=self.header)
  412. htmlTxt = self.fetch(Url).text
  413. jRoot = json.loads(htmlTxt)
  414. data = jRoot['data']
  415. jsonList = data['list']
  416. videoList = self.get_EpisodesList(jsonList=jsonList)
  417. if len(videoList) < 1:
  418. # htmlTxt = self.webReadFile(urlStr=lastVideo, header=self.header)
  419. htmlTxt = self.fetch(lastVideo).text
  420. if tid == "电视剧" or tid == "纪录片" or tid == "4K专区":
  421. patternTxt = r"'title':\s*'(?P<title>.+?)',\n{0,1}\s*'brief':\s*'(.+?)',\n{0,1}\s*'img':\s*'(.+?)',\n{0,1}\s*'url':\s*'(?P<url>.+?)'"
  422. elif tid == "特别节目":
  423. patternTxt = r'class="tp1"><a\s*href="(?P<url>https://.+?)"\s*target="_blank"\s*title="(?P<title>.+?)"></a></div>'
  424. elif tid == "动画片":
  425. patternTxt = r"'title':\s*'(?P<title>.+?)',\n{0,1}\s*'img':\s*'(.+?)',\n{0,1}\s*'brief':\s*'(.+?)',\n{0,1}\s*'url':\s*'(?P<url>.+?)'"
  426. elif tid == "栏目大全":
  427. patternTxt = r'href="(?P<url>.+?)" target="_blank" alt="(?P<title>.+?)" title=".+?">'
  428. videoList = self.get_EpisodesList_re(htmlTxt=htmlTxt, patternTxt=patternTxt)
  429. fromId = '央视'
  430. except:
  431. pass
  432. if len(videoList) == 0:
  433. return {}
  434. vod = {
  435. "vod_id": array[0],
  436. "vod_name": title.replace(' ', ''),
  437. "vod_pic": logo,
  438. "type_name": tid,
  439. "vod_year": vod_year,
  440. "vod_area": "",
  441. "vod_remarks": '',
  442. "vod_actor": actors,
  443. "vod_director": '',
  444. "vod_content": brief
  445. }
  446. vod['vod_play_from'] = fromId
  447. vod['vod_play_url'] = "#".join(videoList)
  448. result = {
  449. 'list': [
  450. vod
  451. ]
  452. }
  453. return result
  454. def get_lineList(self, Txt, mark, after):
  455. circuit = []
  456. origin = Txt.find(mark)
  457. while origin > 8:
  458. end = Txt.find(after, origin)
  459. circuit.append(Txt[origin:end])
  460. origin = Txt.find(mark, end)
  461. return circuit
  462. def get_RegexGetTextLine(self, Text, RegexText, Index):
  463. returnTxt = []
  464. pattern = re.compile(RegexText, re.M | re.S)
  465. ListRe = pattern.findall(Text)
  466. if len(ListRe) < 1:
  467. return returnTxt
  468. for value in ListRe:
  469. returnTxt.append(value)
  470. return returnTxt
  471. def searchContent(self, key, quick, pg=1):
  472. key = urllib.parse.quote(key)
  473. Url = 'https://search.cctv.com/ifsearch.php?page=1&qtext={0}&sort=relevance&pageSize=20&type=video&vtime=-1&datepid=1&channel=&pageflag=0&qtext_str={0}'.format(
  474. key)
  475. # htmlTxt = self.webReadFile(urlStr=Url, header=self.header)
  476. htmlTxt = self.fetch(Url).text
  477. videos = self.get_list_search(html=htmlTxt, tid='搜索')
  478. result = {
  479. 'list': videos
  480. }
  481. return result
  482. def playerContent(self, flag, id, vipFlags):
  483. result = {}
  484. url = ''
  485. parse = 0
  486. headers = {
  487. 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'
  488. }
  489. if flag == 'CCTV':
  490. url = self.get_m3u8(urlTxt=id)
  491. else:
  492. try:
  493. # htmlTxt = self.webReadFile(urlStr=id, header=self.header)
  494. htmlTxt = self.fetch(id).text
  495. guid = self.get_RegexGetText(Text=htmlTxt, RegexText=r'var\sguid\s*=\s*"(.+?)";', Index=1)
  496. url = self.get_m3u8(urlTxt=guid)
  497. except:
  498. url = id
  499. parse = 1
  500. if url.find('https:') < 0:
  501. url = id
  502. parse = 1
  503. result["parse"] = parse # 1=嗅探,0=播放
  504. result["playUrl"] = ''
  505. result["url"] = url
  506. result["header"] = headers
  507. return result
  508. # 分类抓取地址:
  509. # 栏目大全:https://tv.cctv.com/lm/index.shtml?spm=C28340.Pu9TN9YUsfNZ.E2PQtIunpEaz.24
  510. # 电视剧:https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65#datacid=dsj&datafl=&datadq=&fc=%E7%94%B5%E8%A7%86%E5%89%A7&datanf=&dataszm=
  511. # 动画片:https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65#datacid=dhp&datafl=&datadq=&fc=%E5%8A%A8%E7%94%BB%E7%89%87&dataszm=
  512. # 记录片:https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65#datacid=jlp&datapd=&datafl=&fc=%E7%BA%AA%E5%BD%95%E7%89%87&datanf=&dataszm=
  513. # 特别节目:https://tv.cctv.com/yxg/index.shtml?spm=C28340.PlFTqGe6Zk8M.E2PQtIunpEaz.65#datacid=tbjm&datapd=&datafl=&fc=%E7%89%B9%E5%88%AB%E8%8A%82%E7%9B%AE&datajr=&dataszm=
  514. config = {
  515. "player": {},
  516. "filter": {
  517. "电视剧": [
  518. {"key": "datafl-sc", "name": "类型",
  519. "value": [{"n": "全部", "v": ""}, {"n": "谍战", "v": "谍战"}, {"n": "悬疑", "v": "悬疑"},
  520. {"n": "刑侦", "v": "刑侦"}, {"n": "历史", "v": "历史"}, {"n": "古装", "v": "古装"},
  521. {"n": "武侠", "v": "武侠"}, {"n": "军旅", "v": "军旅"}, {"n": "战争", "v": "战争"},
  522. {"n": "喜剧", "v": "喜剧"}, {"n": "青春", "v": "青春"}, {"n": "言情", "v": "言情"},
  523. {"n": "偶像", "v": "偶像"}, {"n": "家庭", "v": "家庭"}, {"n": "年代", "v": "年代"},
  524. {"n": "革命", "v": "革命"}, {"n": "农村", "v": "农村"}, {"n": "都市", "v": "都市"},
  525. {"n": "其他", "v": "其他"}]},
  526. {"key": "datadq-area", "name": "地区",
  527. "value": [{"n": "全部", "v": ""}, {"n": "中国大陆", "v": "中国大陆"}, {"n": "中国香港", "v": "香港"},
  528. {"n": "美国", "v": "美国"}, {"n": "欧洲", "v": "欧洲"}, {"n": "泰国", "v": "泰国"}]},
  529. {"key": "datanf-year", "name": "年份",
  530. "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"},
  531. {"n": "2022", "v": "2022"},
  532. {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"},
  533. {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"},
  534. {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"},
  535. {"n": "2012", "v": "2012"}, {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"},
  536. {"n": "2009", "v": "2009"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"},
  537. {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"},
  538. {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"},
  539. {"n": "2000", "v": "2000"}, {"n": "1999", "v": "1999"}, {"n": "1998", "v": "1998"},
  540. {"n": "1997", "v": "1997"}]},
  541. {"key": "dataszm-letter", "name": "字母",
  542. "value": [{"n": "全部", "v": ""}, {"n": "A", "v": "A"}, {"n": "C", "v": "C"}, {"n": "E", "v": "E"},
  543. {"n": "F", "v": "F"}, {"n": "G", "v": "G"}, {"n": "H", "v": "H"}, {"n": "I", "v": "I"},
  544. {"n": "J", "v": "J"}, {"n": "K", "v": "K"}, {"n": "L", "v": "L"}, {"n": "M", "v": "M"},
  545. {"n": "N", "v": "N"}, {"n": "O", "v": "O"}, {"n": "P", "v": "P"}, {"n": "Q", "v": "Q"},
  546. {"n": "R", "v": "R"}, {"n": "S", "v": "S"}, {"n": "T", "v": "T"}, {"n": "U", "v": "U"},
  547. {"n": "V", "v": "V"}, {"n": "W", "v": "W"}, {"n": "X", "v": "X"}, {"n": "Y", "v": "Y"},
  548. {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
  549. ],
  550. "动画片": [
  551. {"key": "datafl-sc", "name": "类型",
  552. "value": [{"n": "全部", "v": ""}, {"n": "亲子", "v": "亲子"}, {"n": "搞笑", "v": "搞笑"},
  553. {"n": "冒险", "v": "冒险"}, {"n": "动作", "v": "动作"}, {"n": "宠物", "v": "宠物"},
  554. {"n": "体育", "v": "体育"}, {"n": "益智", "v": "益智"}, {"n": "历史", "v": "历史"},
  555. {"n": "教育", "v": "教育"}, {"n": "校园", "v": "校园"}, {"n": "言情", "v": "言情"},
  556. {"n": "武侠", "v": "武侠"}, {"n": "经典", "v": "经典"}, {"n": "未来", "v": "未来"},
  557. {"n": "古代", "v": "古代"}, {"n": "神话", "v": "神话"}, {"n": "真人", "v": "真人"},
  558. {"n": "励志", "v": "励志"}, {"n": "热血", "v": "热血"}, {"n": "奇幻", "v": "奇幻"},
  559. {"n": "童话", "v": "童话"}, {"n": "剧情", "v": "剧情"}, {"n": "夺宝", "v": "夺宝"},
  560. {"n": "其他", "v": "其他"}]},
  561. {"key": "datadq-area", "name": "地区",
  562. "value": [{"n": "全部", "v": ""}, {"n": "中国大陆", "v": "中国大陆"}, {"n": "美国", "v": "美国"},
  563. {"n": "欧洲", "v": "欧洲"}]},
  564. {"key": "dataszm-letter", "name": "字母",
  565. "value": [{"n": "全部", "v": ""}, {"n": "A", "v": "A"}, {"n": "C", "v": "C"}, {"n": "E", "v": "E"},
  566. {"n": "F", "v": "F"}, {"n": "G", "v": "G"}, {"n": "H", "v": "H"}, {"n": "I", "v": "I"},
  567. {"n": "J", "v": "J"}, {"n": "K", "v": "K"}, {"n": "L", "v": "L"}, {"n": "M", "v": "M"},
  568. {"n": "N", "v": "N"}, {"n": "O", "v": "O"}, {"n": "P", "v": "P"}, {"n": "Q", "v": "Q"},
  569. {"n": "R", "v": "R"}, {"n": "S", "v": "S"}, {"n": "T", "v": "T"}, {"n": "U", "v": "U"},
  570. {"n": "V", "v": "V"}, {"n": "W", "v": "W"}, {"n": "X", "v": "X"}, {"n": "Y", "v": "Y"},
  571. {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
  572. ],
  573. "纪录片": [
  574. {"key": "datafl-sc", "name": "类型",
  575. "value": [{"n": "全部", "v": ""}, {"n": "人文历史", "v": "人文历史"}, {"n": "人物", "v": "人物"},
  576. {"n": "军事", "v": "军事"}, {"n": "探索", "v": "探索"}, {"n": "社会", "v": "社会"},
  577. {"n": "时政", "v": "时政"}, {"n": "经济", "v": "经济"}, {"n": "科技", "v": "科技"}]},
  578. {"key": "datanf-year", "name": "年份",
  579. "value": [{"n": "全部", "v": ""}, {"n": "2024", "v": "2024"}, {"n": "2023", "v": "2023"},
  580. {"n": "2022", "v": "2022"},
  581. {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"},
  582. {"n": "2018", "v": "2018"}, {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"},
  583. {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"},
  584. {"n": "2012", "v": "2012"}, {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"},
  585. {"n": "2009", "v": "2009"}, {"n": "2008", "v": "2008"}]},
  586. {"key": "dataszm-letter", "name": "字母",
  587. "value": [{"n": "全部", "v": ""}, {"n": "A", "v": "A"}, {"n": "C", "v": "C"}, {"n": "E", "v": "E"},
  588. {"n": "F", "v": "F"}, {"n": "G", "v": "G"}, {"n": "H", "v": "H"}, {"n": "I", "v": "I"},
  589. {"n": "J", "v": "J"}, {"n": "K", "v": "K"}, {"n": "L", "v": "L"}, {"n": "M", "v": "M"},
  590. {"n": "N", "v": "N"}, {"n": "O", "v": "O"}, {"n": "P", "v": "P"}, {"n": "Q", "v": "Q"},
  591. {"n": "R", "v": "R"}, {"n": "S", "v": "S"}, {"n": "T", "v": "T"}, {"n": "U", "v": "U"},
  592. {"n": "V", "v": "V"}, {"n": "W", "v": "W"}, {"n": "X", "v": "X"}, {"n": "Y", "v": "Y"},
  593. {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
  594. ],
  595. "特别节目": [
  596. {"key": "datafl-sc", "name": "类型",
  597. "value": [{"n": "全部", "v": ""}, {"n": "全部", "v": "全部"}, {"n": "新闻", "v": "新闻"},
  598. {"n": "经济", "v": "经济"}, {"n": "综艺", "v": "综艺"}, {"n": "体育", "v": "体育"},
  599. {"n": "军事", "v": "军事"}, {"n": "影视", "v": "影视"}, {"n": "科教", "v": "科教"},
  600. {"n": "戏曲", "v": "戏曲"}, {"n": "青少", "v": "青少"}, {"n": "音乐", "v": "音乐"},
  601. {"n": "社会", "v": "社会"}, {"n": "公益", "v": "公益"}, {"n": "其他", "v": "其他"}]},
  602. {"key": "dataszm-letter", "name": "字母",
  603. "value": [{"n": "全部", "v": ""}, {"n": "A", "v": "A"}, {"n": "C", "v": "C"}, {"n": "E", "v": "E"},
  604. {"n": "F", "v": "F"}, {"n": "G", "v": "G"}, {"n": "H", "v": "H"}, {"n": "I", "v": "I"},
  605. {"n": "J", "v": "J"}, {"n": "K", "v": "K"}, {"n": "L", "v": "L"}, {"n": "M", "v": "M"},
  606. {"n": "N", "v": "N"}, {"n": "O", "v": "O"}, {"n": "P", "v": "P"}, {"n": "Q", "v": "Q"},
  607. {"n": "R", "v": "R"}, {"n": "S", "v": "S"}, {"n": "T", "v": "T"}, {"n": "U", "v": "U"},
  608. {"n": "V", "v": "V"}, {"n": "W", "v": "W"}, {"n": "X", "v": "X"}, {"n": "Y", "v": "Y"},
  609. {"n": "Z", "v": "Z"}, {"n": "0-9", "v": "0-9"}]}
  610. ],
  611. "栏目大全": [{"key": "cid", "name": "频道",
  612. "value": [{"n": "全部", "v": ""}, {"n": "CCTV-1综合", "v": "EPGC1386744804340101"},
  613. {"n": "CCTV-2财经", "v": "EPGC1386744804340102"},
  614. {"n": "CCTV-3综艺", "v": "EPGC1386744804340103"},
  615. {"n": "CCTV-4中文国际", "v": "EPGC1386744804340104"},
  616. {"n": "CCTV-5体育", "v": "EPGC1386744804340107"},
  617. {"n": "CCTV-6电影", "v": "EPGC1386744804340108"},
  618. {"n": "CCTV-7国防军事", "v": "EPGC1386744804340109"},
  619. {"n": "CCTV-8电视剧", "v": "EPGC1386744804340110"},
  620. {"n": "CCTV-9纪录", "v": "EPGC1386744804340112"},
  621. {"n": "CCTV-10科教", "v": "EPGC1386744804340113"},
  622. {"n": "CCTV-11戏曲", "v": "EPGC1386744804340114"},
  623. {"n": "CCTV-12社会与法", "v": "EPGC1386744804340115"},
  624. {"n": "CCTV-13新闻", "v": "EPGC1386744804340116"},
  625. {"n": "CCTV-14少儿", "v": "EPGC1386744804340117"},
  626. {"n": "CCTV-15音乐", "v": "EPGC1386744804340118"},
  627. {"n": "CCTV-16奥林匹克", "v": "EPGC1634630207058998"},
  628. {"n": "CCTV-17农业农村", "v": "EPGC1563932742616872"},
  629. {"n": "CCTV-5+体育赛事", "v": "EPGC1468294755566101"}]},
  630. {"key": "fc", "name": "分类",
  631. "value": [{"n": "全部", "v": ""}, {"n": "新闻", "v": "新闻"}, {"n": "体育", "v": "体育"},
  632. {"n": "综艺", "v": "综艺"}, {"n": "健康", "v": "健康"}, {"n": "生活", "v": "生活"},
  633. {"n": "科教", "v": "科教"}, {"n": "经济", "v": "经济"}, {"n": "农业", "v": "农业"},
  634. {"n": "法治", "v": "法治"}, {"n": "军事", "v": "军事"}, {"n": "少儿", "v": "少儿"},
  635. {"n": "动画", "v": "动画"}, {"n": "纪实", "v": "纪实"}, {"n": "戏曲", "v": "戏曲"},
  636. {"n": "音乐", "v": "音乐"}, {"n": "影视", "v": "影视"}]},
  637. {"key": "fl", "name": "字母",
  638. "value": [{"n": "全部", "v": ""}, {"n": "A", "v": "A"}, {"n": "B", "v": "B"},
  639. {"n": "C", "v": "C"}, {"n": "D", "v": "D"}, {"n": "E", "v": "E"},
  640. {"n": "F", "v": "F"}, {"n": "G", "v": "G"}, {"n": "H", "v": "H"},
  641. {"n": "I", "v": "I"}, {"n": "J", "v": "J"}, {"n": "K", "v": "K"},
  642. {"n": "L", "v": "L"}, {"n": "M", "v": "M"}, {"n": "N", "v": "N"},
  643. {"n": "O", "v": "O"}, {"n": "P", "v": "P"}, {"n": "Q", "v": "Q"},
  644. {"n": "R", "v": "R"}, {"n": "S", "v": "S"}, {"n": "T", "v": "T"},
  645. {"n": "U", "v": "U"}, {"n": "V", "v": "V"}, {"n": "W", "v": "W"},
  646. {"n": "X", "v": "X"}, {"n": "Y", "v": "Y"}, {"n": "Z", "v": "Z"}]},
  647. ]
  648. }
  649. }
  650. header = {
  651. "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",
  652. "Host": "tv.cctv.com",
  653. "Referer": "https://tv.cctv.com/"
  654. }
  655. def localProxy(self, params):
  656. return [200, "video/MP2T", ""]
  657. # -----------------------------------------------自定义函数-----------------------------------------------
  658. # 访问网页
  659. def webReadFile(self, urlStr, header):
  660. html = ''
  661. req = urllib.request.Request(url=urlStr) # ,headers=header
  662. with urllib.request.urlopen(req) as response:
  663. html = response.read().decode('utf-8')
  664. return html
  665. # 判断网络地址是否存在
  666. def TestWebPage(self, urlStr, header):
  667. html = ''
  668. req = urllib.request.Request(url=urlStr, method='HEAD') # ,headers=header
  669. with urllib.request.urlopen(req) as response:
  670. html = response.getcode()
  671. return html
  672. # 正则取文本
  673. def get_RegexGetText(self, Text, RegexText, Index):
  674. returnTxt = ""
  675. Regex = re.search(RegexText, Text, re.M | re.S)
  676. if Regex is None:
  677. returnTxt = ""
  678. else:
  679. returnTxt = Regex.group(Index)
  680. return returnTxt
  681. # 取集数
  682. def get_EpisodesList(self, jsonList):
  683. videos = []
  684. for vod in jsonList:
  685. url = vod['guid']
  686. title = vod['title']
  687. if len(url) == 0:
  688. continue
  689. videos.append(title + "$" + url)
  690. return videos
  691. # 取集数
  692. def get_EpisodesList_re(self, htmlTxt, patternTxt):
  693. ListRe = re.finditer(patternTxt, htmlTxt, re.M | re.S)
  694. videos = []
  695. for vod in ListRe:
  696. url = vod.group('url')
  697. title = vod.group('title')
  698. if len(url) == 0:
  699. continue
  700. videos.append(title + "$" + url)
  701. return videos
  702. # 取剧集区
  703. def get_lineList(self, Txt, mark, after):
  704. circuit = []
  705. origin = Txt.find(mark)
  706. while origin > 8:
  707. end = Txt.find(after, origin)
  708. circuit.append(Txt[origin:end])
  709. origin = Txt.find(mark, end)
  710. return circuit
  711. # 正则取文本,返回数组
  712. def get_RegexGetTextLine(self, Text, RegexText, Index):
  713. returnTxt = []
  714. pattern = re.compile(RegexText, re.M | re.S)
  715. ListRe = pattern.findall(Text)
  716. if len(ListRe) < 1:
  717. return returnTxt
  718. for value in ListRe:
  719. returnTxt.append(value)
  720. return returnTxt
  721. # 删除html标签
  722. def removeHtml(self, txt):
  723. soup = re.compile(r'<[^>]+>', re.S)
  724. txt = soup.sub('', txt)
  725. return txt.replace("&nbsp;", " ")
  726. # 取m3u8
  727. def get_m3u8(self, urlTxt):
  728. url = "https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid={0}".format(urlTxt)
  729. # htmlTxt = self.webReadFile(urlStr=url, header=self.header)
  730. htmlTxt = self.fetch(url).text
  731. jo = json.loads(htmlTxt)
  732. link = jo['hls_url'].strip()
  733. # 获取域名前缀
  734. urlPrefix = self.get_RegexGetText(Text=link, RegexText='(http[s]?://[a-zA-z0-9.]+)/', Index=1)
  735. # 域名前缀指定替换,然后可以获取到更高质量的视频列表
  736. new_link = link.replace(f'{urlPrefix}/asp/hls/', 'https://dh5.cntv.qcloudcdn.com/asp/h5e/hls/').split('?')[0]
  737. html = self.webReadFile(urlStr=new_link, header=self.header)
  738. content = html.strip()
  739. arr = content.split('\n')
  740. subUrl = arr[-1].split('/')
  741. # hdUrl = urlPrefix + arr[-1]
  742. # subUrl[3] = '2000'
  743. # subUrl[-1] = '2000.m3u8'
  744. # hdUrl = urlPrefix + '/'.join(subUrl)
  745. maxVideo = subUrl[-1].replace('.m3u8', '')
  746. hdUrl = link.replace('main', maxVideo)
  747. hdUrl = hdUrl.replace(urlPrefix, 'https://newcntv.qcloudcdn.com')
  748. hdRsp = self.TestWebPage(urlStr=hdUrl, header=self.header)
  749. if hdRsp == 200:
  750. url = hdUrl.split('?')[0]
  751. self.log(f'视频链接: {url}')
  752. else:
  753. url = ''
  754. return url
  755. # 搜索
  756. def get_list_search(self, html, tid):
  757. jRoot = json.loads(html)
  758. jsonList = jRoot['list']
  759. videos = []
  760. for vod in jsonList:
  761. url = vod['urllink']
  762. title = self.removeHtml(txt=vod['title'])
  763. img = vod['imglink']
  764. id = vod['id']
  765. brief = vod['channel']
  766. year = vod['uploadtime']
  767. if len(url) == 0:
  768. continue
  769. guids = [tid, title, url, img, id, year, '', brief]
  770. guid = "||".join(guids)
  771. videos.append({
  772. "vod_id": guid,
  773. "vod_name": title,
  774. "vod_pic": img,
  775. "vod_remarks": year
  776. })
  777. return videos
  778. def get_list1(self, html, tid, year_prefix=None):
  779. jRoot = json.loads(html)
  780. videos = []
  781. data = jRoot['response']
  782. if data is None:
  783. return []
  784. jsonList = data['docs']
  785. for vod in jsonList:
  786. id = vod['lastVIDE']['videoSharedCode']
  787. desc = vod['lastVIDE']['videoTitle']
  788. title = vod['column_name']
  789. url = vod['column_website']
  790. img = vod['column_logo']
  791. year = vod['column_playdate']
  792. brief = vod['column_brief']
  793. actors = ''
  794. if len(url) == 0:
  795. continue
  796. guids = [tid, title, url, img, id, year, actors, brief]
  797. guid = "||".join(guids)
  798. # print(vod_id)
  799. videos.append({
  800. "vod_id": year_prefix + '$$$' + guid if year_prefix else guid,
  801. "vod_name": title,
  802. "vod_pic": img,
  803. "vod_remarks": desc.split('》')[1].strip() if '》' in desc else desc.strip()
  804. })
  805. # print(videos)
  806. return videos
  807. # 分类取结果
  808. def get_list(self, html, tid):
  809. jRoot = json.loads(html)
  810. videos = []
  811. data = jRoot['data']
  812. if data is None:
  813. return []
  814. jsonList = data['list']
  815. for vod in jsonList:
  816. url = vod['url']
  817. title = vod['title']
  818. img = vod['image']
  819. id = vod['id']
  820. try:
  821. brief = vod['brief']
  822. except:
  823. brief = ''
  824. try:
  825. year = vod['year']
  826. except:
  827. year = ''
  828. try:
  829. actors = vod['actors']
  830. except:
  831. actors = ''
  832. if len(url) == 0:
  833. continue
  834. guids = [tid, title, url, img, id, year, actors, brief]
  835. guid = "||".join(guids)
  836. # print(vod_id)
  837. videos.append({
  838. "vod_id": guid,
  839. "vod_name": title,
  840. "vod_pic": img,
  841. "vod_remarks": ''
  842. })
  843. return videos
  844. # 4k分类取结果
  845. def get_list_4k(self, html, tid):
  846. jRoot = json.loads(html)
  847. videos = []
  848. data = jRoot['data']
  849. if data is None:
  850. return []
  851. jsonList = data['list']
  852. for vod in jsonList:
  853. vod_remarks = vod['title']
  854. id = vod['id']
  855. vod = vod['last_video']
  856. img = vod['image']
  857. url = vod['url']
  858. title = vod['title']
  859. brief = vod.get('brief') or ''
  860. year = vod.get('year') or ''
  861. actors = vod.get('actors') or ''
  862. if len(url) == 0:
  863. continue
  864. guids = [tid, title, url, img, id, year, actors, brief]
  865. guid = "||".join(guids)
  866. # print(vod_id)
  867. videos.append({
  868. "vod_id": guid,
  869. "vod_name": title,
  870. "vod_pic": img,
  871. "vod_remarks": vod_remarks
  872. })
  873. return videos
  874. if __name__ == '__main__':
  875. from t4.core.loader import t4_spider_init
  876. spider = Spider()
  877. t4_spider_init(spider)
  878. # print(spider.homeContent(True))
  879. # print(spider.homeVideoContent())
  880. # spider.init_api_ext_file()
  881. # url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=%E6%96%B0%E9%97%BB&cid=&p=1&n=20&serviceId=tvcctv&t=jsonp&cb=Callback'
  882. # url = 'https://api.cntv.cn/lanmu/columnSearch?&fl=&fc=&cid=&p=1&n=20&serviceId=tvcctv&t=json&cb=ko'
  883. # r = spider.fetch(url)
  884. # print(r.text)
  885. # home_content = spider.homeContent(None)
  886. # print(home_content)
  887. # cate_content = spider.categoryContent('栏目大全', 1, {'cid': 'n'}, {})
  888. # print(cate_content)
  889. # vid = cate_content['list'][0]['vod_id']
  890. # print(vid)
  891. # detail_content = spider.detailContent([vid])
  892. # print(detail_content)
  893. #
  894. # vod_play_from = detail_content['list'][0]['vod_play_from']
  895. # vod_play_url = detail_content['list'][0]['vod_play_url']
  896. # print(vod_play_from, vod_play_url)
  897. # _url = vod_play_url.split('#')[0].split('$')[1]
  898. # print(_url)
  899. # play = spider.playerContent(vod_play_from, _url, None)
  900. # print(play)