py_zxzj.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. class Spider(Spider): # 元类 默认的元类 type
  8. def getName(self):
  9. return "在线之家"
  10. def init(self,extend=""):
  11. print("============{0}============".format(extend))
  12. pass
  13. def homeContent(self,filter):
  14. result = {}
  15. cateManual = {
  16. "电影":"1",
  17. "美剧":"2",
  18. "韩剧":"3",
  19. "日剧":"4",
  20. "泰剧":"5",
  21. "动漫":"6"
  22. }
  23. classes = []
  24. for k in cateManual:
  25. classes.append({
  26. 'type_name':k,
  27. 'type_id':cateManual[k]
  28. })
  29. result['class'] = classes
  30. if(filter):
  31. result['filters'] = self.config['filter']
  32. return result
  33. def homeVideoContent(self):
  34. rsp = self.fetch("https://zxzj.vip/")
  35. root = self.html(rsp.text)
  36. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  37. videos = []
  38. for a in aList:
  39. name = a.xpath('./@title')[0]
  40. pic = a.xpath('./@data-original')[0]
  41. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  42. sid = a.xpath("./@href")[0]
  43. sid = self.regStr(sid,"/detail/(\\S+).html")
  44. videos.append({
  45. "vod_id":sid,
  46. "vod_name":name,
  47. "vod_pic":pic,
  48. "vod_remarks":mark
  49. })
  50. result = {
  51. 'list':videos
  52. }
  53. return result
  54. def categoryContent(self,tid,pg,filter,extend):
  55. result = {}
  56. if 'id' not in extend.keys():
  57. extend['id'] = tid
  58. extend['page'] = pg
  59. filterParams = ["id", "area", "by", "class", "lang", "", "", "", "page", "", "", "year"]
  60. params = ["", "", "", "", "", "", "", "", "", "", "", ""]
  61. for idx in range(len(filterParams)):
  62. fp = filterParams[idx]
  63. if fp in extend.keys():
  64. params[idx] = extend[fp]
  65. suffix = '-'.join(params)
  66. url = 'https://zxzj.vip/vodshow/{0}.html'.format(suffix)
  67. rsp = self.fetch(url)
  68. root = self.html(rsp.text)
  69. aList = root.xpath("//div[@class='stui-vodlist__box']/a")
  70. videos = []
  71. for a in aList:
  72. name = a.xpath('./@title')[0]
  73. pic = a.xpath('./@data-original')[0]
  74. mark = a.xpath("./span[@class='pic-text text-right']/text()")[0]
  75. sid = a.xpath("./@href")[0]
  76. sid = self.regStr(sid,"/detail/(\\S+).html")
  77. videos.append({
  78. "vod_id":sid,
  79. "vod_name":name,
  80. "vod_pic":pic,
  81. "vod_remarks":mark
  82. })
  83. result['list'] = videos
  84. result['page'] = pg
  85. result['pagecount'] = 9999
  86. result['limit'] = 90
  87. result['total'] = 999999
  88. return result
  89. def detailContent(self,array):
  90. tid = array[0]
  91. url = 'https://zxzj.vip/detail/{0}.html'.format(tid)
  92. rsp = self.fetch(url)
  93. root = self.html(rsp.text)
  94. node = root.xpath("//div[@class='stui-content']")[0]
  95. pic = node.xpath(".//img/@data-original")[0]
  96. title = node.xpath('.//h1/text()')[0]
  97. detail = node.xpath(".//span[@class='detail-content']/text()")[0]
  98. vod = {
  99. "vod_id":tid,
  100. "vod_name":title,
  101. "vod_pic":pic,
  102. "type_name":"",
  103. "vod_year":"",
  104. "vod_area":"",
  105. "vod_remarks":"",
  106. "vod_actor":"",
  107. "vod_director":"",
  108. "vod_content":detail
  109. }
  110. infoArray = node.xpath(".//div[@class='stui-content__detail']/p")
  111. for info in infoArray:
  112. content = info.xpath('string(.)')
  113. if content.startswith('类型'):
  114. vod['type_name'] = content
  115. # if content.startswith('年份'):
  116. # vod['vod_year'] = content
  117. # if content.startswith('地区'):
  118. # vod['vod_area'] = content
  119. # if content.startswith('更新'):
  120. # vod['vod_remarks'] = content.replace('\n','').replace('\t','')
  121. if content.startswith('主演'):
  122. vod['vod_actor'] = content.replace('\n','').replace('\t','')
  123. if content.startswith('导演'):
  124. vod['vod_director'] = content.replace('\n','').replace('\t','')
  125. # if content.startswith('剧情'):
  126. # vod['vod_content'] = content.replace('\n','').replace('\t','')
  127. vod_play_from = '$$$'
  128. playFrom = []
  129. vodHeader = root.xpath("//div[@class='stui-vodlist__head']/h3/text()")
  130. for v in vodHeader:
  131. playFrom.append(v)
  132. vod_play_from = vod_play_from.join(playFrom)
  133. vod_play_url = '$$$'
  134. playList = []
  135. vodList = root.xpath("//ul[contains(@class,'stui-content__playlist')]")
  136. for vl in vodList:
  137. vodItems = []
  138. aList = vl.xpath('./li/a')
  139. for tA in aList:
  140. href = tA.xpath('./@href')[0]
  141. name = tA.xpath('./text()')[0]
  142. tId = self.regStr(href,'/video/(\\S+).html')
  143. vodItems.append(name + "$" + tId)
  144. joinStr = '#'
  145. joinStr = joinStr.join(vodItems)
  146. playList.append(joinStr)
  147. vod_play_url = vod_play_url.join(playList)
  148. vod['vod_play_from'] = vod_play_from
  149. vod['vod_play_url'] = vod_play_url
  150. result = {
  151. 'list':[
  152. vod
  153. ]
  154. }
  155. return result
  156. def searchContent(self,key,quick):
  157. url = 'https://zxzj.vip/index.php/ajax/suggest?mid=1&wd={0}'.format(key)
  158. # getHeader()
  159. rsp = self.fetch(url)
  160. jo = json.loads(rsp.text)
  161. result = {}
  162. jArray = []
  163. if int(jo['total']) > 0:
  164. for j in jo['list']:
  165. jArray.append({
  166. "vod_id": j['id'],
  167. "vod_name": j['name'],
  168. "vod_pic": j['pic'],
  169. "vod_remarks": ""
  170. })
  171. result = {
  172. 'list':jArray
  173. }
  174. return result
  175. config = {
  176. "player": {
  177. "dpp": {
  178. "sh": "DP播放",
  179. "pu": "https://jx.zxzj.vip/dplayer.php?url=",
  180. "sn": 1,
  181. "or": 999
  182. }
  183. },
  184. "filter": {"1": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"}, {"n": "恐怖", "v": "恐怖"}, {"n": "动作", "v": "动作"}, {"n": "科幻", "v": "科幻"}, {"n": "剧情", "v": "剧情"}, {"n": "战争", "v": "战争"}, {"n": "警匪", "v": "警匪"}, {"n": "犯罪", "v": "犯罪"}, {"n": "动画", "v": "动画"}, {"n": "奇幻", "v": "奇幻"}, {"n": "冒险", "v": "冒险"}, {"n": "恐怖", "v": "恐怖"}, {"n": "悬疑", "v": "悬疑"}, {"n": "惊悚", "v": "惊悚"}, {"n": "青春", "v": "青春"}, {"n": "情色", "v": "情色"}]}, {"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "大陆", "v": "大陆"}, {"n": "香港", "v": "香港"}, {"n": "台湾", "v": "台湾"}, {"n": "欧美", "v": "欧美"}, {"n": "韩国", "v": "韩国"}, {"n": "日本", "v": "日本"}, {"n": "泰国", "v": "泰国"}, {"n": "印度", "v": "印度"}, {"n": "俄罗斯", "v": "俄罗斯"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "lang", "name": "语言", "value": [{"n": "全部", "v": ""}, {"n": "英语", "v": "英语"}, {"n": "韩语", "v": "韩语"}, {"n": "日语", "v": "日语"}, {"n": "法语", "v": "法语"}, {"n": "泰语", "v": "泰语"}, {"n": "德语", "v": "德语"}, {"n": "印度语", "v": "印度语"}, {"n": "国语", "v": "国语"}, {"n": "粤 语", "v": "粤语"}, {"n": "俄语", "v": "俄语"}, {"n": "西班牙语", "v": "西班牙语"}, {"n": "意大利语", "v": "意大利语"}, {"n": "其它", "v": "其它"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "2": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "剧 情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"}, {"n": "动作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"}, {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"}, {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}]}, {"key": "lang", "name": "语言", "value": [{"n": "全部", "v": ""}, {"n": "英语", "v": "英语"}, {"n": "法语", "v": "法语"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "3": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "剧情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"}, {"n": "动 作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"}, {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"}, {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "4": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "剧情", "v": "剧情"}, {"n": "喜剧", "v": "喜剧"}, {"n": "爱情", "v": "爱情"}, {"n": "动作", "v": "动作"}, {"n": "悬疑", "v": "悬疑"}, {"n": "恐怖", "v": "恐怖"}, {"n": "奇幻", "v": "奇幻"}, {"n": "惊悚", "v": "惊悚"}, {"n": "犯罪", "v": "犯罪"}, {"n": "科幻", "v": "科幻"}, {"n": "音乐", "v": "音乐"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "5": [{"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}], "6": [{"key": "class", "name": "剧情", "value": [{"n": "全部", "v": ""}, {"n": "情感", "v": "情感"}, {"n": "科幻", "v": "科幻"}, {"n": "热血", "v": "热血"}, {"n": "推理", "v": " 推理"}, {"n": "搞笑", "v": "搞笑"}, {"n": "冒险", "v": "冒险"}, {"n": "萝莉", "v": "萝莉"}, {"n": "校园", "v": "校园"}, {"n": "动作", "v": "动作"}, {"n": "机战", "v": "机战"}, {"n": "运动", "v": "运动"}, {"n": "战争", "v": "战争"}, {"n": " 少年", "v": "少年"}, {"n": "少女", "v": "少女"}, {"n": "社会", "v": "社会"}, {"n": "原创", "v": "原创"}, {"n": "亲子", "v": "亲子"}, {"n": "益智", "v": "益智"}, {"n": "励志", "v": "励志"}, {"n": "其他", "v": "其他"}]}, {"key": "area", "name": "地区", "value": [{"n": "全部", "v": ""}, {"n": "国产", "v": "国产"}, {"n": "日本", "v": "日本"}, {"n": "欧美", "v": "欧美"}, {"n": "其他", "v": "其他"}]}, {"key": "lang", "name": "语言", "value": [{"n": "全部", "v": ""}, {"n": "国语", "v": "国语"}, {"n": "日语", "v": "日语"}, {"n": "英语", "v": "英语"}, {"n": "其他", "v": "其他"}]}, {"key": "year", "name": "年份", "value": [{"n": "全部", "v": ""}, {"n": "2022", "v": "2022"}, {"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"}, {"n": "2008", "v": "2008"}, {"n": "2007", "v": "2007"}, {"n": "2006", "v": "2006"}, {"n": "2005", "v": "2005"}, {"n": "2004", "v": "2004"}, {"n": "2003", "v": "2003"}, {"n": "2002", "v": "2002"}, {"n": "2001", "v": "2001"}, {"n": "2000", "v": "2000"}]}, {"key": "by", "name": "排序", "value": [{"n": "最新", "v": "time"}, {"n": "最热", "v": "hits"}, {"n": "评分", "v": "score"}]}]}
  185. }
  186. header = {
  187. "origin":"https://zxzj.vip",
  188. "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
  189. "Accept":" */*",
  190. "Accept-Language":"zh-CN,zh;q=0.9,en-US;q=0.3,en;q=0.7",
  191. "Accept-Encoding":"gzip, deflate"
  192. }
  193. def playerContent(self,flag,id,vipFlags):
  194. result = {}
  195. url = 'https://zxzj.vip/video/{0}.html'.format(id)
  196. rsp = self.fetch(url)
  197. root = self.html(rsp.text)
  198. scripts = root.xpath("//script/text()")
  199. jo = {}
  200. for script in scripts:
  201. if(script.startswith("var player_")):
  202. target = script[script.index('{'):]
  203. jo = json.loads(target)
  204. break;
  205. parseUrl = ''
  206. # src="(\S+url=)
  207. # playerConfig = self.config['player']
  208. # if jo['from'] in self.config['player']:
  209. # playerConfig = self.config['player'][jo['from']]
  210. # parseUrl = playerConfig['pu'] + jo['url']
  211. scriptUrl = 'https://zxzj.vip/static/player/{0}.js'.format(jo['from'])
  212. scriptRsp = self.fetch(scriptUrl)
  213. parseUrl = self.regStr(scriptRsp.text,'src="(\\S+url=)')
  214. if len(parseUrl) > 0:
  215. parseRsp = self.fetch(parseUrl+jo['url'])
  216. realUrl = self.regStr(parseRsp.text,"(?<=urls\\s=\\s').*?(?=')",0)
  217. if len(realUrl) > 0 :
  218. result["parse"] = 0
  219. result["playUrl"] = ""
  220. result["url"] = realUrl
  221. result["header"] = json.dumps(self.header)
  222. else:
  223. result["parse"] = 1
  224. result["playUrl"] = ""
  225. result["url"] = jo['url']
  226. result["header"] = json.dumps(self.header)
  227. return result
  228. def isVideoFormat(self,url):
  229. pass
  230. def manualVideoCheck(self):
  231. pass
  232. def localProxy(self,param):
  233. return [200, "video/MP2T", action, ""]