nivod.js 8.3 KB

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