kankan70.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * @File : kankan70.js
  3. * @Author : jade
  4. * @Date : 2023/12/29 15:33
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc :
  8. */
  9. import * as Utils from "../lib/utils.js";
  10. import {_, load} from "../lib/cat.js";
  11. import {VodDetail, VodShort} from "../lib/vod.js";
  12. import {Spider} from "./spider.js";
  13. function get_qp_name44(qp_type) {
  14. if (qp_type === 'zd') return '最大';
  15. if (qp_type === 'yj') return '永久';
  16. if (qp_type === 'hn') return '牛牛';
  17. if (qp_type === 'gs') return '光波';
  18. if (qp_type === 'sn') return '新朗';
  19. if (qp_type === 'wl') return '涡轮';
  20. if (qp_type === 'lz') return '良子';
  21. if (qp_type === 'fs') return 'F速';
  22. if (qp_type === 'ff') return '飞飞';
  23. if (qp_type === 'bd') return '百度';
  24. if (qp_type === 'uk') return '酷U';
  25. if (qp_type === 'wj') return '无天';
  26. if (qp_type === 'bj') return '八戒';
  27. if (qp_type === 'tk') return '天空';
  28. if (qp_type === 'ss') return '速速';
  29. if (qp_type === 'kb') return '酷播';
  30. if (qp_type === 'sd') return '闪电';
  31. if (qp_type === 'xk') return '看看';
  32. if (qp_type === 'tp') return '淘淘';
  33. if (qp_type === 'jy') return '精英';
  34. return qp_type;
  35. }
  36. class Kankan70Spider extends Spider {
  37. constructor() {
  38. super();
  39. this.siteUrl = "http://cqdb6.com";
  40. }
  41. getName() {
  42. return "📺┃70看看┃📺"
  43. }
  44. getAppName() {
  45. return "70看看"
  46. }
  47. getJSName() {
  48. return "kankan70"
  49. }
  50. getType() {
  51. return 3
  52. }
  53. paraseUrlObject(js_str) {
  54. let content_list = js_str.split(";")
  55. let urlObject = {}
  56. let js_name = ""
  57. let play_id = 0
  58. let pldy_id = 0
  59. let js_key = ""
  60. for (let i = 0; i < content_list.length; i++) {
  61. let content = content_list[i]
  62. if (content.indexOf("var lianzaijs") > -1) {
  63. js_name = content.split("=")[0].split(" ")[1]
  64. js_key = js_name.split("_")[1]
  65. } else if (content.indexOf("pl_id=") > -1) {
  66. play_id = content.split("=")[1]
  67. urlObject[js_name] = {"play_id": play_id, "list": [], "pl_dy": pldy_id}
  68. } else if (content.indexOf("var pl_dy") > -1) {
  69. pldy_id = content.split("=")[1]
  70. }
  71. if (content.indexOf(`playarr_${js_key}[`) > -1) {
  72. let play_url = content.split("=\"")[1].split(",")[0]
  73. urlObject[js_name]["list"].push(play_url)
  74. }
  75. }
  76. let play_url_list = [], play_format_list = [];
  77. for (const key of Object.keys(urlObject)) {
  78. if (key.indexOf("_") > -1) {
  79. let play_format_name = get_qp_name44(key.split("_")[1])
  80. play_format_list.push(play_format_name)
  81. let vodItems = []
  82. let index = 0
  83. for (const play_url of urlObject[key]["list"]) {
  84. index = index + 1
  85. vodItems.push("第" + index.toString() + "集" + "$" + play_url)
  86. }
  87. play_url_list.push(vodItems.join("#"))
  88. }
  89. }
  90. return {"play_format": play_format_list.join("$$$"), "play_url": play_url_list.join("$$$")}
  91. }
  92. async parseVodShortListFromDoc($) {
  93. let vod_list = []
  94. let vod_elements = $("a.li-hv")
  95. for (const vod_element of vod_elements) {
  96. let vodShort = new VodShort()
  97. vodShort.vod_id = "/" + vod_element.attribs["href"]
  98. vodShort.vod_name = vod_element.attribs["title"]
  99. vodShort.vod_pic = $(vod_element).find("img")[0].attribs["data-original"]
  100. let remarkEle = $(vod_element).find("p.bz")[0]
  101. if (remarkEle.length > 0) {
  102. vodShort.vod_remarks = remarkEle.children[0].data
  103. }
  104. vod_list.push(vodShort)
  105. }
  106. return vod_list
  107. }
  108. async parseVodDetailFromDoc($) {
  109. let vodDetail = new VodDetail()
  110. let infoElement = $("[class=info]")
  111. let dtElement = $(infoElement).find("dt.name")[0]
  112. vodDetail.vod_name = dtElement.children[0].data
  113. vodDetail.vod_remarks = dtElement.children[1].children[0].data
  114. let ddString = $(infoElement).find("dd").text()
  115. vodDetail.vod_area = Utils.getStrByRegex(/地区:(.*?) /, ddString)
  116. vodDetail.vod_year = Utils.getStrByRegex(/年代:(.*?)\n/, ddString)
  117. vodDetail.type_name = Utils.getStrByRegex(/类型:(.*?)\n/, ddString)
  118. vodDetail.vod_content = $(infoElement).find("[class=des2]").text().replaceAll("\n", "").replaceAll("剧情:", "")
  119. vodDetail.vod_pic = $("img.lazy")[0].attribs["data-original"]
  120. return vodDetail
  121. }
  122. async parseVodShortListFromJson(obj) {
  123. let vod_list = []
  124. for (const vod_object of obj) {
  125. let vodShort = new VodShort()
  126. vodShort.vod_id = vod_object["url"]
  127. vodShort.vod_pic = vod_object["thumb"]
  128. vodShort.vod_remarks = vod_object["time"]
  129. vodShort.vod_name = vod_object["title"]
  130. vod_list.push(vodShort)
  131. }
  132. return vod_list
  133. }
  134. async setClasses() {
  135. let html = await this.fetch(this.siteUrl, null, this.getHeader())
  136. if (!_.isEmpty(html)) {
  137. let $ = load(html)
  138. let elements = $("[class=index-list-l]")
  139. for (const element of elements) {
  140. let typeElement = $($(element).find("[class=\"h1 clearfix\"]")[0]).find("a")
  141. let type_id = typeElement[0].attribs["href"]
  142. let type_name = $(typeElement[1]).text()
  143. if (!_.isEmpty(type_name)) {
  144. this.classes.push({"type_id": type_id, "type_name": type_name})
  145. }
  146. }
  147. }
  148. }
  149. async getFilter(type_id) {
  150. let url = this.siteUrl + type_id
  151. let html = await this.fetch(url, null, this.getHeader())
  152. let extend_list = []
  153. if (!_.isEmpty(html)) {
  154. let $ = load(html)
  155. let elements = $("[class=\"sy scon clearfix\"]").find("dl")
  156. let i = 0
  157. for (const element of elements) {
  158. let type_name = $($(element).find("dt")).text().replace("按", "").replace(":", "")
  159. let extend_dic = {
  160. "key": (i + 1).toString(), "name": type_name, "value": []
  161. }
  162. let type_elements = $(element).find("a")
  163. let index = 0
  164. if (type_name === "剧情") {
  165. index = 3
  166. } else if (type_name === "年代") {
  167. index = 2
  168. } else if (type_name === "地区") {
  169. index = 4
  170. }
  171. for (const type_element of type_elements) {
  172. let type_id_list = type_element.attribs["href"].split("/")
  173. extend_dic["value"].push({"n": $(type_element).text(), "v": type_id_list[index]})
  174. }
  175. extend_list.push(extend_dic)
  176. i = i + 1
  177. }
  178. }
  179. return extend_list
  180. }
  181. async setFilterObj() {
  182. for (const class_dic of this.classes) {
  183. let type_id = class_dic["type_id"]
  184. if (type_id !== "最近更新") {
  185. this.filterObj[type_id] = await this.getFilter(type_id)
  186. }
  187. }
  188. }
  189. async setHomeVod() {
  190. let html = await this.fetch(this.siteUrl, null, this.getHeader())
  191. if (!_.isEmpty(html)) {
  192. let $ = load(html)
  193. this.homeVodList = await this.parseVodShortListFromDoc($)
  194. }
  195. }
  196. async setCategory(tid, pg, filter, extend) {
  197. let url = this.siteUrl + tid
  198. let html = await this.fetch(url, null, this.getHeader())
  199. if (!_.isEmpty(html)) {
  200. let class_name = tid.split("/")[1]
  201. let id = tid.split("/")[2]
  202. let api_str = Utils.getStrByRegex(/var _yu_gda_s="(.*?)";/, html)
  203. let params = {
  204. "action": class_name,
  205. "page": parseInt(pg),
  206. "year": extend["2"] ?? "0",
  207. "area": extend["3"] ?? "all",
  208. "class": extend["1"] ?? "0",
  209. "dect": "",
  210. "id": id
  211. }
  212. let cate_html = await this.fetch(api_str, params, this.getHeader())
  213. if (cate_html !== null) {
  214. let $ = load(cate_html)
  215. this.vodList = await this.parseVodShortListFromDoc($)
  216. }
  217. }
  218. }
  219. async setDetail(id) {
  220. let detailUrl = this.siteUrl + id
  221. let html = await this.fetch(detailUrl, null, this.getHeader())
  222. if (!_.isEmpty(html)) {
  223. let $ = load(html)
  224. this.vodDetail = await this.parseVodDetailFromDoc($)
  225. let mather = /<script type="text\/javascript" src="http:\/\/test.gqyy8.com:8077\/ne2(.*?)"><\/script>/g.exec(html)
  226. let js_url = "http://test.gqyy8.com:8077/ne2" + mather[1]
  227. let js_str = await this.fetch(js_url, null, this.getHeader())
  228. if (!_.isEmpty(js_str)) {
  229. let playObject = this.paraseUrlObject(js_str)
  230. this.vodDetail.vod_play_url = playObject["play_url"]
  231. this.vodDetail.vod_play_from = playObject["play_format"]
  232. }
  233. }
  234. }
  235. async setSearch(wd, quick) {
  236. let url = this.siteUrl + "/search.php"
  237. let html = await this.fetch(url, null, this.getHeader())
  238. if (!_.isEmpty(html)) {
  239. let params = {
  240. "top": 10, "q": wd,
  241. }
  242. let api_url = Utils.getStrByRegex(/var my_search='(.*?)';/, html)
  243. let content = await this.fetch(api_url, params, this.getHeader())
  244. if (!_.isEmpty(content)) {
  245. let content_json = JSON.parse(content.replaceAll("",""))
  246. this.vodList = await this.parseVodShortListFromJson(content_json)
  247. }
  248. }
  249. }
  250. }
  251. let spider = new Kankan70Spider()
  252. async function init(cfg) {
  253. await spider.init(cfg)
  254. }
  255. async function home(filter) {
  256. return await spider.home(filter)
  257. }
  258. async function homeVod() {
  259. return await spider.homeVod()
  260. }
  261. async function category(tid, pg, filter, extend) {
  262. return await spider.category(tid, pg, filter, extend)
  263. }
  264. async function detail(id) {
  265. return await spider.detail(id)
  266. }
  267. async function play(flag, id, flags) {
  268. return await spider.play(flag, id, flags)
  269. }
  270. async function search(wd, quick) {
  271. return await spider.search(wd, quick)
  272. }
  273. export function __jsEvalReturn() {
  274. return {
  275. init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
  276. };
  277. }
  278. export {spider}