在线之家.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. # coding=utf-8
  2. # !/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. try:
  6. # from base.spider import Spider as BaseSpider
  7. from base.spider import BaseSpider
  8. except ImportError:
  9. from t4.base.spider import BaseSpider
  10. import json
  11. import re
  12. class Spider(BaseSpider): # 元类 默认的元类 type
  13. def getName(self):
  14. return "在线之家"
  15. def init(self, extend=""):
  16. print("============{0}============".format(extend))
  17. pass
  18. def homeContent(self, filter):
  19. result = {}
  20. cateManual = {
  21. "电影": "1",
  22. "美剧": "2",
  23. "韩剧": "3",
  24. "日剧": "4",
  25. "泰剧": "5",
  26. "动漫": "6"
  27. }
  28. classes = []
  29. for k in cateManual:
  30. classes.append({
  31. 'type_name': k,
  32. 'type_id': cateManual[k]
  33. })
  34. result['class'] = classes
  35. if (filter):
  36. result['filters'] = self.config['filter']
  37. return result
  38. def homeVideoContent(self):
  39. rsp = self.fetch("https://www.zxzjhd.com/")
  40. root = self.html(rsp.text)
  41. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  42. videos = []
  43. for a in aList:
  44. name = a.xpath('./@title')[0]
  45. pic = a.xpath('./@data-original')[0]
  46. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  47. sid = a.xpath("./@href")[0]
  48. sid = self.regStr(sid, "/detail/(\\S+).html")
  49. videos.append({
  50. "vod_id": sid,
  51. "vod_name": name,
  52. "vod_pic": pic,
  53. "vod_remarks": mark
  54. })
  55. result = {
  56. 'list': videos
  57. }
  58. return result
  59. def categoryContent(self, tid, pg, filter, extend):
  60. result = {}
  61. if 'id' not in extend.keys():
  62. extend['id'] = tid
  63. extend['page'] = pg
  64. filterParams = ["id", "area", "by", "class", "lang", "", "", "", "page", "", "", "year"]
  65. params = ["", "", "", "", "", "", "", "", "", "", "", ""]
  66. for idx in range(len(filterParams)):
  67. fp = filterParams[idx]
  68. if fp in extend.keys():
  69. params[idx] = str(extend[fp])
  70. suffix = '-'.join(params)
  71. url = 'https://www.zxzjhd.com/vodshow/{0}.html'.format(suffix)
  72. rsp = self.fetch(url)
  73. root = self.html(rsp.text)
  74. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  75. videos = []
  76. for a in aList:
  77. name = a.xpath('./@title')[0]
  78. pic = a.xpath('./@data-original')[0]
  79. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  80. sid = a.xpath("./@href")[0]
  81. sid = self.regStr(sid, "/detail/(\\S+).html")
  82. videos.append({
  83. "vod_id": sid,
  84. "vod_name": name,
  85. "vod_pic": pic,
  86. "vod_remarks": mark
  87. })
  88. result['list'] = videos
  89. result['page'] = pg
  90. result['pagecount'] = 9999
  91. result['limit'] = 90
  92. result['total'] = 999999
  93. return result
  94. def detailContent(self, array):
  95. tid = array[0]
  96. url = 'https://www.zxzjhd.com/detail/{0}.html'.format(tid)
  97. rsp = self.fetch(url)
  98. root = self.html(rsp.text)
  99. node = root.xpath("//div[@class='stui-content']")[0]
  100. pic = node.xpath(".//img/@data-original")[0]
  101. title = node.xpath('.//h1/text()')[0]
  102. detail = node.xpath(".//span[@class='detail-content']/text()")[0]
  103. vod = {
  104. "vod_id": tid,
  105. "vod_name": title,
  106. "vod_pic": pic,
  107. "type_name": "",
  108. "vod_year": "",
  109. "vod_area": "",
  110. "vod_remarks": "",
  111. "vod_actor": "",
  112. "vod_director": "",
  113. "vod_content": detail
  114. }
  115. infoArray = node.xpath(".//div[@class='stui-content__detail']/p")
  116. for info in infoArray:
  117. content = info.xpath('string(.)')
  118. if content.startswith('类型'):
  119. vod['type_name'] = content
  120. # if content.startswith('年份'):
  121. # vod['vod_year'] = content
  122. # if content.startswith('地区'):
  123. # vod['vod_area'] = content
  124. # if content.startswith('更新'):
  125. # vod['vod_remarks'] = content.replace('\n','').replace('\t','')
  126. if content.startswith('主演'):
  127. vod['vod_actor'] = content.replace('\n', '').replace('\t', '')
  128. if content.startswith('导演'):
  129. vod['vod_director'] = content.replace('\n', '').replace('\t', '')
  130. # if content.startswith('剧情'):
  131. # vod['vod_content'] = content.replace('\n','').replace('\t','')
  132. vod_play_from = '$$$'
  133. playFrom = []
  134. vodHeader = root.xpath("//div[@class='stui-vodlist__head']/h3/text()")
  135. for v in vodHeader:
  136. playFrom.append(v)
  137. vod_play_from = vod_play_from.join(playFrom)
  138. vod_play_url = '$$$'
  139. playList = []
  140. vodList = root.xpath("//ul[contains(@class,'stui-content__playlist')]")
  141. for vl in vodList:
  142. vodItems = []
  143. aList = vl.xpath('./li/a')
  144. for tA in aList:
  145. href = tA.xpath('./@href')[0]
  146. name = tA.xpath('./text()')[0]
  147. tId = self.regStr(href, '/video/(\\S+).html')
  148. vodItems.append(name + "$" + tId)
  149. joinStr = '#'
  150. joinStr = joinStr.join(vodItems)
  151. playList.append(joinStr)
  152. vod_play_url = vod_play_url.join(playList)
  153. vod['vod_play_from'] = vod_play_from
  154. vod['vod_play_url'] = vod_play_url
  155. result = {
  156. 'list': [
  157. vod
  158. ]
  159. }
  160. return result
  161. def searchContent(self, wd, quick=False, pg=1):
  162. url = 'https://www.zxzjhd.com/index.php/ajax/suggest?mid=1&wd={0}'.format(wd)
  163. # getHeader()
  164. rsp = self.fetch(url)
  165. jo = json.loads(rsp.text)
  166. result = {}
  167. jArray = []
  168. if int(jo['total']) > 0:
  169. for j in jo['list']:
  170. jArray.append({
  171. "vod_id": j['id'],
  172. "vod_name": j['name'],
  173. "vod_pic": j['pic'],
  174. "vod_remarks": ""
  175. })
  176. result = {
  177. 'list': jArray
  178. }
  179. return result
  180. config = {
  181. "player": {
  182. "dpp": {
  183. "sh": "DP播放",
  184. "pu": "https://jx.zxzj.vip/dplayer.php?url=",
  185. "sn": 1,
  186. "or": 999
  187. }
  188. },
  189. "filter": {"1": [{"key": "class", "name": "剧情",
  190. "value": [{"n": "全部", "v": ""}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"},
  191. {"n": "恐怖", "v": "恐怖"}, {"n": "动作", "v": "动作"}, {"n": "科幻", "v": "科幻"},
  192. {"n": "剧情", "v": "剧情"}, {"n": "战争", "v": "战争"}, {"n": "警匪", "v": "警匪"},
  193. {"n": "犯罪", "v": "犯罪"}, {"n": "动画", "v": "动画"}, {"n": "奇幻", "v": "奇幻"},
  194. {"n": "冒险", "v": "冒险"}, {"n": "恐怖", "v": "恐怖"}, {"n": "悬疑", "v": "悬疑"},
  195. {"n": "惊悚", "v": "惊悚"}, {"n": "青春", "v": "青春"},
  196. {"n": "情色", "v": "情色"}]}, {"key": "area", "name": "地区",
  197. "value": [{"n": "全部", "v": ""},
  198. {"n": "大陆", "v": "大陆"},
  199. {"n": "香港", "v": "香港"},
  200. {"n": "台湾", "v": "台湾"},
  201. {"n": "欧美", "v": "欧美"},
  202. {"n": "韩国", "v": "韩国"},
  203. {"n": "日本", "v": "日本"},
  204. {"n": "泰国", "v": "泰国"},
  205. {"n": "印度", "v": "印度"},
  206. {"n": "俄罗斯", "v": "俄罗斯"},
  207. {"n": "其他", "v": "其他"}]},
  208. {"key": "year", "name": "年份",
  209. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"},
  210. {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  211. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"},
  212. {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  213. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"}, {"n": "2009", "v": "2009"},
  214. {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"},
  215. {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"},
  216. {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"},
  217. {"n": "2000", "v": "2000"}]}, {"key": "lang", "name": "语言",
  218. "value": [{"n": "全部", "v": ""},
  219. {"n": "英语", "v": "英语"},
  220. {"n": "韩语", "v": "韩语"},
  221. {"n": "日语", "v": "日语"},
  222. {"n": "法语", "v": "法语"},
  223. {"n": "泰语", "v": "泰语"},
  224. {"n": "德语", "v": "德语"},
  225. {"n": "印度语", "v": "印度语"},
  226. {"n": "国语", "v": "国语"},
  227. {"n": "粤 语", "v": "粤语"},
  228. {"n": "俄语", "v": "俄语"},
  229. {"n": "西班牙语", "v": "西班牙语"},
  230. {"n": "意大利语", "v": "意大利语"},
  231. {"n": "其它", "v": "其它"}]},
  232. {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"},
  233. {"n": "评分", "v": "score"}]}], "2": [
  234. {"key": "class", "name": "剧情",
  235. "value": [{"n": "全部", "v": ""}, {"n": "剧 情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"},
  236. {"n": "爱情", "v": "爱情"}, {"n": "动作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"},
  237. {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"},
  238. {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"},
  239. {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份",
  240. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"},
  241. {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"},
  242. {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  243. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"},
  244. {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"},
  245. {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  246. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"},
  247. {"n": "2009", "v": "2009"}, {"n": "2008", "v": "2008"},
  248. {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"},
  249. {"n": "2004", "v": "2004"}]},
  250. {"key": "lang", "name": "语言",
  251. "value": [{"n": "全部", "v": ""}, {"n": "英语", "v": "英语"}, {"n": "法语", "v": "法语"}]},
  252. {"key": "by", "name": "排序",
  253. "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "3": [
  254. {"key": "class", "name": "剧情",
  255. "value": [{"n": "全部", "v": ""}, {"n": "剧情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"},
  256. {"n": "爱情", "v": "爱情"}, {"n": "动 作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"},
  257. {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"},
  258. {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"},
  259. {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份",
  260. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"},
  261. {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"},
  262. {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  263. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"},
  264. {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"},
  265. {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  266. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"},
  267. {"n": "2009", "v": "2009"}, {"n": "2008", "v": "2008"},
  268. {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"},
  269. {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"},
  270. {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"},
  271. {"n": "2001", "v": "2001"},
  272. {"n": "2000", "v": "2000"}]},
  273. {"key": "by", "name": "排序",
  274. "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "4": [
  275. {"key": "class", "name": "剧情",
  276. "value": [{"n": "全部", "v": ""}, {"n": "剧情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"},
  277. {"n": "爱情", "v": "爱情"}, {"n": "动作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"},
  278. {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"},
  279. {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"},
  280. {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份",
  281. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"},
  282. {"n": "2021", "v": "2021"}, {"n": "2020", "v": "2020"},
  283. {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  284. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"},
  285. {"n": "2015", "v": "2015"}, {"n": "2014", "v": "2014"},
  286. {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  287. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"},
  288. {"n": "2009", "v": "2009"}, {"n": "2008", "v": "2008"},
  289. {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"},
  290. {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"},
  291. {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"},
  292. {"n": "2001", "v": "2001"},
  293. {"n": "2000", "v": "2000"}]},
  294. {"key": "by", "name": "排序",
  295. "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "5": [
  296. {"key": "year", "name": "年份",
  297. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"},
  298. {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  299. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"},
  300. {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  301. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"}, {"n": "2009", "v": "2009"},
  302. {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"},
  303. {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"},
  304. {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]},
  305. {"key": "by", "name": "排序",
  306. "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "6": [
  307. {"key": "class", "name": "剧情",
  308. "value": [{"n": "全部", "v": ""}, {"n": "情感", "v": "情感"}, {"n": "科幻", "v": "科幻"},
  309. {"n": "热血", "v": "热血"}, {"n": "推理", "v": " 推理"}, {"n": "搞笑", "v": "搞笑"},
  310. {"n": "冒险", "v": "冒险"}, {"n": "萝莉", "v": "萝莉"}, {"n": "校园", "v": "校园"},
  311. {"n": "动作", "v": "动作"}, {"n": "机战", "v": "机战"}, {"n": "运动", "v": "运动"},
  312. {"n": "战争", "v": "战争"}, {"n": " 少年", "v": "少年"}, {"n": "少女", "v": "少女"},
  313. {"n": "社会", "v": "社会"}, {"n": "原创", "v": "原创"}, {"n": "亲子", "v": "亲子"},
  314. {"n": "益智", "v": "益智"}, {"n": "励志", "v": "励志"}, {"n": "其他", "v": "其他"}]},
  315. {"key": "area", "name": "地区",
  316. "value": [{"n": "全部", "v": ""}, {"n": "国产", "v": "国产"}, {"n": "日本", "v": "日本"},
  317. {"n": "欧美", "v": "欧美"}, {"n": "其他", "v": "其他"}]}, {"key": "lang", "name": "语言",
  318. "value": [{"n": "全部", "v": ""},
  319. {"n": "国语", "v": "国语"},
  320. {"n": "日语", "v": "日语"},
  321. {"n": "英语", "v": "英语"},
  322. {"n": "其他",
  323. "v": "其他"}]},
  324. {"key": "year", "name": "年份",
  325. "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"n": "2021", "v": "2021"},
  326. {"n": "2020", "v": "2020"}, {"n": "2019", "v": "2019"}, {"n": "2018", "v": "2018"},
  327. {"n": "2017", "v": "2017"}, {"n": "2016", "v": "2016"}, {"n": "2015", "v": "2015"},
  328. {"n": "2014", "v": "2014"}, {"n": "2013", "v": "2013"}, {"n": "2012", "v": "2012"},
  329. {"n": "2011", "v": "2011"}, {"n": "2010", "v": "2010"}, {"n": "2009", "v": "2009"},
  330. {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"},
  331. {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"},
  332. {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]},
  333. {"key": "by", "name": "排序",
  334. "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}]}
  335. }
  336. def playerContent(self, flag, id, vipFlags):
  337. result = {}
  338. url = 'https://www.zxzjhd.com/video/{0}.html'.format(id)
  339. rsp = self.fetch(url)
  340. root = self.html(rsp.text)
  341. scripts = root.xpath("//script/text()")
  342. jo = {}
  343. for script in scripts:
  344. if (script.startswith("var player_")):
  345. target = script[script.index('{'):]
  346. jo = json.loads(target)
  347. break;
  348. parseUrl = ''
  349. # src="(\S+url=)
  350. # playerConfig = self.config['player']
  351. # if jo['from'] in self.config['player']:
  352. # playerConfig = self.config['player'][jo['from']]
  353. # parseUrl = playerConfig['pu'] + jo['url']
  354. # scriptUrl = 'https://www.zxzjhd.com/static/player/{0}.js'.format(jo['from'])
  355. # scriptRsp = self.fetch(scriptUrl)
  356. # parseUrl = self.regStr(scriptRsp.text,'src="(\\S+url=)')
  357. if 'line5' in jo['from']:
  358. url = jo['url']
  359. header = {
  360. 'Host': 'cx.zxzja.com:9876',
  361. 'Referer': 'https://www.zxzjhd.com/',
  362. 'sec-fetch-mode': 'navigate',
  363. 'sec-fetch-site': 'cross-site',
  364. 'sec-fetch-dest': 'iframe',
  365. 'upgrade-insecure-requests': '1'
  366. }
  367. self.log(url)
  368. parseRsp = self.fetch(url, headers=header)
  369. self.log(parseRsp)
  370. resultv2 = re.findall(r'var result_v2 = {(.*?)};', parseRsp.text, re.S)[0]
  371. self.log(resultv2)
  372. data = json.loads('{' + resultv2 + '}')['data']
  373. data_list = [i for i in data]
  374. data_list.reverse()
  375. content = data_list
  376. self.log(content)
  377. playUrl = ''
  378. for i in range(0, len(content), 2):
  379. combinedChars = content[i] + content[i + 1]
  380. decimalValue = int(combinedChars, 16)
  381. playUrl += chr(decimalValue)
  382. pos = int((len(playUrl) - 7) / 2)
  383. realUrl = playUrl[:pos] + playUrl[pos + 7:]
  384. if len(realUrl) > 0:
  385. result["parse"] = 0
  386. result["playUrl"] = ""
  387. result["url"] = realUrl
  388. result["header"] = ''
  389. else:
  390. result["parse"] = 1
  391. result["playUrl"] = ""
  392. result["url"] = jo['url']
  393. result["header"] = ''
  394. return result
  395. def isVideoFormat(self, url):
  396. pass
  397. def manualVideoCheck(self):
  398. pass
  399. def localProxy(self, params):
  400. action = {}
  401. return [200, "video/MP2T", action, ""]