newvision.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * @File : newvision.js
  3. * @Author : jade
  4. * @Date : 2024/2/20 14:14
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc : 新视觉影院
  8. */
  9. import {VodDetail, VodShort} from "../lib/vod.js"
  10. import * as Utils from "../lib/utils.js";
  11. import {Spider} from "./spider.js";
  12. import {Crypto} from "../lib/cat.js";
  13. class NewVisionSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.siteUrl = "https://www.6080yy3.com"
  17. }
  18. getAppName() {
  19. return "新视觉影院"
  20. }
  21. getName() {
  22. return "🐼┃新视觉影院┃🐼"
  23. }
  24. getJSName() {
  25. return "newvision"
  26. }
  27. getType() {
  28. return 3
  29. }
  30. async setClasses() {
  31. let $ = await this.getHtml()
  32. let navElements = $($("[class=\"nav-menu-items\"]")[0]).find("a")
  33. for (const navElement of navElements) {
  34. let type_id = Utils.getStrByRegex(/\/vodtype\/(.*?).html/, navElement.attribs.href)
  35. let type_name = navElement.attribs.title
  36. if (Utils.isNumeric(type_id)) {
  37. this.classes.push(this.getTypeDic(type_name, type_id))
  38. }
  39. }
  40. }
  41. async getFilter($) {
  42. let elements = $("[class='scroll-content']").slice(1)
  43. let extend_list = []
  44. let type_key_list = [3, 1, 11, 2]
  45. for (let i = 0; i < elements.length; i++) {
  46. let name = $($(elements[i]).find("a")[0]).text()
  47. let extend_dic = {"key": name, "name": name, "value": []}
  48. extend_dic["name"] = name
  49. extend_dic["value"].push({"n": "全部", "v": "0"})
  50. for (const ele of $(elements[i]).find("a").slice(1)) {
  51. let type_id_list = Utils.getStrByRegex(/\/vodshow\/(.*?).html/, ele.attribs.href).split("-")
  52. extend_dic["value"].push({
  53. "n": $(ele).text(), "v": decodeURIComponent(type_id_list[type_key_list[i]])
  54. })
  55. }
  56. extend_list.push(extend_dic)
  57. }
  58. return extend_list
  59. }
  60. async setFilterObj() {
  61. for (const type_dic of this.classes) {
  62. let type_id = type_dic["type_id"]
  63. if (type_id !== "最近更新") {
  64. let url = this.siteUrl + `/vodshow/${type_id}-----------.html`
  65. let $ = await this.getHtml(url)
  66. this.filterObj[type_id] = await this.getFilter($)
  67. }
  68. }
  69. }
  70. async parseVodShortListFromDoc($) {
  71. let items = $('.module-item');
  72. let vod_list = [];
  73. for (const item of items) {
  74. let vodShort = new VodShort()
  75. let oneA = $(item).find('.module-item-cover .module-item-pic a').first();
  76. vodShort.vod_id = oneA.attr('href');
  77. vodShort.vod_name = oneA.attr('title');
  78. vodShort.vod_pic = $(item).find('.module-item-cover .module-item-pic img').first().attr('data-src');
  79. if (vodShort.vod_pic.indexOf("img.php?url=") > 0) {
  80. vodShort.vod_pic = vodShort.vod_pic.split("img.php?url=")[1]
  81. }
  82. vodShort.vod_remarks = $(item).find('.module-item-text').first().text();
  83. vod_list.push(vodShort)
  84. }
  85. return vod_list
  86. }
  87. async parseVodShortListFromJson(obj) {
  88. let vod_list = []
  89. for (const result of obj["Data"]["result"]){
  90. let vodShort = new VodShort()
  91. vodShort.vod_id = result["vod_url"].replaceAll(this.siteUrl,"")
  92. vodShort.vod_pic = result["vod_pic"]
  93. vodShort.vod_name = result["vod_name"]
  94. vod_list.push(vodShort)
  95. }
  96. return vod_list
  97. }
  98. async parseVodDetailFromDoc($) {
  99. let html = $.html()
  100. let vodDetail = new VodDetail()
  101. let vodDetailElement = $("[class=\"box view-heading\"]")
  102. vodDetail.vod_name = $($(vodDetailElement).find("[class=\"page-title\"]")).text()
  103. let typeElements = $($(vodDetailElement).find("[class=\"tag-link\"]").find("a"))
  104. vodDetail.vod_area = $($(vodDetailElement).find("[class=\"tag-link\"]").slice(-1)[0]).text()
  105. let type_list = []
  106. for (const typeElement of typeElements) {
  107. type_list.push($(typeElement).text())
  108. }
  109. vodDetail.type_name = type_list.join("/")
  110. let itemElements = $(vodDetailElement).find("[class=\"video-info-items\"]")
  111. vodDetail.vod_director = $($(itemElements[0]).find("a")).text()
  112. let actor_list = []
  113. for (const actorElement of $(itemElements[1]).find("a")) {
  114. actor_list.push($(actorElement).text())
  115. }
  116. vodDetail.vod_pic = $($(vodDetailElement).find("[class=\"module-item-pic\"]")).find("img")[0].attribs["data-src"]
  117. vodDetail.vod_actor = actor_list.join("/")
  118. vodDetail.vod_year = $($(itemElements[2]).find("[class=\"video-info-item\"]")).text()
  119. vodDetail.vod_remarks = $($(itemElements[3]).find("[class=\"video-info-item\"]")).text()
  120. vodDetail.vod_content = $($(itemElements[5]).find("[class=\"video-info-item video-info-content vod_content\"]")).text().replaceAll("\n", "\t").replaceAll("\t收起", "")
  121. let playerformatElements = $("[class=\"module-tab-item tab-item\"]")
  122. let playUrlElements = $("[class=\"scroll-content\"]")
  123. let vod_play_from_list = []
  124. let vod_play_list = []
  125. for (let i = 0; i < playerformatElements.length; i++) {
  126. let playFormatElement = playerformatElements[i]
  127. let format_name = playFormatElement.attribs["data-dropdown-value"]
  128. if (format_name.indexOf("夸克") === -1) {
  129. vod_play_from_list.push(format_name)
  130. let vodItems = []
  131. for (const playUrlElement of $(playUrlElements[i]).find("a")) {
  132. let episodeName = $(playUrlElement).text()
  133. let episodeUrl = playUrlElement.attribs.href
  134. vodItems.push(episodeName + "$" + episodeUrl)
  135. }
  136. vod_play_list.push(vodItems.join("#"))
  137. }
  138. }
  139. vodDetail.vod_play_from = vod_play_from_list.join("$$$")
  140. vodDetail.vod_play_url = vod_play_list.join("$$$")
  141. return vodDetail
  142. }
  143. async setHomeVod() {
  144. let $ = await this.getHtml()
  145. this.homeVodList = await this.parseVodShortListFromDoc($)
  146. }
  147. async setCategory(tid, pg, filter, extend) {
  148. let urlParams = [tid.toString(), "", "", "", "", "", "", "", pg.toString(), "", "", ""]
  149. let type_key_list = [3, 11, 1, 2]
  150. if (extend["全部剧情"] !== undefined && extend["全部剧情"] !== "0") {
  151. urlParams[type_key_list[0]] = extend["全部剧情"]
  152. }
  153. if (extend["全部时间"] !== undefined && extend["全部时间"] !== "0") {
  154. urlParams[type_key_list[1]] = extend["全部时间"]
  155. }
  156. if (extend["全部地区"] !== undefined && extend["全部地区"] !== "0") {
  157. urlParams[type_key_list[2]] = extend["全部地区"]
  158. }
  159. if (extend["时间排序"] !== undefined && extend["时间排序"] !== "0") {
  160. urlParams[type_key_list[3]] = extend["时间排序"]
  161. }
  162. let reqUrl = this.siteUrl + '/index.php/vodshow/' + urlParams.join("-") + '.html';
  163. let $ = await this.getHtml(reqUrl)
  164. this.vodList = await this.parseVodShortListFromDoc($)
  165. }
  166. async setDetail(id) {
  167. let $ = await this.getHtml(this.siteUrl + id)
  168. this.vodDetail = await this.parseVodDetailFromDoc($)
  169. }
  170. uic(url,uid){
  171. let ut = Crypto.enc.Utf8.parse('2890'+uid+'tB959C')
  172. let mm = Crypto.enc.Utf8.parse("2F131BE91247866E")
  173. let decrypted = Crypto.AES.decrypt(url, ut, {iv: mm, mode: Crypto.mode.CBC, padding: Crypto.pad.Pkcs7});
  174. return Crypto.enc.Utf8.stringify(decrypted);
  175. }
  176. async setPlay(flag, id, flags) {
  177. let $ = await this.getHtml(this.siteUrl + id)
  178. let playUrl = $("[id=\"bfurl\"]")[0].attribs.href
  179. if (playUrl.indexOf("http") > -1){
  180. this.playUrl = playUrl
  181. }else{
  182. //需要解析URL,支持弹幕
  183. let newUrl = "https://jiexi.xn--1lq90i13mxk5bolhm8k.xn--fiqs8s/player/ec.php?code=ak&if=1&url=" + playUrl
  184. let play$ = await this.getHtml(newUrl)
  185. let playHtml = play$.html()
  186. let playConfig = JSON.parse(Utils.getStrByRegex(/let ConFig = (.*?),box = /,playHtml))
  187. this.playUrl = this.uic(playConfig["url"],playConfig["config"]["uid"])
  188. }
  189. }
  190. async setSearch(wd, quick) {
  191. let url = `http://123.207.150.253/zxapi/public/?service=App.F.Fetch&req_p=${wd}&type=6080`
  192. let content = await this.fetch(url,null,this.getHeader())
  193. this.vodList = await this.parseVodShortListFromJson(JSON.parse(content))
  194. }
  195. }
  196. let spider = new NewVisionSpider()
  197. async function init(cfg) {
  198. await spider.init(cfg)
  199. }
  200. async function home(filter) {
  201. return await spider.home(filter)
  202. }
  203. async function homeVod() {
  204. return await spider.homeVod()
  205. }
  206. async function category(tid, pg, filter, extend) {
  207. return await spider.category(tid, pg, filter, extend)
  208. }
  209. async function detail(id) {
  210. return await spider.detail(id)
  211. }
  212. async function play(flag, id, flags) {
  213. return await spider.play(flag, id, flags)
  214. }
  215. async function search(wd, quick) {
  216. return await spider.search(wd, quick)
  217. }
  218. async function proxy(segments, headers) {
  219. return await spider.proxy(segments, headers)
  220. }
  221. export function __jsEvalReturn() {
  222. return {
  223. init: init,
  224. home: home,
  225. homeVod: homeVod,
  226. category: category,
  227. detail: detail,
  228. play: play,
  229. search: search,
  230. proxy: proxy
  231. };
  232. }
  233. export {spider}