py_czspp.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. # coding=utf-8
  2. # !/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. import base64
  7. import hashlib
  8. import requests
  9. from Crypto.Cipher import AES
  10. import urllib
  11. class Spider(Spider): # 元类 默认的元类 type
  12. def getName(self):
  13. return "厂长资源"
  14. def init(self, extend=""):
  15. print("============{0}============".format(extend))
  16. pass
  17. def homeContent(self, filter):
  18. result = {}
  19. cateManual = {
  20. "豆瓣电影Top250": "dbtop250",
  21. "最新电影": "zuixindianying",
  22. "电视剧": "dsj",
  23. "国产剧": "gcj",
  24. "美剧": "meijutt",
  25. "韩剧": "hanjutv",
  26. "番剧": "fanju",
  27. "动漫": "dm"
  28. }
  29. classes = []
  30. for k in cateManual:
  31. classes.append({
  32. 'type_name': k,
  33. 'type_id': cateManual[k]
  34. })
  35. result['class'] = classes
  36. return result
  37. def homeVideoContent(self):
  38. url = "https://czspp.com"
  39. header = {
  40. "Connection": "keep-alive",
  41. "Referer": url,
  42. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
  43. }
  44. session = self.getCookie(url,header)
  45. rsp = session.get(url, headers=header)
  46. root = self.html(self.cleanText(rsp.text))
  47. aList = root.xpath("//div[@class='mi_btcon']//ul/li")
  48. videos = []
  49. for a in aList:
  50. name = a.xpath('./a/img/@alt')[0]
  51. pic = a.xpath('./a/img/@data-original')[0]
  52. mark = a.xpath("./div[@class='hdinfo']/span/text()")[0]
  53. sid = a.xpath("./a/@href")[0]
  54. sid = self.regStr(sid, "/movie/(\\S+).html")
  55. videos.append({
  56. "vod_id": sid,
  57. "vod_name": name,
  58. "vod_pic": pic,
  59. "vod_remarks": mark
  60. })
  61. result = {
  62. 'list': videos
  63. }
  64. return result
  65. def getCookie(self,url,header):
  66. session = requests.session()
  67. rsp = session.get(url)
  68. nurl = 'https://czspp.com' + self.regStr(rsp.text, 'src=\"(.*?)\"')
  69. nrsp = session.get(nurl, headers=header)
  70. key = self.regStr(nrsp.text, 'var key=\"(.*?)\"')
  71. avalue = self.regStr(nrsp.text, 'value=\"(.*?)\"')
  72. c = ''
  73. for i in range(0, len(avalue)):
  74. a = avalue[i]
  75. b = ord(a)
  76. c = c + str(b)
  77. value = hashlib.md5(c.encode()).hexdigest()
  78. session.get('https://czspp.com/a20be899_96a6_40b2_88ba_32f1f75f1552_yanzheng_ip.php?type=96c4e20a0e951f471d32dae103e83881&key={0}&value={1}'.format(key,value), headers=header)
  79. return session
  80. def categoryContent(self, tid, pg, filter, extend):
  81. result = {}
  82. url = 'https://czspp.com/{0}/page/{1}'.format(tid,pg)
  83. header = {
  84. "Connection": "keep-alive",
  85. "Referer": url,
  86. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
  87. }
  88. session = self.getCookie(url,header)
  89. rsp = session.get(url, headers=header)
  90. root = self.html(self.cleanText(rsp.text))
  91. aList = root.xpath("//div[contains(@class,'bt_img mi_ne_kd mrb')]/ul/li")
  92. videos = []
  93. for a in aList:
  94. name = a.xpath('./a/img/@alt')[0]
  95. pic = a.xpath('./a/img/@data-original')[0]
  96. mark = a.xpath(".//div[@class='jidi']/span/text()")
  97. if mark ==[]:
  98. mark = a.xpath("./div[@class='hdinfo']/span/text()")
  99. mark = mark[0]
  100. sid = a.xpath("./a/@href")[0]
  101. sid = self.regStr(sid, "/movie/(\\S+).html")
  102. videos.append({
  103. "vod_id": sid,
  104. "vod_name": name,
  105. "vod_pic": pic,
  106. "vod_remarks": mark
  107. })
  108. result['list'] = videos
  109. result['page'] = pg
  110. result['pagecount'] = 9999
  111. result['limit'] = 90
  112. result['total'] = 999999
  113. return result
  114. def detailContent(self, array):
  115. tid = array[0]
  116. url = 'https://czspp.com/movie/{0}.html'.format(tid)
  117. header = {
  118. "Connection": "keep-alive",
  119. "Referer": url,
  120. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
  121. }
  122. session = self.getCookie(url, header)
  123. rsp = session.get(url, headers=header)
  124. root = self.html(self.cleanText(rsp.text))
  125. node = root.xpath("//div[@class='dyxingq']")[0]
  126. pic = node.xpath(".//div[@class='dyimg fl']/img/@src")[0]
  127. title = node.xpath('.//h1/text()')[0]
  128. detail = root.xpath(".//div[@class='yp_context']//p/text()")[0]
  129. vod = {
  130. "vod_id": tid,
  131. "vod_name": title,
  132. "vod_pic": pic,
  133. "type_name": "",
  134. "vod_year": "",
  135. "vod_area": "",
  136. "vod_remarks": "",
  137. "vod_actor": "",
  138. "vod_director": "",
  139. "vod_content": detail
  140. }
  141. infoArray = node.xpath(".//ul[@class='moviedteail_list']/li")
  142. for info in infoArray:
  143. content = info.xpath('string(.)')
  144. if content.startswith('地区'):
  145. tpyeare = ''
  146. for inf in info:
  147. tn = inf.text
  148. tpyeare = tpyeare +'/'+'{0}'.format(tn)
  149. vod['vod_area'] = tpyeare.strip('/')
  150. if content.startswith('年份'):
  151. vod['vod_year'] = content.replace("年份:","")
  152. if content.startswith('主演'):
  153. tpyeact = ''
  154. for inf in info:
  155. tn = inf.text
  156. tpyeact = tpyeact +'/'+'{0}'.format(tn)
  157. vod['vod_actor'] = tpyeact.strip('/')
  158. if content.startswith('导演'):
  159. tpyedire = ''
  160. for inf in info:
  161. tn = inf.text
  162. tpyedire = tpyedire +'/'+'{0}'.format(tn)
  163. vod['vod_director'] = tpyedire .strip('/')
  164. vod_play_from = '$$$'
  165. playFrom = ['厂长']
  166. vod_play_from = vod_play_from.join(playFrom)
  167. vod_play_url = '$$$'
  168. playList = []
  169. vodList = root.xpath("//div[@class='paly_list_btn']")
  170. for vl in vodList:
  171. vodItems = []
  172. aList = vl.xpath('./a')
  173. for tA in aList:
  174. href = tA.xpath('./@href')[0]
  175. name = tA.xpath('./text()')[0].replace('\xa0','')
  176. tId = self.regStr(href, '/v_play/(\\S+).html')
  177. vodItems.append(name + "$" + tId)
  178. joinStr = '#'
  179. joinStr = joinStr.join(vodItems)
  180. playList.append(joinStr)
  181. vod_play_url = vod_play_url.join(playList)
  182. vod['vod_play_from'] = vod_play_from
  183. vod['vod_play_url'] = vod_play_url
  184. result = {
  185. 'list': [
  186. vod
  187. ]
  188. }
  189. return result
  190. def searchContent(self, key, quick):
  191. url = 'https://czspp.com/xssearch?q={0}'.format(urllib.parse.quote(key))
  192. header = {
  193. "Connection": "keep-alive",
  194. "Referer": url,
  195. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
  196. }
  197. session = self.getCookie(url, header)
  198. rsp = session.get(url, headers=header)
  199. root = self.html(self.cleanText(rsp.text))
  200. vodList = root.xpath("//div[contains(@class,'mi_ne_kd')]/ul/li/a")
  201. videos = []
  202. for vod in vodList:
  203. name = vod.xpath('./img/@alt')[0]
  204. pic = vod.xpath('./img/@data-original')[0]
  205. href = vod.xpath('./@href')[0]
  206. tid = self.regStr(href, 'movie/(\\S+).html')
  207. res = vod.xpath('./div[@class="jidi"]/span/text()')
  208. if len(res) == 0:
  209. remark = '全1集'
  210. else:
  211. remark = vod.xpath('./div[@class="jidi"]/span/text()')[0]
  212. videos.append({
  213. "vod_id": tid,
  214. "vod_name": name,
  215. "vod_pic": pic,
  216. "vod_remarks": remark
  217. })
  218. result = {
  219. 'list': videos
  220. }
  221. return result
  222. config = {
  223. "player": {},
  224. "filter": {}
  225. }
  226. header = {
  227. "Referer": "https://czspp.com/",
  228. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36"
  229. }
  230. def parseCBC(self, enc, key, iv):
  231. keyBytes = key.encode("utf-8")
  232. ivBytes = iv.encode("utf-8")
  233. cipher = AES.new(keyBytes, AES.MODE_CBC, ivBytes)
  234. msg = cipher.decrypt(enc)
  235. paddingLen = msg[len(msg) - 1]
  236. return msg[0:-paddingLen]
  237. def playerContent(self, flag, id, vipFlags):
  238. result = {}
  239. url = 'https://czspp.com/v_play/{0}.html'.format(id)
  240. header = {
  241. "Connection": "keep-alive",
  242. "Referer": url,
  243. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
  244. }
  245. session = self.getCookie(url, header)
  246. pat = '\\"([^\\"]+)\\";var [\\d\\w]+=function dncry.*md5.enc.Utf8.parse\\(\\"([\\d\\w]+)\\".*md5.enc.Utf8.parse\\(([\\d]+)\\)'
  247. rsp = session.get(url, headers=header)
  248. html = rsp.text
  249. content = self.regStr(html, pat)
  250. if content == '':
  251. str3 = url
  252. pars = 1
  253. header = {
  254. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
  255. }
  256. else:
  257. key = self.regStr(html, pat, 2)
  258. iv = self.regStr(html, pat, 3)
  259. decontent = self.parseCBC(base64.b64decode(content), key, iv).decode()
  260. urlPat = 'video: \\{url: \\\"([^\\\"]+)\\\"'
  261. vttPat = 'subtitle: \\{url:\\\"([^\\\"]+\\.vtt)\\\"'
  262. str3 = self.regStr(decontent, urlPat)
  263. str4 = self.regStr(decontent, vttPat)
  264. self.loadVtt(str3)
  265. pars = 0
  266. header = ''
  267. if len(str4) > 0:
  268. result['subf'] = '/vtt/utf-8'
  269. result['subt'] = ''
  270. result = {
  271. 'parse': pars,
  272. 'playUrl': '',
  273. 'url': str3,
  274. 'header': header
  275. }
  276. return result
  277. def loadVtt(self, url):
  278. pass
  279. def isVideoFormat(self, url):
  280. pass
  281. def manualVideoCheck(self):
  282. pass
  283. def localProxy(self, param):
  284. action = {}
  285. return [200, "video/MP2T", action, ""]