py_yiso.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import os
  4. import sys
  5. import time
  6. import json
  7. import requests
  8. from base64 import b64encode
  9. sys.path.append('..')
  10. from base.spider import Spider
  11. class Spider(Spider):
  12. def getName(self):
  13. return "Yiso"
  14. def init(self,extend):
  15. self.ali = extend[0]
  16. print("============{0}============")
  17. pass
  18. def isVideoFormat(self,url):
  19. pass
  20. def manualVideoCheck(self):
  21. pass
  22. def homeContent(self,filter):
  23. result = {}
  24. return result
  25. def homeVideoContent(self):
  26. result = {}
  27. return result
  28. def categoryContent(self,tid,pg,filter,extend):
  29. result = {}
  30. return result
  31. def detailContent(self,array):
  32. hashMap = {}
  33. dirname = ''
  34. ids = array[0].split('@@@')
  35. self.listFiles(hashMap, dirname, [ids[1]])
  36. if not hashMap:
  37. return {}
  38. sortedMap = sorted(hashMap.items(), key=lambda x: x[0])
  39. vod = {
  40. "vod_id": array[0],
  41. "vod_name": ids[0],
  42. "vod_pic": 'https://p2.itc.cn/q_70/images03/20211009/59c75745d3524163b9277c4006020ac0.jpeg',
  43. "type_name": "",
  44. "vod_year": "",
  45. "vod_area": "",
  46. "vod_remarks": "",
  47. "vod_actor": "",
  48. "vod_director": "",
  49. "vod_content": ""
  50. }
  51. vod['vod_play_from'] = '原画$$$超清'
  52. vod_play_url = ''
  53. YHplayurl = ''
  54. CQplayurl = ''
  55. subDict = {}
  56. nameList = []
  57. for sm in sortedMap:
  58. if 'subtitles' in sm:
  59. for subList in sm[1]:
  60. subDict.update({os.path.splitext(subList['name'])[0]: sm[1].index(subList)})
  61. else:
  62. name = sm[0]
  63. sm[1][0]['params']['downloader_switch'] = 'True'
  64. YHurl = 'Docker域名或IP地址:端口/ali_resolve?item=' + b64encode(
  65. json.dumps(sm[1][0]['params']).encode("utf-8")).decode("utf-8")
  66. CQurl = 'Docker域名或IP地址:端口/ali_resolve?item=' + b64encode(
  67. json.dumps(sm[1][1]['params']).encode("utf-8")).decode("utf-8")
  68. YHplayurl = '{}#{}${}'.format(YHplayurl, name, YHurl)
  69. CQplayurl = '{}#{}${}'.format(CQplayurl, name, CQurl)
  70. name = name.split('/')[0]
  71. if ']|' in name:
  72. name = name.split('|')[1]
  73. nameList.append(name)
  74. for nL in nameList:
  75. for sbkey in subDict:
  76. if os.path.splitext(nL)[0] in sbkey:
  77. value = json.dumps(sm[1][subDict[sbkey]]['params'])
  78. requests.post('Docker域名或IP地址:端口/cache', params={'key': 'alisub', }, data=value, headers={'Content-Length': str(len(value))})
  79. vod['vod_play_url'] = YHplayurl.strip('#') + '$$$' + CQplayurl.strip('#')
  80. result = {
  81. 'list': [vod]
  82. }
  83. return result
  84. def listFiles(self, map, dirname, list):
  85. header = {
  86. "User-Agent": "Mozilla/5.0 (Linux; Android 12; V2049A Build/SP1A.210812.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36"
  87. }
  88. parent_item = {
  89. 'id': list[0],
  90. 'params': {}
  91. }
  92. url = 'Docker域名或IP地址:端口/ali_list?item=' + b64encode(json.dumps(parent_item).encode("utf-8")).decode("utf-8") + '&display_file_size=True'
  93. rsp = self.fetch(url, headers=header)
  94. while rsp.status_code != 200:
  95. time.sleep(1)
  96. rsp = self.fetch(url, headers=header)
  97. if rsp.text in ['Erro', 'Token', 'Session', 'Lapse', 'None']:
  98. return {}
  99. jo = json.loads(rsp.text)
  100. folderList = []
  101. dirnameList = []
  102. subtitlesList = []
  103. for info in jo:
  104. if dirname != '' and not dirname.startswith('['):
  105. dirname = '[' + dirname + ']|'
  106. if info['params']['file_type'] == 'folder':
  107. folderList.append(info['id'])
  108. dirnameList.append(info['name'])
  109. else:
  110. size = '/[{}]'.format(info['description'].split('\n')[0].split(':')[1])
  111. map[dirname + info['name'] + size] = info['sources']
  112. if info['subtitles'] != [] and info['subtitles'][0] not in subtitlesList:
  113. subtitlesList = subtitlesList + info['subtitles']
  114. if len(subtitlesList) > 0:
  115. map.update({'subtitles': subtitlesList})
  116. for folder in folderList:
  117. dirname = dirnameList[folderList.index(folder)]
  118. self.listFiles(map, dirname, [folder])
  119. def searchContent(self,key,quick):
  120. header = {
  121. "User-Agent": "Mozilla/5.0 (Linux; Android 12; V2049A Build/SP1A.210812.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36",
  122. "Referer": "https://yiso.fun/"
  123. }
  124. url = "https://yiso.fun/api/search?name={0}&from=ali".format(key)
  125. rsp = self.fetch(url=url, headers=header)
  126. vodList = json.loads(self.cleanText(rsp.text))['data']['list']
  127. videos = []
  128. for vod in vodList:
  129. videos.append({
  130. "vod_id": vod["fileInfos"][0]["fileName"] + '@@@' + vod["url"],
  131. "vod_name": vod["fileInfos"][0]["fileName"],
  132. "vod_pic": "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000",
  133. "vod_remarks": vod['gmtCreate']
  134. })
  135. result = {
  136. 'list':videos
  137. }
  138. return result
  139. def playerContent(self,flag,id,vipFlags):
  140. result = {}
  141. token = requests.get('Token或Token外链').text.replace('\n', '').replace(' ', '')
  142. url = id
  143. rsp = self.fetch(url=url)
  144. purl = '{}&token={}&connection={}' .format(rsp.text, token, '20')
  145. alisub = requests.get('Docker域名或IP地址:端口/cache',params={'key': 'alisub'}).text
  146. if alisub != '':
  147. requests.delete('Docker域名或IP地址:端口/cache', params={'key': 'alisub'})
  148. suburl = 'Docker域名或IP地址:端口/proxy_download_file?params={}&token={}&connection=1'.format(b64encode(alisub).encode("utf-8").decode("utf-8"), token)
  149. result['subt'] = suburl
  150. result["parse"] = 0
  151. result["playUrl"] = ''
  152. result["url"] = purl
  153. return result
  154. config = {
  155. "player": {},
  156. "filter": {}
  157. }
  158. header = {}
  159. def localProxy(self,param):
  160. return [200, "video/MP2T", action, ""]