sehuatang.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*
  2. * @File : sehuatang
  3. * @Author : jade
  4. * @Date : 2024/1/24 16:47
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc : 色花堂BT
  8. */
  9. import * as Utils from "../lib/utils.js";
  10. import {Spider} from "./spider.js";
  11. import {VodDetail, VodShort} from "../lib/vod.js";
  12. import {_} from "../lib/cat.js";
  13. class SHTSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.siteUrl = "https://www.sehuatang.net"
  17. }
  18. getAppName() {
  19. return "色花堂BT"
  20. }
  21. getName() {
  22. return "🔞┃色花堂BT┃🔞"
  23. }
  24. getJSName() {
  25. return "sehuatang"
  26. }
  27. getType() {
  28. return 3
  29. }
  30. async init(cfg) {
  31. await super.init(cfg);
  32. this.jsBaseDetail = await js2Proxy(true, this.siteType, this.siteKey, 'detail/', {});
  33. }
  34. getHeader() {
  35. return {
  36. "User-Agent": "PostmanRuntime/7.36.1",
  37. "Host": "www.sehuatang.net",
  38. "Cookie": "cPNj_2132_saltkey=Q4BKEOEC; cf_clearance=6Gz2tvOXPkkJP2UhLnSsN4s0RrnDUy0jBN0kUvC5FNQ-1706109144-1-AebvwBnAURwWWQhj0QRBrRPku2n8xI73PIeuZVj2ckqY9zjQ7zFzDviX7Gkex1P1bUw9SXHGEYnkBB9nmWe6Nhk=; _safe=vqd37pjm4p5uodq339yzk6b7jdt6oich",
  39. }
  40. }
  41. async parseVodShortListFromDoc($) {
  42. let vod_list = []
  43. let vodShortElements = $("[id=\"portal_block_43_content\"]").find("li")
  44. for (const vodShortElement of vodShortElements) {
  45. let vodShort = new VodShort()
  46. vodShort.vod_remarks = $($(vodShortElement).find("a")[1]).text()
  47. vodShort.vod_id = $(vodShortElement).find("a")[2].attribs["href"]
  48. vodShort.vod_name = $(vodShortElement).find("a")[2].attribs["title"]
  49. vodShort.vod_pic = this.jsBaseDetail + Utils.base64Encode(vodShort.vod_id)
  50. vod_list.push(vodShort)
  51. }
  52. return vod_list
  53. }
  54. async parseVodShortListFromDocByCategory($) {
  55. let vod_list = []
  56. let vodElements = $($("[class=\"bm_c\"]")[0]).find("tbody")
  57. for (const vodElement of vodElements) {
  58. let user_name = $($($(vodElement).find("cite")).find("a")[0]).text()
  59. if (user_name !== "admin" && user_name !== undefined && !_.isEmpty(user_name)) {
  60. let vodShort = new VodShort()
  61. vodShort.vod_id = $(vodElement).find("a")[0].attribs["href"]
  62. vodShort.vod_remarks = $($(vodElement).find("a")[2]).text()
  63. vodShort.vod_name = $($(vodElement).find("a")[3]).text()
  64. vodShort.vod_pic = this.jsBaseDetail + Utils.base64Encode(vodShort.vod_id)
  65. vod_list.push(vodShort)
  66. }
  67. }
  68. return vod_list
  69. }
  70. async parseVodDetailFromDoc($) {
  71. let vodDetail = new VodDetail();
  72. let vodElement = $("[class=\"t_f\"]")[0]
  73. let content = $(vodElement).text().replaceAll(":", ":").replaceAll("【", "").replaceAll("】", "")
  74. vodDetail.vod_pic = $(vodElement).find("img")[0].attribs["file"]
  75. vodDetail.vod_name = Utils.getStrByRegex(/影片名称(.*?)\n/, content).replaceAll(":", "").replaceAll("\n", "")
  76. vodDetail.vod_actor = Utils.getStrByRegex(/出演女优(.*?)\n/, content).replaceAll(":", "").replaceAll("\n", "")
  77. vodDetail.vod_remarks = Utils.getStrByRegex(/是否有码(.*?)\n/, content).replaceAll(":", "").replaceAll("\n", "")
  78. vodDetail.vod_play_from = "BT"
  79. vodDetail.vod_play_url = vodDetail.vod_name + "$" + Utils.getStrByRegex(/磁力链接: (.*)复制代码/, content)
  80. return vodDetail
  81. }
  82. async setClasses() {
  83. let $ = await this.getHtml()
  84. let tagElements = $("[id=\"category_1\"]").find("tr").slice(0, -1)
  85. for (const tagElement of tagElements) {
  86. let classElements = $($(tagElement).find("[class=\"fl_icn_g\"]")).find("a")
  87. for (const classElement of classElements) {
  88. let type_id = classElement.attribs["href"]
  89. let type_name = $(classElement).find("img")[0].attribs["alt"]
  90. this.classes.push(this.getTypeDic(type_name, type_id))
  91. }
  92. }
  93. }
  94. async getFilter($) {
  95. let extend_list = []
  96. let extend_dic1 = {"key": 1, "name": "类型", "value": []}
  97. let typeElements = $("[id=\"thread_types\"]").find("a")
  98. for (const typeElement of typeElements){
  99. let type_name = ""
  100. if (typeElement.children.length > 1){
  101. type_name = typeElement.children[0].data + ":" + $(typeElement.children[1]).text()
  102. }else{
  103. type_name = typeElement.children[0].data
  104. }
  105. extend_dic1["value"].push({"n":type_name,"v":typeElement.attribs["href"]})
  106. }
  107. extend_list.push(extend_dic1)
  108. let extend_dic2 = {"key": 1, "name": "主题", "value": []}
  109. let themeElements = $("[class=\"tf\"]").find("a")
  110. for (const themeElement of themeElements){
  111. let type_name = $(themeElement).text()
  112. if (type_name !== "更多" && type_name !== "显示置顶"){
  113. extend_dic2["value"].push({"n":$(themeElement).text(),"v":themeElement.attribs["href"]})
  114. }
  115. }
  116. extend_list.push(extend_dic2)
  117. return extend_list
  118. }
  119. async setFilterObj() {
  120. for (const class_dic of this.classes){
  121. let type_name = class_dic["type_name"]
  122. let type_id = class_dic["type_id"]
  123. if (type_name !== "最近更新"){
  124. let $ = await this.getHtml(this.siteUrl + '/' + type_id)
  125. this.filterObj[type_id] = await this.getFilter($)
  126. }
  127. }
  128. }
  129. async setHomeVod() {
  130. let $ = await this.getHtml()
  131. this.homeVodList = await this.parseVodShortListFromDoc($)
  132. }
  133. async setCategory(tid, pg, filter, extend) {
  134. if (extend["1"]!==undefined && extend[1] ==="javascript:;"){
  135. }else{
  136. tid = extend["1"] ?? tid
  137. }
  138. let cateUrl
  139. let tid_list = tid.split(".")[0].split("-")
  140. if (tid_list.length > 2){
  141. tid_list[2] = pg
  142. cateUrl = this.siteUrl + "/" + tid_list.join("-") + ".html"
  143. }else{
  144. cateUrl = this.siteUrl + "/" + tid + "&page=" + pg
  145. }
  146. let $ = await this.getHtml(cateUrl)
  147. this.vodList = await this.parseVodShortListFromDocByCategory($)
  148. }
  149. async setDetail(id) {
  150. let $ = await this.getHtml(this.siteUrl + "/" + id)
  151. this.vodDetail = await this.parseVodDetailFromDoc($)
  152. }
  153. async proxy(segments, headers) {
  154. await this.jadeLog.debug(`正在设置反向代理 segments = ${segments.join(",")},headers = ${JSON.stringify(headers)}`)
  155. let what = segments[0];
  156. let url = Utils.base64Decode(segments[1]);
  157. if (what === 'detail') {
  158. await this.jadeLog.debug(`反向代理ID为:${url}`)
  159. let $ = await this.getHtml(this.siteUrl + "/" + url)
  160. let vodDetail = await this.parseVodDetailFromDoc($)
  161. await this.jadeLog.debug(`图片地址为:${vodDetail.vod_pic}`)
  162. let resp;
  163. if (!_.isEmpty(headers)) {
  164. resp = await req(vodDetail.vod_pic, {
  165. buffer: 2, headers: headers
  166. });
  167. } else {
  168. resp = await req(vodDetail.vod_pic, {
  169. buffer: 2, headers: {
  170. Referer: url, 'User-Agent': Utils.CHROME,
  171. },
  172. });
  173. }
  174. return JSON.stringify({
  175. code: resp.code, buffer: 2, content: resp.content, headers: resp.headers,
  176. });
  177. }
  178. return JSON.stringify({
  179. code: 500, content: '',
  180. });
  181. }
  182. }
  183. let spider = new SHTSpider()
  184. async function init(cfg) {
  185. await spider.init(cfg)
  186. }
  187. async function home(filter) {
  188. return await spider.home(filter)
  189. }
  190. async function homeVod() {
  191. return await spider.homeVod()
  192. }
  193. async function category(tid, pg, filter, extend) {
  194. return await spider.category(tid, pg, filter, extend)
  195. }
  196. async function detail(id) {
  197. return await spider.detail(id)
  198. }
  199. async function play(flag, id, flags) {
  200. return await spider.play(flag, id, flags)
  201. }
  202. async function search(wd, quick) {
  203. return await spider.search(wd, quick)
  204. }
  205. async function proxy(segments, headers) {
  206. return await spider.proxy(segments, headers)
  207. }
  208. export function __jsEvalReturn() {
  209. return {
  210. init: init,
  211. home: home,
  212. homeVod: homeVod,
  213. category: category,
  214. detail: detail,
  215. play: play,
  216. search: search,
  217. proxy: proxy
  218. };
  219. }
  220. export {spider}