nivod_18.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * @File : nivod18.js
  3. * @Author : jade
  4. * @Date : 2023/12/19 14:23
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc :
  8. */
  9. import {getHeader, createSign, desDecrypt, ChannelResponse, getVod} from "../lib/nivid_object.js"
  10. import {VodDetail, VodShort} from "../lib/vod.js";
  11. import {Spider} from "./spider.js";
  12. class Nivod18Spider extends Spider {
  13. constructor() {
  14. super();
  15. this.siteUrl = "https://api.nivodz.com"
  16. }
  17. getName() {
  18. return "🔞┃泥视频18+┃🔞"
  19. }
  20. getAppName() {
  21. return "泥视频18+"
  22. }
  23. getJSName() {
  24. return "nivod_18"
  25. }
  26. getType() {
  27. return 3
  28. }
  29. async setClasses() {
  30. let url = this.siteUrl + "/show/channel/list/WEB/3.2" + await createSign()
  31. let content = desDecrypt(await this.post(url, null, getHeader()))
  32. if (content !== null) {
  33. let channelResponse = new ChannelResponse()
  34. channelResponse.fromJsonString(content, 2)
  35. let filterUrl = this.siteUrl + "/show/filter/condition/WEB/3.2" + await createSign()
  36. let filterContent = desDecrypt(await this.post(filterUrl, null, getHeader()))
  37. if (filterContent !== null) {
  38. channelResponse.setChannelFilters(filterContent)
  39. this.classes = channelResponse.getClassList()
  40. this.filterObj = channelResponse.getFilters()
  41. }
  42. }
  43. }
  44. async parseVodShortListFromJson(obj) {
  45. let vod_list = []
  46. for (const cate_dic of obj) {
  47. for (const row of cate_dic.rows) {
  48. for (const cells of row.cells) {
  49. let vodShort = new VodShort()
  50. vodShort.vod_id = cells.show["showIdCode"]
  51. vodShort.vod_pic = cells.img
  52. vodShort.vod_name = cells.title
  53. vodShort.vod_remarks = this.getVodRemarks(cells.show["hot"], cells.show["playResolutions"])
  54. vod_list.push(vodShort)
  55. }
  56. }
  57. }
  58. return vod_list
  59. }
  60. async parseVodDetailfromJson(vod_dic) {
  61. let vodDetail = new VodDetail()
  62. vodDetail.vod_id = vod_dic["showIdCode"]
  63. vodDetail.vod_name = vod_dic["showTitle"]
  64. vodDetail.vod_remarks = this.getVodRemarks(vod_dic["hot"], vod_dic["playResolutions"])
  65. vodDetail.vod_pic = vod_dic["showImg"]
  66. vodDetail.vod_director = vod_dic["director"]
  67. vodDetail.vod_actor = vod_dic["actors"]
  68. vodDetail.vod_year = vod_dic["postYear"]
  69. vodDetail.vod_content = vod_dic["showDesc"]
  70. vodDetail.type_name = vod_dic["showTypeName"]
  71. vodDetail.vod_area = vod_dic["regionName"]
  72. return vodDetail
  73. }
  74. getVodRemarks(hot, playResolutions) {
  75. let vod_remarks
  76. if (this.catOpenStatus) {
  77. vod_remarks = `清晰度:${playResolutions[0]}`
  78. } else {
  79. vod_remarks = `清晰度:${playResolutions[0]},热度:${(Math.floor(parseInt(hot) / 1000)).toString()}k`
  80. }
  81. return vod_remarks
  82. }
  83. getExtendDic(extend, params) {
  84. if (extend["5"] === undefined) {
  85. delete params.year_range
  86. } else {
  87. if (extend["5"] === "0") {
  88. delete params.year_range
  89. } else {
  90. params.year_range = extend["5"]
  91. }
  92. }
  93. if (extend["1"] !== undefined) {
  94. params.sort_by = extend["1"]
  95. }
  96. if (extend["2"] !== undefined) {
  97. params.show_type_id = extend["2"]
  98. }
  99. if (extend["3"] !== undefined) {
  100. params.region_id = extend["3"]
  101. }
  102. if (extend["4"] !== undefined) {
  103. params.lang_id = extend["4"]
  104. }
  105. return params
  106. }
  107. async setHomeVod() {
  108. let url = this.siteUrl + "/index/mobile/WAP/3.0" + await createSign()
  109. let content = desDecrypt(await this.post(url, null, getHeader()))
  110. if (content !== null) {
  111. let content_json = JSON.parse(content)
  112. let cate_list = content_json.list
  113. for (const cate_dic of cate_list) {
  114. for (const row of cate_dic.rows) {
  115. for (const cells of row.cells) {
  116. let vodShort = new VodShort()
  117. vodShort.vod_id = cells.show["showIdCode"]
  118. vodShort.vod_pic = cells.img
  119. vodShort.vod_name = cells.title
  120. vodShort.vod_remarks = this.getVodRemarks(cells.show["hot"], cells.show["playResolutions"])
  121. this.homeVodList.push(vodShort)
  122. }
  123. }
  124. }
  125. }
  126. }
  127. async setCategory(tid, pg, filter, extend) {
  128. let params = {
  129. "sort_by": "0",
  130. "channel_id": tid.toString(),
  131. "show_type_id": "0",
  132. "region_id": "0",
  133. "lang_id": "0",
  134. "year_range": "2023",
  135. "start": ((parseInt(pg) - 1) * 20).toString()
  136. }
  137. this.limit = 20;
  138. params = this.getExtendDic(extend, params)
  139. let url = this.siteUrl + "/show/filter/WEB/3.2" + await createSign(params)
  140. let content = desDecrypt(await this.post(url, params, getHeader()))
  141. if (content != null) {
  142. let content_json = JSON.parse(content)
  143. for (const vod_dic of content_json["list"]) {
  144. let vodShort = new VodShort()
  145. vodShort.vod_id = vod_dic["showIdCode"]
  146. vodShort.vod_name = vod_dic["showTitle"]
  147. vodShort.vod_pic = vod_dic["showImg"]
  148. vodShort.vod_remarks = this.getVodRemarks(vod_dic["hot"], vod_dic["playResolutions"])
  149. this.vodList.push(vodShort)
  150. }
  151. }
  152. }
  153. async setDetail(id) {
  154. let params = {
  155. "show_id_code": id.toString()
  156. }
  157. let url = this.siteUrl + "/show/detail/WEB/3.2" + await createSign(params)
  158. let content = desDecrypt(await this.post(url, params, getHeader()))
  159. if (content != null) {
  160. let content_json = JSON.parse(content)
  161. let vod_dic = content_json["entity"]
  162. this.vodDetail = await this.parseVodDetailfromJson(vod_dic)
  163. let niBaVodDetail = getVod(vod_dic["plays"], ["原画"], id.toString())
  164. this.vodDetail.vod_play_from = niBaVodDetail.vod_play_from
  165. this.vodDetail.vod_play_url = niBaVodDetail.vod_play_url
  166. }
  167. }
  168. async setSearch(wd, quick) {
  169. let params = {"cat_id": "1", "keyword": wd, "keyword_type": "0", "start": "0"}
  170. let url = this.siteUrl + "/show/search/WEB/3.2" + await createSign(params)
  171. let content = desDecrypt(await this.post(url, params, getHeader()))
  172. if (content != null) {
  173. let content_json = JSON.parse(content)
  174. for (const vod_dic of content_json["list"]) {
  175. let vod_detail = await this.parseVodDetailfromJson(vod_dic)
  176. this.vodList.push(vod_detail)
  177. }
  178. }
  179. }
  180. async setPlay(flag, id, flags) {
  181. let playId = id.split("@")[0]
  182. let showId = id.split("@")[1]
  183. let params = {
  184. "show_id_code": showId,
  185. "play_id_code": playId
  186. }
  187. let url = this.siteUrl + "/show/play/info/WEB/3.2" + await createSign(params)
  188. let content = desDecrypt(await this.post(url, params,getHeader()))
  189. if (content != null) {
  190. let content_json = JSON.parse(content)
  191. this.playUrl = content_json["entity"]["playUrl"]
  192. }
  193. }
  194. }
  195. let spider = new Nivod18Spider()
  196. async function init(cfg) {
  197. await spider.init(cfg)
  198. }
  199. async function home(filter) {
  200. return await spider.home(filter)
  201. }
  202. async function homeVod() {
  203. return await spider.homeVod()
  204. }
  205. async function category(tid, pg, filter, extend) {
  206. return await spider.category(tid, pg, filter, extend)
  207. }
  208. async function detail(id) {
  209. return await spider.detail(id)
  210. }
  211. async function play(flag, id, flags) {
  212. return await spider.play(flag, id, flags)
  213. }
  214. async function search(wd, quick) {
  215. return await spider.search(wd, quick)
  216. }
  217. export function __jsEvalReturn() {
  218. return {
  219. init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
  220. };
  221. }
  222. export {spider}