yiqikan.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * @File : yiqikan.js
  3. * @Author : jade
  4. * @Date : 2024/3/19 18:45
  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. class YiQiKanSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.siteUrl = "https://api.gquaxhce.com"
  17. this.nextObj = {}
  18. }
  19. async init(cfg) {
  20. await super.init(cfg);
  21. this.danmuStaus = true;
  22. }
  23. getRequestId() {
  24. let strArr = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
  25. let sb = "";
  26. for (let i = 0; i < 32; i++) {
  27. sb = sb + strArr[_.random(0, strArr.length)];
  28. }
  29. return sb.toString();
  30. }
  31. getName() {
  32. return `🛫┃一起看┃🛫`
  33. }
  34. getAppName() {
  35. return "一起看"
  36. }
  37. getJSName() {
  38. return "yiqikan"
  39. }
  40. getType() {
  41. return 3
  42. }
  43. getHeader() {
  44. let headers = super.getHeader();
  45. headers["Connection"] = "keep-alive"
  46. headers["Host"] = "api.gquaxhce.com"
  47. return headers
  48. }
  49. getParams(ob_params = null) {
  50. let requestId = this.getRequestId()
  51. let appid = "e6ddefe09e0349739874563459f56c54"
  52. let reqDomain = "m.yqktv888.com"
  53. let udid = Utils.getUUID();
  54. let appKey = "3359de478f8d45638125e446a10ec541"
  55. let params = {"appId": appid}
  56. if (!_.isEmpty(ob_params)) {
  57. for (const ob_key of Object.keys(ob_params)) {
  58. if (!_.isEmpty(ob_params[ob_key]) && (ob_key === "epId" || ob_key === "nextCount" || ob_key === "nextVal" || ob_key === "queryValueJson" || ob_key === "keyword")) {
  59. params[ob_key] = ob_params[ob_key]
  60. }
  61. }
  62. }
  63. params["reqDomain"] = reqDomain
  64. params["requestId"] = requestId
  65. params["udid"] = udid
  66. if (!_.isEmpty(ob_params)) {
  67. for (const ob_key of Object.keys(ob_params)) {
  68. if (!_.isEmpty(ob_params[ob_key]) && (ob_key === "vodId" || ob_key === "vodResolution")) {
  69. params[ob_key] = ob_params[ob_key]
  70. }
  71. }
  72. }
  73. params["appKey"] = appKey
  74. params["sign"] = md5X(Utils.objectToStr(params))
  75. delete params["appKey"]
  76. return params
  77. }
  78. async setClasses() {
  79. let response = JSON.parse(await this.post(this.siteUrl + "/v1/api/home/header", this.getParams(), this.getHeader(), "raw"))
  80. for (const data of response["data"]["channelList"]) {
  81. this.classes.push(this.getTypeDic(data["channelName"], data["channelId"]))
  82. }
  83. }
  84. async parseVodShortListFromJson(obj) {
  85. let vod_list = []
  86. for (const data of obj) {
  87. let vodShort = new VodShort()
  88. vodShort.vod_id = data["vodId"]
  89. vodShort.vod_name = data["vodName"]
  90. vodShort.vod_remarks = data["watchingCountDesc"]
  91. vodShort.vod_pic = data["coverImg"]
  92. vod_list.push(vodShort)
  93. }
  94. return vod_list
  95. }
  96. async parseVodDetailfromJson(obj) {
  97. let vodDetail = new VodDetail()
  98. vodDetail.vod_name = obj["vodName"]
  99. vodDetail.vod_content = obj["intro"]
  100. vodDetail.vod_area = obj["areaName"]
  101. vodDetail.vod_year = obj["year"]
  102. vodDetail.type_name = obj["channelName"]
  103. vodDetail.vod_remarks = "评分:" + obj["score"].toString()
  104. vodDetail.vod_pic = obj["coverImg"]
  105. vodDetail.vod_actor = Utils.objToList(obj["actorList"], "vodWorkerName")
  106. vodDetail.vod_director = Utils.objToList(obj["directorList"], "vodWorkerName")
  107. let playlist = {}
  108. for (const playDic of obj["playerList"]) {
  109. let vodItems = []
  110. for (const item of playDic["epList"]) {
  111. let playId = item["epId"]
  112. let playName = item["epName"]
  113. vodItems.push(playName + "$" + playId)
  114. }
  115. playlist[playDic["playerName"]] = vodItems.join("#")
  116. }
  117. vodDetail.vod_play_url = _.values(playlist).join('$$$');
  118. vodDetail.vod_play_from = _.keys(playlist).join('$$$');
  119. return vodDetail
  120. }
  121. async setHomeVod() {
  122. let response = await this.post(this.siteUrl + "/v1/api/home/body", this.getParams(), this.getHeader(), "raw")
  123. let resJson = JSON.parse(response)
  124. if (resJson["result"]) {
  125. this.homeVodList = await this.parseVodShortListFromJson(resJson["data"]["hotVodList"])
  126. } else {
  127. await this.jadeLog.error(`获取首页失败,失败原因为:${resJson["msg"]}`)
  128. }
  129. }
  130. async setCategory(tid, pg, filter, extend) {
  131. let url = this.siteUrl + "/v1/api/search/queryNow"
  132. this.limit = 18
  133. let ob_params = {}
  134. if (!_.isEmpty(this.nextObj[tid])) {
  135. ob_params["nextVal"] = this.nextObj[tid]
  136. }
  137. ob_params["nextCount"] = 18
  138. ob_params["queryValueJson"] = JSON.stringify([{
  139. "filerName": "channelId", "filerValue": tid.toString()
  140. }]).replaceAll("\\\\", "")
  141. let response = await this.post(url, this.getParams(ob_params), this.getHeader(), "raw")
  142. let resJson = JSON.parse(response)
  143. if (resJson["result"]) {
  144. if (resJson["data"]["hasNext"]) {
  145. this.nextObj[tid] = resJson["data"]["nextVal"]
  146. }
  147. this.vodList = await this.parseVodShortListFromJson(resJson["data"]["items"])
  148. } else {
  149. await this.jadeLog.error(`获取分类失败,失败原因为:${resJson["msg"]}`)
  150. }
  151. }
  152. async setDetail(id) {
  153. let url = this.siteUrl + "/v1/api/vodInfo/detail"
  154. let ob_params = {"vodId": id}
  155. let response = await this.post(url, this.getParams(ob_params), this.getHeader(), "raw")
  156. let resJson = JSON.parse(response)
  157. if (resJson["result"]) {
  158. this.vodDetail = await this.parseVodDetailfromJson(resJson["data"])
  159. } else {
  160. await this.jadeLog.error(`获取详情失败,失败原因为:${resJson["msg"]}`)
  161. }
  162. }
  163. async setPlay(flag, id, flags) {
  164. let url = this.siteUrl + "/v1/api/vodInfo/getEpDetail"
  165. let ob_params = {"epId": id}
  166. let ep_detail_response = await this.post(url, this.getParams(ob_params), this.getHeader(), "raw")
  167. let ep_detail_resJson = JSON.parse(ep_detail_response)
  168. let vodResolution = "1";
  169. if (ep_detail_resJson["result"]) {
  170. if (ep_detail_resJson["data"]["resolutionItems"].length > 0) {
  171. vodResolution = ep_detail_resJson["data"]["resolutionItems"].slice(-1)[0]["vodResolution"].toString()
  172. let playUrl = this.siteUrl + "/v1/api/vodInfo/getPlayUrl"
  173. let play_params = {"epId": id, "vodResolution": vodResolution}
  174. let play_response = await this.post(playUrl, this.getParams(play_params), this.getHeader(), "raw")
  175. let play_resJson = JSON.parse(play_response)
  176. if (play_resJson["result"]) {
  177. this.playUrl = play_resJson["data"]
  178. }else{
  179. await this.jadeLog.error(`获取播放链接失败,失败原因为:${ep_detail_resJson["msg"]}`)
  180. }
  181. }
  182. } else {
  183. await this.jadeLog.error(`获取播放详情失败,失败原因为:${ep_detail_resJson["msg"]}`)
  184. }
  185. }
  186. async setSearch(wd, quick) {
  187. let url = this.siteUrl + "/v1/api/search/search"
  188. let ob_prams = {"nextCount":15,"nextVal":"","keyword":wd}
  189. let esponse = await this.post(url, this.getParams(ob_prams), this.getHeader(), "raw")
  190. let resJson = JSON.parse(esponse)
  191. if (resJson["result"]) {
  192. this.vodList = await this.parseVodShortListFromJson(resJson["data"]["items"])
  193. } else {
  194. await this.jadeLog.error(`获取详情失败,失败原因为:${resJson["msg"]}`)
  195. }
  196. }
  197. }
  198. let spider = new YiQiKanSpider()
  199. async function init(cfg) {
  200. await spider.init(cfg)
  201. }
  202. async function home(filter) {
  203. return await spider.home(filter)
  204. }
  205. async function homeVod() {
  206. return await spider.homeVod()
  207. }
  208. async function category(tid, pg, filter, extend) {
  209. return await spider.category(tid, pg, filter, extend)
  210. }
  211. async function detail(id) {
  212. return await spider.detail(id)
  213. }
  214. async function play(flag, id, flags) {
  215. return await spider.play(flag, id, flags)
  216. }
  217. async function search(wd, quick) {
  218. return await spider.search(wd, quick)
  219. }
  220. async function proxy(segments, headers) {
  221. return await spider.proxy(segments, headers)
  222. }
  223. export function __jsEvalReturn() {
  224. return {
  225. init: init,
  226. home: home,
  227. homeVod: homeVod,
  228. category: category,
  229. detail: detail,
  230. play: play,
  231. search: search,
  232. proxy: proxy
  233. };
  234. }
  235. export {spider}