py_yiso.py 5.6 KB

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