ciliduo.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * @File : ciliduo.js
  3. * @Author : jade
  4. * @Date : 2024/3/1 13:26
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc : 磁力多
  8. */
  9. import {_, load} from '../lib/cat.js';
  10. import {VodDetail, VodShort} from "../lib/vod.js"
  11. import * as Utils from "../lib/utils.js";
  12. import {Spider} from "./spider.js";
  13. class CiliDuoSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.siteUrl = "https://of.cilido.top"
  17. this.apiUrl = ""
  18. this.vodShortObj = {}
  19. }
  20. getName() {
  21. return "🔞┃磁力多BT┃🔞"
  22. }
  23. getAppName() {
  24. return "磁力多BT"
  25. }
  26. getJSName() {
  27. return "ciliduo"
  28. }
  29. getType() {
  30. return 3
  31. }
  32. getProxy(src) {
  33. return Utils.base64Decode(src)
  34. }
  35. async home(filter) {
  36. try {
  37. await this.jadeLog.info("正在解析首页类别", true)
  38. let $ = await this.getHtml()
  39. let proxy_src = Utils.getStrByRegex(/var proxy = atob\('(.*?)'\)/, $.html())
  40. this.apiUrl = this.getProxy(proxy_src)
  41. let params = `/?host=${Utils.getHost(this.siteUrl).split("://").slice(-1)[0]}&v=1`
  42. let homeContent = await this.fetch(this.apiUrl, params, this.getHeader())
  43. return await this.parseVodShortListFromDoc(load(homeContent))
  44. } catch (e) {
  45. await this.jadeLog.error(`首页解析失败,失败原因为:${e}`)
  46. }
  47. }
  48. async parseVodShortListFromDoc($) {
  49. let rootElemet = $("[class=\"htab\"]")
  50. let navElements = rootElemet.find("a")
  51. let vodElements = $("[class=\"hotwords\"]").find("ul")
  52. for (let i = 0; i < navElements.length; i++) {
  53. let navElement = navElements[i]
  54. if (i !== navElements.length - 1) {
  55. let type_name = $(navElement).text()
  56. if (type_name === "热门") {
  57. type_name = "最近更新"
  58. }
  59. this.classes.push(this.getTypeDic(type_name, type_name))
  60. let vodElement = vodElements[i]
  61. let vod_list = []
  62. for (const vodShorElement of $(vodElement).find("a")) {
  63. let vodShort = new VodShort()
  64. vodShort.vod_id = vodShorElement.attribs.href
  65. vodShort.vod_name = $(vodShorElement).html()
  66. vodShort.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
  67. vod_list.push(vodShort)
  68. }
  69. this.vodShortObj[type_name] = vod_list
  70. }
  71. }
  72. return this.result.home(this.classes, [], this.filterObj)
  73. }
  74. async parseVodShortListFromDocBySearch($) {
  75. let vod_list = []
  76. let vodElements = $("[class=\"ssbox\"]")
  77. for (const vodElement of vodElements.slice(0, -1)) {
  78. let vodShort = new VodShort()
  79. vodShort.vod_id = $(vodElement).find("a")[0].attribs.href
  80. vodShort.vod_name = $($(vodElement).find("a")[0]).text()
  81. vodShort.vod_remarks = $($(vodElement).find("span")[0]).text()
  82. vodShort.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
  83. vod_list.push(vodShort)
  84. }
  85. return vod_list
  86. }
  87. async parseVodDetailFromDoc($) {
  88. let html = $.html()
  89. let vodDetail = new VodDetail()
  90. vodDetail.vod_name = $($("[class=\"bt_title\"]")).text()
  91. vodDetail.vod_pic = Utils.RESOURCEURL + "/resources/cili.jpg"
  92. vodDetail.vod_remarks = Utils.getStrByRegex(/<br>收录时间:<span>(.*?)<\/span>/, $.html())
  93. vodDetail.vod_content = "下载速度:" + Utils.getStrByRegex(/下载速度:<span>(.*?)<\/span>/, $.html())
  94. vodDetail.vod_play_from = ["磁力连接"].join("$$$")
  95. let vodItems = []
  96. let contentElement = $("[class=\"content\"]").find("span")[0]
  97. let episodeUrl = contentElement.attribs.href;
  98. let episodeName = contentElement.attribs.title;
  99. vodItems.push(episodeName + "$" + episodeUrl);
  100. vodDetail.vod_play_url = [vodItems.join("#")].join("$$$")
  101. return vodDetail
  102. }
  103. async setHomeVod() {
  104. this.homeVodList = this.vodShortObj["最近更新"]
  105. }
  106. async setCategory(tid, pg, filter, extend) {
  107. this.vodList = this.vodShortObj[tid]
  108. }
  109. async setDetail(id) {
  110. if (id.indexOf("search") > -1) {
  111. let content = await this.fetch(this.apiUrl + id, null, this.getHeader())
  112. let vod_list = await this.parseVodShortListFromDocBySearch(load(content))
  113. id = vod_list[0].vod_id
  114. }
  115. await this.jadeLog.debug(id)
  116. let detailUrl = this.apiUrl + id
  117. let detailContent = await this.fetch(detailUrl, null, this.getHeader())
  118. this.vodDetail = await this.parseVodDetailFromDoc(load(detailContent))
  119. }
  120. async setSearch(wd, quick) {
  121. let searchUrl = this.apiUrl + `search?word=${wd}`
  122. let content = await this.fetch(searchUrl, null, this.getHeader())
  123. this.vodList = await this.parseVodShortListFromDocBySearch(load(content))
  124. }
  125. }
  126. let spider = new CiliDuoSpider()
  127. async function init(cfg) {
  128. await spider.init(cfg)
  129. }
  130. async function home(filter) {
  131. return await spider.home(filter)
  132. }
  133. async function homeVod() {
  134. return await spider.homeVod()
  135. }
  136. async function category(tid, pg, filter, extend) {
  137. return await spider.category(tid, pg, filter, extend)
  138. }
  139. async function detail(id) {
  140. return await spider.detail(id)
  141. }
  142. async function play(flag, id, flags) {
  143. return await spider.play(flag, id, flags)
  144. }
  145. async function search(wd, quick) {
  146. return await spider.search(wd, quick)
  147. }
  148. async function proxy(segments, headers) {
  149. return await spider.proxy(segments, headers)
  150. }
  151. export function __jsEvalReturn() {
  152. return {
  153. init: init,
  154. home: home,
  155. homeVod: homeVod,
  156. category: category,
  157. detail: detail,
  158. play: play,
  159. proxy: proxy,
  160. search: search,
  161. };
  162. }
  163. export {spider}