ng_open.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. import { Crypto, jinja2, _ } from './lib/cat.js';
  2. let key = '南瓜影视';
  3. let HOST = 'http://ys.changmengyun.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. let MOBILE_UA = 'okhttp/4.6.0'
  7. async function request(reqUrl) {
  8. let t = new Date().getTime().toString();
  9. let res = await req(reqUrl, {
  10. method: 'get',
  11. headers: {
  12. 'version_name': '1.0.6',
  13. 'version_code': '6',
  14. 'package_name': 'com.app.nanguatv',
  15. 'sign': Crypto.MD5('c431ea542cee9679#uBFszdEM0oL0JRn@' + t).toString().toLowerCase(),
  16. 'imei': 'c431ea542cee9679',
  17. 'timeMillis': t,
  18. 'User-Agent': MOBILE_UA
  19. },
  20. });
  21. return res.content;
  22. }
  23. async function init(cfg) {
  24. siteKey = cfg.skey;
  25. siteType = cfg.stype;
  26. }
  27. async function home(filter) {
  28. let data = JSON.parse(await request(HOST + '/api.php/provide/home_nav'));
  29. let classes = [];
  30. for (const key in data) {
  31. if (data[key].name != '精选')
  32. classes.push({
  33. type_id: data[key].id,
  34. type_name: data[key].name,
  35. });
  36. }
  37. let filterObj = {
  38. "2":[{"key":"class","name":"类型","value":[{"n":"全部","v":"类型"},{"n":"国产剧","v":"国产剧"},{"n":"港台剧","v":"港台剧"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":"地区"},{"n":"内地","v":"内地"},{"n":"香港地区","v":"香港地区"},{"n":"台湾地区","v":"台湾地区"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":"年份"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"10年代","v":"10年代"},{"n":"00年代","v":"00年代"},{"n":"90年代","v":"90年代"},{"n":"80年代","v":"80年代"}]},{"key":"by","name":"排序","value":[{"n":"热播榜","v":"热播榜"},{"n":"好评榜","v":"好评榜"},{"n":"新上线","v":"新上线"}]}],
  39. "1":[{"key":"class","name":"类型","value":[{"n":"全部","v":"类型"},{"n":"动作片","v":"动作片"},{"n":"喜剧片","v":"喜剧片"},{"n":"爱情片","v":"爱情片"},{"n":"科幻片","v":"科幻片"},{"n":"恐怖片","v":"恐怖片"},{"n":"剧情片","v":"剧情片"},{"n":"战争片","v":"战争片"},{"n":"惊悚片","v":"惊悚片"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":"地区"},{"n":"华语","v":"华语"},{"n":"香港地区","v":"香港地区"},{"n":"美国","v":"美国"},{"n":"欧洲","v":"欧洲"},{"n":"韩国","v":"韩国"},{"n":"日本","v":"日本"},{"n":"台湾地区","v":"台湾地区"},{"n":"泰国","v":"泰国"},{"n":"台湾地区","v":"台湾地区"},{"n":"印度","v":"印度"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":"年份"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"10年代","v":"10年代"},{"n":"00年代","v":"00年代"},{"n":"90年代","v":"90年代"},{"n":"80年代","v":"80年代"}]},{"key":"by","name":"排序","value":[{"n":"热播榜","v":"热播榜"},{"n":"好评榜","v":"好评榜"},{"n":"新上线","v":"新上线"}]}],
  40. "4":[{"key":"class","name":"类型","value":[{"n":"全部","v":"类型"},{"n":"国产漫","v":"国产漫"},{"n":"欧美漫","v":"欧美漫"},{"n":"日韩漫","v":"日韩漫"},{"n":"港台漫","v":"港台漫"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":"地区"},{"n":"中国大陆","v":"中国大陆"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"欧美","v":"欧美"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":"年份"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"10年代","v":"10年代"},{"n":"00年代","v":"00年代"},{"n":"90年代","v":"90年代"},{"n":"80年代","v":"80年代"}]},{"key":"by","name":"排序","value":[{"n":"热播榜","v":"热播榜"},{"n":"新上线","v":"新上线"}]},{"key":"total","name":"状态","value":[{"n":"全部","v":"状态"},{"n":"连载","v":"连载"},{"n":"完结","v":"完结"}]}],
  41. "3":[{"key":"class","name":"类型","value":[{"n":"全部","v":"类型"},{"n":"大陆","v":"大陆"},{"n":"港台","v":"港台"},{"n":"日韩","v":"日韩"},{"n":"欧美","v":"欧美"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":"地区"},{"n":"内地","v":"内地"},{"n":"港台","v":"港台"},{"n":"日韩","v":"日韩"},{"n":"欧美","v":"欧美"},{"n":"其它","v":"其它"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":"年份"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"10年代","v":"10年代"},{"n":"00年代","v":"00年代"},{"n":"90年代","v":"90年代"},{"n":"80年代","v":"80年代"}]},{"key":"by","name":"排序","value":[{"n":"热播榜","v":"热播榜"},{"n":"新上线","v":"新上线"}]}],
  42. "46":[{"key":"class","name":"类型","value":[{"n":"全部","v":"类型"},{"n":"日韩剧","v":"日韩剧"},{"n":"欧美剧","v":"欧美剧"},{"n":"海外剧","v":"海外剧"}]},{"key":"area","name":"地区","value":[{"n":"全部","v":"地区"},{"n":"韩国","v":"韩国"},{"n":"美剧","v":"美剧"},{"n":"日本","v":"日本"},{"n":"泰国","v":"泰国"},{"n":"英国","v":"英国"},{"n":"新加坡","v":"新加坡"},{"n":"其他","v":"其他"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":"年份"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"},{"n":"2018","v":"2018"},{"n":"2017","v":"2017"},{"n":"2016","v":"2016"},{"n":"2015","v":"2015"},{"n":"10年代","v":"10年代"},{"n":"00年代","v":"00年代"},{"n":"90年代","v":"90年代"},{"n":"80年代","v":"80年代"}]},{"key":"by","name":"排序","value":[{"n":"热播榜","v":"热播榜"},{"n":"好评榜","v":"好评榜"},{"n":"新上线","v":"新上线"}]}]
  43. };
  44. return JSON.stringify({
  45. class: classes,
  46. filters: filterObj,
  47. });
  48. }
  49. async function homeVod() {
  50. let data = JSON.parse(await request(HOST + '/api.php/provide/vod_rank?app=ylys&sort_type=month&imei=c431ea542cee9679&id=2&page=1'));
  51. let videos = [];
  52. data.forEach(function(it) {
  53. videos.push({
  54. vod_id: it.id,
  55. vod_name: it.name,
  56. vod_pic: it.img,
  57. vod_remarks: it.remarks,
  58. });
  59. });
  60. return JSON.stringify({
  61. list: videos,
  62. });
  63. }
  64. async function category(tid, pg, filter, extend) {
  65. if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
  66. let reqUrl = HOST + '/api.php/provide/vod_list?app=ylys&id=' + tid + '&page=' + pg + '&imei=c431ea542cee9679&';
  67. reqUrl += jinja2('area={{ext.area}}&year={{ext.year}}&type={{ext.class}}&total={{ext.total}}&order={{ext.by}}', { ext: extend });
  68. // let data = JSON.parse(await request(reqUrl));
  69. let data = JSON.parse(await request(reqUrl)).list;
  70. let videos = [];
  71. data.forEach(function(it) {
  72. videos.push({
  73. vod_id: it.id,
  74. vod_name: it.name,
  75. vod_pic: it.img,
  76. vod_remarks: it.remarks,
  77. });
  78. });
  79. let pgChk = JSON.parse(await request(HOST + '/api.php/provide/vod_list?app=ylys&id=' + tid + '&page=' + (parseInt(pg) + 1) + '&imei=c431ea542cee9679&')).msg;
  80. const pgCount = (pgChk == 'ok') ? parseInt(pg) + 1 : parseInt(pg);
  81. return JSON.stringify({
  82. page: parseInt(pg),
  83. pagecount: pgCount,
  84. limit: 20,
  85. total: 20 * pgCount,
  86. list: videos,
  87. });
  88. }
  89. async function detail(id) {
  90. let data = JSON.parse(await request(HOST + '/api.php/provide/vod_detail?app=ylys&imei=c431ea542cee9679&id=' + id)).data;
  91. let vod = {
  92. vod_id: data.id,
  93. vod_name: data.name,
  94. vod_pic: data.img,
  95. type_name: data.type,
  96. vod_year: data.year,
  97. vod_remarks: '更新至: ' + data.msg + ' / 评分: ' + data.score,
  98. vod_content: stripHtmlTag(data.info),
  99. };
  100. let episodes = data.player_info;
  101. let playlist = {};
  102. episodes.forEach(function(it) {
  103. let playurls = it.video_info;
  104. playurls.forEach(function(playurl) {
  105. let source = it.show;
  106. let t = formatPlayUrl(vod.vod_name, playurl.name);
  107. if (t.length == 0) t = playurl.name.trim();
  108. if (!playlist.hasOwnProperty(source)) {
  109. playlist[source] = [];
  110. }
  111. playlist[source].push(t + '$' + playurl.url);
  112. });
  113. });
  114. vod.vod_play_from = _.keys(playlist).join('$$$');
  115. let urls = _.values(playlist);
  116. let vod_play_url = [];
  117. urls.forEach(function(it) {
  118. vod_play_url.push(it.join('#'));
  119. });
  120. vod.vod_play_url = vod_play_url.join('$$$');
  121. return JSON.stringify({
  122. list: [vod],
  123. });
  124. }
  125. async function play(flag, id, flags) {
  126. try {
  127. if (id.indexOf('m3u8') != -1) {
  128. let mjurl = id.split('url=')[1]
  129. return JSON.stringify({
  130. parse: 0,
  131. url: mjurl,
  132. });
  133. } else if (id.indexOf(',') != -1) {
  134. let mjurl = id.split(',')[1]
  135. let jData = JSON.parse(await request(mjurl));
  136. return JSON.stringify({
  137. parse: 0,
  138. url: jData.data.url,
  139. });
  140. } else {
  141. let mjurl = 'http://43.154.104.152:1234/jhapi/cs.php?url=' + id.split('url=')[1]
  142. let jData = JSON.parse(await request(mjurl));
  143. return JSON.stringify({
  144. parse: 0,
  145. url: jData.data.url,
  146. });
  147. }
  148. } catch (e) {
  149. return JSON.stringify({
  150. parse: 0,
  151. url: id,
  152. });
  153. }
  154. }
  155. async function search(wd, quick, pg) {
  156. if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
  157. let data = JSON.parse(await request(HOST + '/api.php/provide/search_result_more?app=ylys&video_name=' + wd + '&pageSize=20&tid=0&imei=c431ea542cee9679&page=' + pg, 'okhttp/4.6.0')).data;
  158. let videos = [];
  159. data.forEach(function(it) {
  160. videos.push({
  161. vod_id: it.id,
  162. vod_name: it.video_name,
  163. vod_pic: it.img,
  164. vod_remarks: it.qingxidu + '/' + it.category,
  165. });
  166. });
  167. let pgChk = JSON.parse(await request(HOST + '/api.php/provide/search_result_more?app=ylys&video_name=' + wd + '&pageSize=20&tid=0&imei=c431ea542cee9679&page=' + (parseInt(pg) + 1), 'okhttp/4.6.0')).msg;
  168. const pgCount = (pgChk == 'ok') ? parseInt(pg) + 1 : parseInt(pg);
  169. return JSON.stringify({
  170. page: parseInt(pg),
  171. pagecount: pgCount,
  172. limit: 20,
  173. total: 20 * pgCount,
  174. list: videos,
  175. });
  176. }
  177. function stripHtmlTag(src) {
  178. return src
  179. .replace(/<\/?[^>]+(>|$)/g, '')
  180. .replace(/&.{1,5};/g, '')
  181. .replace(/\s{2,}/g, ' ');
  182. }
  183. function formatPlayUrl(src, name) {
  184. return name
  185. .trim()
  186. .replaceAll(src, '')
  187. .replace(/<|>|《|》/g, '')
  188. .replace(/\$|#/g, ' ')
  189. .trim();
  190. }
  191. export function __jsEvalReturn() {
  192. return {
  193. init: init,
  194. home: home,
  195. homeVod: homeVod,
  196. category: category,
  197. detail: detail,
  198. play: play,
  199. search: search,
  200. };
  201. }