py_ikan.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. import math
  5. import json
  6. import base64
  7. import requests
  8. sys.path.append('..')
  9. from base.spider import Spider
  10. class Spider(Spider):
  11. def getName(self):
  12. return "爱看影视"
  13. def init(self,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. "电影": "1",
  23. "剧集": "2",
  24. "综艺": "3",
  25. "动漫": "4",
  26. "美剧": "16",
  27. "日韩剧": "15",
  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. if (filter):
  37. result['filters'] = self.config['filter']
  38. return result
  39. def homeVideoContent(self):
  40. result = {}
  41. return result
  42. def categoryContent(self,tid,pg,filter,extend):
  43. result = {}
  44. return result
  45. def detailContent(self,array):
  46. aid = array[0]
  47. url = 'https://ikanys.tv/voddetail/{0}/'.format(aid)
  48. rsp = self.fetch(url)
  49. html = self.html(rsp.text)
  50. node = html.xpath("//div[@class='box-width flex between rel']")[0]
  51. title = html.xpath("//h3[@class='slide-info-title hide']/text()")[0]
  52. pic = html.xpath("//a[@class='detail-pic lazy mask-1']/@data-original")[0]
  53. vod = {
  54. "vod_id": aid,
  55. "vod_name": title,
  56. "vod_pic": pic,
  57. "type_name": '',
  58. "vod_year": '',
  59. "vod_area": '',
  60. "vod_remarks": '',
  61. "vod_actor": '',
  62. "vod_director": '',
  63. "vod_content": ''
  64. }
  65. playFrom = ''
  66. playfromList = html.xpath("//div[@class='swiper-wrapper']/a")
  67. for pL in playfromList:
  68. pL = pL.xpath("./text()")[0].strip()
  69. playFrom = playFrom + '$$$' + pL
  70. urlList = html.xpath("//div[contains(@class,'anthology-list-box none')]")
  71. playUrl = ''
  72. for uL in urlList:
  73. for playurl in uL.xpath(".//li"):
  74. purl = self.regStr(reg=r'/vodplay/(.*?)/', src=playurl.xpath("./a/@href")[0])
  75. name = playurl.xpath("./a/text()")[0]
  76. playUrl = playUrl + '{}${}#'.format(name, purl)
  77. playUrl = playUrl + '$$$'
  78. vod['vod_play_from'] = playFrom.strip('$$$')
  79. vod['vod_play_url'] = playUrl.strip('$$$')
  80. result = {
  81. 'list': [
  82. vod
  83. ]
  84. }
  85. return result
  86. def verifyCode(self,tag):
  87. header = {
  88. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
  89. }
  90. try:
  91. session = requests.session()
  92. r = session.post('https://ddddocr.lm317379829.repl.co', json={'url': 'https://ikanys.tv/index.php/verify/index.html', 'comp': 'digit'})
  93. jo = r.json()
  94. if jo['code'] == 1:
  95. code = jo['result']
  96. session.cookies.update(jo['cookies'])
  97. else:
  98. return False, None
  99. res = session.post(url="https://ikanys.tv/index.php/ajax/verify_check?type={}&verify={}".format(tag, code), headers=header, timeout=5).json()
  100. if res["msg"] == "ok":
  101. return True, session
  102. except:
  103. pass
  104. return False, None
  105. def searchContent(self,key,quick):
  106. result = {}
  107. header = {
  108. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
  109. }
  110. url = 'https://ikanys.tv/vodsearch/-------------/?wd={0}'.format(key)
  111. _, session = self.verifyCode('search')
  112. rsp = session.get(url, headers=header)
  113. root = self.html(rsp.text)
  114. vodList = root.xpath("//div[@class='search-box flex rel']")
  115. videos = []
  116. for vod in vodList:
  117. name = vod.xpath(".//div[@class='thumb-txt cor4 hide']/text()")[0]
  118. pic = vod.xpath(".//div[@class='lazy gen-movie-img mask-1']/@data-original")[0]
  119. mark = vod.xpath(".//span[@class='public-list-prb hide ft2']/text()")[0]
  120. sid = vod.xpath(".//a[@class='public-list-exp']/@href")[0]
  121. sid = self.regStr(sid,"/voddetail/(\\S+)/")
  122. videos.append({
  123. "vod_id":sid,
  124. "vod_name":name,
  125. "vod_pic":pic,
  126. "vod_remarks":mark
  127. })
  128. result = {
  129. 'list': videos
  130. }
  131. return result
  132. def playerContent(self,flag,id,vipFlags):
  133. header = {
  134. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36",
  135. "Referer": "https://ikanys.tv/"
  136. }
  137. result = {}
  138. url = 'https://ikanys.tv/vodplay/{0}/'.format(id)
  139. rsp = self.fetch(url, headers=header)
  140. info = json.loads(self.regStr(reg=r'var player_data=(.*?)</script>', src=self.cleanText(rsp.text)))
  141. parse = 0
  142. purl = base64.b64decode(info['url'].encode())[14:-8].decode()
  143. if purl.startswith('http'):
  144. purl = purl
  145. else:
  146. parse = 1
  147. purl = url
  148. result["parse"] = parse
  149. result["playUrl"] = ''
  150. result["url"] = purl
  151. result["header"] = ''
  152. return result
  153. config = {
  154. "player": {},
  155. "filter": {}
  156. }
  157. header = {}
  158. def localProxy(self,param):
  159. action = {
  160. 'url':'',
  161. 'header':'',
  162. 'param':'',
  163. 'type':'string',
  164. 'after':''
  165. }
  166. return [200, "video/MP2T", action, ""]