fengche_open.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import { _, Uri, load } from 'assets://js/lib/cat.js';
  2. let key = 'fengche';
  3. let HOST = 'https://www.qyy158.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. const PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36';
  7. async function request(reqUrl) {
  8. const resp = await req(reqUrl, {
  9. headers: {
  10. 'User-Agent': PC_UA,
  11. },
  12. buffer: 1,
  13. });
  14. return gbk.decode(resp.content);
  15. }
  16. // cfg = {skey: siteKey, ext: extend}
  17. async function init(cfg) {
  18. siteKey = cfg.skey;
  19. siteType = cfg.stype;
  20. }
  21. async function home(filter) {
  22. const classes = [{'type_id':'all','type_name':'all'}];
  23. const filterObj = {
  24. 'all':[{'key':'area','name':'地域','init':'','value':[{'n':'全部','v':''},{'n':'大陆','v':'1'},{'n':'日本','v':'2'},{'n':'韩国','v':'3'},{'n':'欧美','v':'4'}]},{'key':'class','name':'类别','init':'','wrap':1,'value':[{'n':'全部','v':''},{'n':'霸总','v':'bazong'},{'n':'修真','v':'xiuzhen'},{'n':'恋爱','v':'lianai'},{'n':'校园','v':'xiaoyuan'},{'n':'冒险','v':'maoxian'},{'n':'搞笑','v':'gaoxiao'},{'n':'生活','v':'shenghuo'},{'n':'热血','v':'rexue'},{'n':'架空','v':'jiakong'},{'n':'后宫','v':'hougong'},{'n':'玄幻','v':'xuanhuan'},{'n':'悬疑','v':'xuanyi'},{'n':'恐怖','v':'kongbu'},{'n':'灵异','v':'lingyi'},{'n':'动作','v':'dongzuo'},{'n':'科幻','v':'kehuan'},{'n':'战争','v':'zhanzheng'},{'n':'古风','v':'gufeng'},{'n':'穿越','v':'chuanyue'},{'n':'竞技','v':'jingji'},{'n':'励志','v':'lizhi'},{'n':'同人','v':'tongren'},{'n':'真人','v':'zhenren'},{'n':'其他','v':'qita'},{'n':'总裁','v':'zongcai'},{'n':'异能','v':'yineng'},{'n':'韩漫','v':'hanman'},{'n':'剧情','v':'juqing'},{'n':'大女主','v':'danvzhu'},{'n':'都市','v':'dushi'},{'n':'格斗','v':'gedou'},{'n':'武侠','v':'wuxia'},{'n':'日常','v':'richang'},{'n':'纯爱','v':'chunai'},{'n':'国漫','v':'guoman'},{'n':'推理','v':'tuili'},{'n':'少年','v':'shaonain'},{'n':'奇幻','v':'qihuan'},{'n':'短篇','v':'duanpian'},{'n':'ABO','v':'abo'},{'n':'运动','v':'yundong'},{'n':'萌系','v':'mengxi'},{'n':'爆笑','v':'baoxiao'},{'n':'蔷薇','v':'qiangwei'},{'n':'百合','v':'baihe'},{'n':'BG','v':'bg'}]},{'key':'status','name':'状态','init':'','value':[{'n':'全部','v':''},{'n':'连载中','v':'1'},{'n':'已完结','v':'2'}]}],
  25. };
  26. return {
  27. class: classes,
  28. filters: filterObj,
  29. };
  30. }
  31. async function category(tid, pg, filter, extend) {
  32. if (pg == 0) pg = 1;
  33. const uri = new Uri(`${HOST}/sort/`);
  34. if (extend.class) {
  35. uri.addQueryParam('class', extend.class);
  36. }
  37. if (extend.area) {
  38. uri.addQueryParam('area', extend.area);
  39. }
  40. if (extend.status) {
  41. uri.addQueryParam('status', extend.status);
  42. }
  43. if (pg > 1) {
  44. uri.addQueryParam('page', pg);
  45. }
  46. const link = uri.toString();
  47. const html = await request(link);
  48. const $ = load(html);
  49. const list = $('.cartoon-block-box .cart-item');
  50. const books = _.map(list, (item) => {
  51. const $item = $(item);
  52. const $cover = $item.find('.cart-cover');
  53. const $img = $cover.find('img:first');
  54. const $p = $item.find('.cart-info p:first');
  55. const $remark = $item.find('.new-chapter');
  56. return {
  57. book_id: $cover.attr('href').replace(/.*\/info\/(.*)\//, '$1'),
  58. book_name: $p.text(),
  59. book_pic: $img.attr('src'),
  60. book_remarks: $remark.text(),
  61. };
  62. });
  63. const hasMore = $('.pagelink a.next').length > 0;
  64. return {
  65. page: pg,
  66. pagecount: hasMore ? pg + 1 : pg,
  67. list: books,
  68. };
  69. }
  70. async function detail(id) {
  71. const html = await request(`${HOST}/info/${id}/`);
  72. const $ = load(html);
  73. const book = {
  74. book_name: $('h1.title').text().trim(),
  75. book_director: $('.mt10:contains(作者)').text().substring(3).trim(),
  76. book_content: $('.line-clamp-4:contains(简介)').text().substring(3).trim(),
  77. };
  78. const list = $('.chapter-list li');
  79. const urls = _.map(list, (item) => {
  80. const $item = $(item).find('a');
  81. const title = $item.text();
  82. const href = `/info/${id}/${$item.attr('href')}`;
  83. return title + '$' + href;
  84. }).join('#');
  85. book.volumes = '章节';
  86. book.urls = urls;
  87. return {
  88. list: [book],
  89. };
  90. }
  91. async function play(flag, id, flags) {
  92. const html = await request(`${HOST}${id}`);
  93. const $ = load(html);
  94. const images = $('.chapter-content img');
  95. const content = _.map(images, (image) => {
  96. return $(image).attr('data-original');
  97. });
  98. return {
  99. content: content,
  100. };
  101. }
  102. async function search(wd, quick, pg) {
  103. if (pg == 0) pg = 1;
  104. const link = `${HOST}/search/${encodeURIComponent(wd)}/`;
  105. const html = await request(link);
  106. const $ = load(html);
  107. const list = $('.cartoon-block-box .cart-item');
  108. const books = _.map(list, (item) => {
  109. const $item = $(item);
  110. const $cover = $item.find('.cart-cover');
  111. const $img = $cover.find('img:first');
  112. const $p = $item.find('.cart-info p:first');
  113. const $remark = $item.find('.new-chapter');
  114. return {
  115. book_id: $cover.attr('href').replace(/.*\/info\/(.*)\//, '$1'),
  116. book_name: $p.text(),
  117. book_pic: $img.attr('src'),
  118. book_remarks: $remark.text(),
  119. };
  120. });
  121. return {
  122. page: pg,
  123. pagecount: pg,
  124. list: books,
  125. };
  126. }
  127. export function __jsEvalReturn() {
  128. return {
  129. init: init,
  130. home: home,
  131. category: category,
  132. detail: detail,
  133. play: play,
  134. search: search,
  135. };
  136. }