cilixiong.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * @File : cilixiong.js
  3. * @Author : jade
  4. * @Date : 2024/4/13 14:52
  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 CiliXiongSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.siteUrl = "https://www.cilixiong.com"
  17. this.cateObj = {"/movie/": "1", "/drama/": "2"}
  18. }
  19. getAppName() {
  20. return "磁力熊"
  21. }
  22. getName() {
  23. return "🐻┃磁力熊┃🐻"
  24. }
  25. getJSName() {
  26. return "cilixiong"
  27. }
  28. getType() {
  29. return 3
  30. }
  31. async setClasses() {
  32. let $ = await this.getHtml()
  33. let navElements = $("[class=\"nav col-12 col-lg-auto me-lg-auto mb-2 justify-content-center mb-md-0\"]").find("li")
  34. for (const navElement of navElements) {
  35. let element = $(navElement).find("a")[0]
  36. let type_name = $(element).text()
  37. let type_id = element.attribs.href
  38. if (type_name !== "首页" && type_name !== "榜单" && type_name !== "留言") {
  39. this.classes.push(this.getTypeDic(type_name, type_id))
  40. }
  41. }
  42. }
  43. async getFilter($) {
  44. let extend_list = []
  45. let filerElements = $("[class=\"nav small\"]")
  46. let i = 1
  47. for (const filetElement of filerElements) {
  48. let extend_name = $($(filetElement).find("li")[0]).text().replaceAll(":", "")
  49. let extend_dic = {"key": (i).toString(), "name": extend_name, "value": []}
  50. for (const typeElement of $(filetElement).find("li").slice(1)) {
  51. let element = $(typeElement).find("a")[0]
  52. let type_id = element.attribs.href.split("-")[i]
  53. extend_dic["value"].push({"n": $(element).text(), "v": type_id})
  54. }
  55. i = i + 1
  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 $ = await this.getHtml(this.siteUrl + type_id)
  65. this.filterObj[type_id] = await this.getFilter($)
  66. }
  67. }
  68. }
  69. async parseVodShortListFromDoc($) {
  70. let vod_list = []
  71. let vodElements = $("[class=\"col\"]")
  72. for (const vodElement of vodElements) {
  73. let vodShort = new VodShort()
  74. vodShort.vod_id = $(vodElement).find("a")[0].attribs.href
  75. vodShort.vod_pic = Utils.getStrByRegex(/background-image: url\('(.*?)'\)/, $(vodElement).find("[class=\"card-img\"]")[0].attribs["style"])
  76. vodShort.vod_name = $($(vodElement).find("h2")).text()
  77. let remarks = $($(vodElement).find("[class=\"rank bg-success p-1\"]")).text()
  78. vodShort.vod_remarks = "评分:" + remarks
  79. if (remarks !== "AD") {
  80. vod_list.push(vodShort)
  81. }
  82. }
  83. return vod_list
  84. }
  85. async parseVodShortListFromDocBySearch($) {
  86. let vod_list = []
  87. let vodElements = $("[class=\"card card-cover h-100 overflow-hidden text-bg-dark rounded-4 shadow-lg position-relative\"]")
  88. for (const vodElement of vodElements){
  89. let vodShort= new VodShort()
  90. vodShort.vod_id = $(vodElement).find("a")[0].attribs.href
  91. vodShort.vod_name = $($(vodElement).find("[class=\"pt-5 lh-1 pb-2 h4\"]")).text()
  92. vodShort.vod_pic = Utils.getStrByRegex(/background-image: url\('(.*?)'\)/,$(vodElement).find("[class=\"card-img\"]")[0].attribs.style)
  93. vodShort.vod_remarks = "评分:" + $($(vodElement).find("[class=\"rank bg-success p-1\"]")).text()
  94. vod_list.push(vodShort)
  95. }
  96. return vod_list
  97. }
  98. async parseVodDetailFromDoc($) {
  99. let vodDetail = new VodDetail()
  100. let vodDetailElement = $("[class=\"row row-cols-1 row-cols-lg-3 align-items-stretch g-4 p-5 text-white\"]")
  101. vodDetail.vod_pic = $(vodDetailElement).find("img")[0].attribs.src
  102. vodDetail.vod_name = $($(vodDetailElement).find("h1")).text()
  103. let vodContentElements = $(vodDetailElement).find("[class=\"mb-2\"]").slice(1)
  104. for (const contentElement of vodContentElements) {
  105. let name = $(contentElement).text()
  106. if (name.indexOf("豆瓣评分") > -1) {
  107. vodDetail.vod_remarks = name
  108. }
  109. if (name.indexOf("类型") > -1) {
  110. vodDetail.type_name = name.replaceAll(":", "").replace("类型", "").replaceAll(":", "")
  111. }
  112. if (name.indexOf("上映地区") > -1) {
  113. vodDetail.vod_area = name.replaceAll(":", "").replace("上映地区", "").replaceAll(":", "")
  114. }
  115. if (name.indexOf("主演") > -1) {
  116. vodDetail.vod_actor = name.replaceAll(":", "").replace("主演", "").replaceAll(":", "")
  117. }
  118. if (name.indexOf("上映日期") > -1){
  119. vodDetail.vod_year = name.replaceAll(":", "").replace("上映日期", "").replaceAll(":", "")
  120. }
  121. }
  122. vodDetail.vod_content = $($(vodDetailElement).find("[class=\"mv_card_box\"]")).text()
  123. let playerMap = {}
  124. let emebedVideoElements = $("[class=\"row col-md-12 embed_video\"]")
  125. let index = 1
  126. for (const emebedVideoElement of emebedVideoElements){
  127. let vodItems = []
  128. let playUrl = $($(emebedVideoElement).find("iframe"))[0].attribs["src"]
  129. vodItems.push("播放" + "$" + playUrl);
  130. playerMap["在线播放" + index.toString()+ "第一集在线播放预览"] = vodItems.join("#")
  131. index = index + 1
  132. }
  133. let mangetIndex = 1
  134. let mangetElements = $("[class=\"row col-md-12 text-white p-3 pt-1\"]").find("[class=\"container\"]")
  135. for (const mangenment of mangetElements){
  136. let vodItems = []
  137. let playElement = $($(mangenment).find("a"))[0]
  138. let playUrl = playElement.attribs.href
  139. let playName = $(playElement).text()
  140. if (playUrl.startsWith("magnet")){
  141. vodItems.push(playName + "$" + playUrl);
  142. }
  143. if (vodItems.length > 0){
  144. playerMap["磁力链接" + "-" + mangetIndex] = vodItems.join("#")
  145. mangetIndex = mangetIndex + 1
  146. }
  147. }
  148. vodDetail.vod_play_from = Object.keys(playerMap).join("$$$");
  149. vodDetail.vod_play_url = Object.values(playerMap).join("$$$");
  150. return vodDetail
  151. }
  152. async setHomeVod() {
  153. let $ = await this.getHtml()
  154. this.homeVodList = await this.parseVodShortListFromDoc($)
  155. }
  156. async setCategory(tid, pg, filter, extend) {
  157. let type = extend["1"] ?? "0"
  158. let area = extend["2"] ?? "0"
  159. let page = parseInt(pg) - 1
  160. let url = this.siteUrl + "/" + this.cateObj[tid] + `-${type}-${area}-${page}.html`
  161. await this.jadeLog.debug(`分类URL:${url}`)
  162. let $ = await this.getHtml(url)
  163. this.vodList = await this.parseVodShortListFromDoc($)
  164. }
  165. async setDetail(id) {
  166. let $ = await this.getHtml(this.siteUrl + id)
  167. this.vodDetail = await this.parseVodDetailFromDoc($)
  168. }
  169. async setPlay(flag, id, flags) {
  170. if (flag.indexOf("在线播放") > -1){
  171. let $ = await this.getHtml(this.siteUrl + id)
  172. this.playUrl = Utils.getStrByRegex(/const source = '(.*?)'/,$.html())
  173. }else{
  174. this.playUrl = id
  175. }
  176. }
  177. async setSearch(wd, quick) {
  178. let params = {"classid":"1,2","show":"title","tempid":"1","keyboard":wd}
  179. let response = await this.post(this.siteUrl + "/e/search/index.php",params,this.getHeader())
  180. let $ = load(response)
  181. this.vodList = await this.parseVodShortListFromDocBySearch($)
  182. }
  183. }
  184. let spider = new CiliXiongSpider()
  185. async function init(cfg) {
  186. await spider.init(cfg)
  187. }
  188. async function home(filter) {
  189. return await spider.home(filter)
  190. }
  191. async function homeVod() {
  192. return await spider.homeVod()
  193. }
  194. async function category(tid, pg, filter, extend) {
  195. return await spider.category(tid, pg, filter, extend)
  196. }
  197. async function detail(id) {
  198. return await spider.detail(id)
  199. }
  200. async function play(flag, id, flags) {
  201. return await spider.play(flag, id, flags)
  202. }
  203. async function search(wd, quick) {
  204. return await spider.search(wd, quick)
  205. }
  206. async function proxy(segments, headers) {
  207. return await spider.proxy(segments, headers)
  208. }
  209. export function __jsEvalReturn() {
  210. return {
  211. init: init,
  212. home: home,
  213. homeVod: homeVod,
  214. category: category,
  215. detail: detail,
  216. play: play,
  217. search: search,
  218. proxy: proxy
  219. };
  220. }
  221. export {spider}