haiwaikan.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * @File : haiwaikan.js
  3. * @Author : jade
  4. * @Date : 2024/04/02 9:15
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc : 海外看
  8. */
  9. import {VodSpider} from "./vodSpider.js";
  10. class HaiWaiKanSpider extends VodSpider {
  11. constructor() {
  12. super();
  13. this.siteUrl = "https://haiwaikan.com"
  14. this.remove18 = true
  15. this.type_id_18 = 0
  16. }
  17. async spiderInit(inReq) {
  18. await super.spiderInit(inReq);
  19. }
  20. async init(cfg) {
  21. await super.init(cfg);
  22. await this.spiderInit(null)
  23. }
  24. getAppName() {
  25. return "海外看"
  26. }
  27. getName() {
  28. return "☕┃海外看┃☕墙"
  29. }
  30. getJSName() {
  31. return "haiwaikan"
  32. }
  33. getType() {
  34. return 3
  35. }
  36. async setClasses() {
  37. let content = await this.fetch(this.siteUrl + "/api.php/provide/vod/from", {"ac": "list"}, this.getHeader())
  38. let content_json = JSON.parse(content)
  39. for (const class_dic of content_json["class"]) {
  40. if (class_dic["type_id"] < 26 ) {
  41. this.classes.push(this.getTypeDic(class_dic["type_name"], class_dic["type_id"].toString()))
  42. }
  43. }
  44. this.content_json = content_json
  45. }
  46. async getFilter(type_id,obj) {
  47. let extend_list = []
  48. let extend_dic = {"key": "1", "name": "全部类别", "value": [{"n":"全部类别","v":type_id.toString()}]}
  49. for (const type_dic of obj["class"]){
  50. let a_type_id = type_dic["type_id"]
  51. let max_type_id = 0
  52. let min_type_id = 0
  53. if (type_id === 20){
  54. max_type_id = 50
  55. min_type_id = 27
  56. }
  57. if (type_id === 21){
  58. max_type_id = 128
  59. min_type_id = 100
  60. }
  61. if (type_id === 22){
  62. max_type_id = 143
  63. min_type_id = 134
  64. }
  65. if (type_id === 23){
  66. max_type_id = 135
  67. min_type_id = 127
  68. }
  69. if (a_type_id < max_type_id && a_type_id > min_type_id){
  70. extend_dic["value"].push({"n":type_dic["type_name"],"v":a_type_id.toString()})
  71. }
  72. }
  73. if (extend_dic["value"].length > 1){
  74. extend_list.push(extend_dic)
  75. return extend_list
  76. }else{
  77. return null
  78. }
  79. }
  80. async setFilterObj() {
  81. let content = await this.fetch(this.siteUrl + "/api.php/provide/vod/from", {"ac": "list"}, this.getHeader())
  82. let content_json = JSON.parse(content)
  83. for (const type_dic of this.classes){
  84. let type_id = type_dic["type_id"]
  85. if (type_id !== "最近更新"){
  86. let extend_list = await this.getFilter(parseInt(type_id),content_json)
  87. if (extend_list !== null){
  88. this.filterObj[type_id] = extend_list
  89. }
  90. }
  91. }
  92. }
  93. }
  94. let spider = new HaiWaiKanSpider()
  95. async function init(cfg) {
  96. await spider.init(cfg)
  97. }
  98. async function home(filter) {
  99. return await spider.home(filter)
  100. }
  101. async function homeVod() {
  102. return await spider.homeVod()
  103. }
  104. async function category(tid, pg, filter, extend) {
  105. return await spider.category(tid, pg, filter, extend)
  106. }
  107. async function detail(id) {
  108. return await spider.detail(id)
  109. }
  110. async function play(flag, id, flags) {
  111. return await spider.play(flag, id, flags)
  112. }
  113. async function search(wd, quick) {
  114. return await spider.search(wd, quick)
  115. }
  116. async function proxy(segments, headers) {
  117. return await spider.proxy(segments, headers)
  118. }
  119. export function __jsEvalReturn() {
  120. return {
  121. init: init,
  122. home: home,
  123. homeVod: homeVod,
  124. category: category,
  125. detail: detail,
  126. play: play,
  127. search: search,
  128. proxy: proxy
  129. };
  130. }
  131. export {spider}