ff_open.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { Crypto, load, _, jinja2 } from './lib/cat.js';
  2. let key = 'ff';
  3. let HOST = 'https://cj.ffzyapi.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
  7. async function request(reqUrl, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || UA,
  12. 'Referer': HOST
  13. },
  14. });
  15. return res.content;
  16. }
  17. // cfg = {skey: siteKey, ext: extend}
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. }
  22. async function home(filter) {
  23. let classes = [{"type_id":1,"type_name":"电影"},{"type_id":2,"type_name":"追剧"},{"type_id":3,"type_name":"综艺"},{"type_id":4,"type_name":"动漫"}];
  24. let filterObj = {
  25. "2":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"2"},{"n":"短剧","v":"36"},{"n":"陆剧","v":"13"},{"n":"韩剧","v":"15"},{"n":"欧美剧","v":"16"},{"n":"港剧","v":"14"},{"n":"台剧","v":"21"},{"n":"日剧","v":"22"},{"n":"海外剧","v":"23"},{"n":"泰剧","v":"24"},{"n":"纪录片","v":"20"}]}],
  26. "1":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"1"},{"n":"动作片","v":"6"},{"n":"喜剧片","v":"7"},{"n":"爱情片","v":"8"},{"n":"科幻片","v":"9"},{"n":"恐怖片","v":"10"},{"n":"剧情片","v":"11"},{"n":"战争片","v":"12"}]}],
  27. "3":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"3"},{"n":"国综","v":"25"},{"n":"港综","v":"26"},{"n":"韩日综","v":"27"},{"n":"欧美综","v":"28"}]}],
  28. "4":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"4"},{"n":"国漫","v":"29"},{"n":"日韩动漫","v":"30"},{"n":"欧美动漫","v":"31"},{"n":"港漫","v":"32"},{"n":"海外动漫","v":"33"}]}]
  29. };
  30. return JSON.stringify({
  31. class: classes,
  32. filters: filterObj,
  33. });
  34. }
  35. async function homeVod() {}
  36. async function category(tid, pg, filter, extend) {
  37. if (pg <= 0) pg = 1;
  38. let data = JSON.parse(await request(HOST + '/index.php/ajax/data?mid=1&tid=' + (extend.cateId || tid) + '&page=' + pg + '&limit=20'));
  39. let videos = [];
  40. for (const vod of data.list) {
  41. videos.push({
  42. vod_id: vod.vod_id,
  43. vod_name: vod.vod_name,
  44. vod_pic: vod.vod_pic,
  45. vod_remarks: '',
  46. });
  47. }
  48. return JSON.stringify({
  49. page: parseInt(data.page),
  50. pagecount: data.pagecount,
  51. limit: 20,
  52. total: data.total,
  53. list: videos,
  54. });
  55. }
  56. async function detail(id) {
  57. var html = await request( HOST + '/index.php/vod/detail/id/' + id + '.html');
  58. var $ = load(html);
  59. var vod = {
  60. vod_id: id,
  61. vod_name: $('h1:first').text().trim(),
  62. vod_type: $('.stui-content__detail p:first a').text(),
  63. vod_actor: $('.stui-content__detail p:nth-child(3)').text().replace('主演:',''),
  64. vod_pic: $('.stui-content__thumb img:first').attr('data-original'),
  65. vod_remarks : $('.stui-content__detail p:nth-child(5)').text() || '',
  66. vod_content: $('span.detail-content').text().trim(),
  67. };
  68. const playlist = _.map($('div.ffm3u8 > li > a[target*=_blank]'), (it) => {
  69. return it.attribs.title + '$' + it.attribs.href;
  70. });
  71. vod.vod_play_from = "非凡直达";
  72. vod.vod_play_url = playlist.join('#');
  73. return JSON.stringify({
  74. list: [vod],
  75. });
  76. }
  77. async function play(flag, id, flags) {
  78. return JSON.stringify({
  79. parse: 0,
  80. url: id,
  81. });
  82. }
  83. async function search(wd, quick, pg) {
  84. if (pg <= 0) pg = 1;
  85. let data = JSON.parse(await request(HOST + '/api.php/provide/vod/?wd=' + wd + '&pg=' +pg + '&ac=detail'));///api.php/provide/vod/?wd=搜索词&pg=翻页&ac=detail
  86. let videos = [];
  87. for (const vod of data.list) {
  88. videos.push({
  89. vod_id: vod.vod_id,
  90. vod_name: vod.vod_name,
  91. vod_pic: vod.vod_pic,
  92. vod_remarks: '',
  93. });
  94. }
  95. return JSON.stringify({
  96. page: parseInt(data.page),
  97. pagecount: data.pagecount,
  98. limit: 20,
  99. total: data.total,
  100. list: videos,
  101. });
  102. }
  103. export function __jsEvalReturn() {
  104. return {
  105. init: init,
  106. home: home,
  107. homeVod: homeVod,
  108. category: category,
  109. detail: detail,
  110. play: play,
  111. search: search,
  112. };
  113. }