You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
6.6 KiB

  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let siteKey = '';
  3. let siteType = 0;
  4. let headers = {
  5. 'Vi': '1.0.0;11;101',
  6. 'Wua': 'YYT/1.0.0 (WEB;web;11;zh-CN;OUN7HHDoKgoDlMN3Z2oQH)',
  7. };
  8. async function request(reqUrl, postData, get) {
  9. let res = await req(reqUrl, {
  10. method: get ? 'get' : 'post',
  11. headers: headers,
  12. data: postData || {},
  13. });
  14. let content = res.content;
  15. return content;
  16. }
  17. async function init(cfg) {
  18. siteKey = cfg.skey;
  19. siteType = cfg.stype;
  20. }
  21. async function home(filter) {
  22. let st = Math.floor(Date.now() / 1e3);
  23. let pp = Ea('st' + st);
  24. let url ='https://video-api.yinyuetai.com/video/explore/channels';
  25. let res = JSON.parse((await req(url, {
  26. 'method': 'get',
  27. 'headers': {
  28. 'Vi': '1.0.0;11;101',
  29. 'Wua': 'YYT/1.0.0 (WEB;web;11;zh-CN;OUN7HHDoKgoDlMN3Z2oQH)',
  30. 'St': st,
  31. 'Pp': pp
  32. }
  33. })).content);
  34. //console.log(res);
  35. const classes = _.map(res.data, n => {
  36. return {
  37. type_id: n.id,
  38. type_name: n.channelName,
  39. }
  40. });
  41. return JSON.stringify({
  42. class: classes,
  43. });
  44. }
  45. async function homeVod() {
  46. }
  47. async function category(tid, pg, filter, extend) {
  48. if(!pg || pg <=0) pg = 1;
  49. `https://video-api.yinyuetai.com/video/explore/channelVideos?channelId=${tid}&detailType=2&size=20&offset=${20 * (pg-1)}`
  50. let url = `https://video-api.yinyuetai.com/video/explore/channelVideos?channelId=${tid}&detailType=2&size=20&offset=${20 * (pg-1)}`;
  51. let st = Math.floor(Date.now() / 1e3);
  52. let d = `channelId${tid}detailType2offset${20 * (pg-1)}size20st${st}`
  53. //console.log(d);
  54. let pp = Ea(d);
  55. let res = JSON.parse((await req(url, {
  56. 'method': 'get',
  57. 'headers': {
  58. 'Vi': '1.0.0;11;101',
  59. 'Wua': 'YYT/1.0.0 (WEB;web;11;zh-CN;OUN7HHDoKgoDlMN3Z2oQH)',
  60. 'St': st,
  61. 'Pp': pp
  62. }
  63. })).content);
  64. let videos = _.map(res.data, n => {
  65. return {
  66. vod_id: n.fullClip.videoId,
  67. vod_name: n.title,
  68. vod_pic: n.headImg,
  69. }
  70. });
  71. return JSON.stringify({
  72. list: videos,
  73. page: pg,
  74. limit: 20,
  75. });
  76. }
  77. async function detail(id) {
  78. let url = 'https://video-api.yinyuetai.com/video/get?id=' + id;
  79. try {
  80. let res = JSON.parse((await req(url, {
  81. 'method': 'get',
  82. })).content).data;
  83. let vod = {
  84. vod_id: id,
  85. vod_name: res.title,
  86. vod_play_from: _.map(res.fullClip.urls, n => {return n.display}).join('$$$'),
  87. vod_play_url: _.map(res.fullClip.urls, n => {return '播放$' + n.url}).join('$$$'),
  88. vod_content: '关注公众号“东方精英汇”,获取最新接口,加qq群783264601防迷失!【东辰影视】提醒您:该资源来源于网络,请勿传播,仅供技术学习使用,请在学习后24小时内删除!',
  89. };
  90. return JSON.stringify({
  91. list: [vod],
  92. });
  93. } catch (e) {
  94. console.log('err', e);
  95. }
  96. return null;
  97. }
  98. async function search(wd, quick, pg) {
  99. let url = 'https://search-api.yinyuetai.com/search/get_search_result.json';
  100. let params = {
  101. searchType: 'MV',
  102. key: wd,
  103. sinceId: 0,
  104. size: 20,
  105. requestTagRows: [],
  106. }
  107. let res = JSON.parse((await req(url, {
  108. 'method': 'post',
  109. 'headers': {
  110. 'Content-Type':'application/json'
  111. },
  112. 'data': params,
  113. })).content);
  114. let videos = _.map(res.data, n => {
  115. return {
  116. vod_id: n.fullClip.videoId,
  117. vod_name: n.title,
  118. vod_pic: n.headImg,
  119. }
  120. });
  121. return JSON.stringify({
  122. list: videos,
  123. });
  124. }
  125. async function play(flag, id, flags) {
  126. return JSON.stringify({
  127. parse: 0,
  128. url: id
  129. });
  130. }
  131. function base64Encode(text) {
  132. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  133. }
  134. function base64Decode(text) {
  135. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  136. }
  137. function base64ToHex(str) {
  138. for (var i = 0,
  139. bin = base64Decode(str.replace(/[ \r\n]+$/, "")), hex = []; i < bin.length; ++i) {
  140. var tmp = bin.charCodeAt(i).toString(16);
  141. if (tmp.length === 1) tmp = "0" + tmp;
  142. hex[hex.length] = tmp;
  143. }
  144. return hex.join("");
  145. }
  146. function Ea(e) {
  147. const t = e + "91fd6ee712437d42eeccdf545133039888d1cc77";
  148. return o(t);
  149. }
  150. function o(a, i) {
  151. var s = wordsToBytes(n(a));
  152. return i && i.asBytes ? s : i && i.asString ? bytesToString(s) : bytesToHex(s)
  153. };
  154. function n(a) {
  155. a = stringToBytes(a);
  156. var i = bytesToWords(a)
  157. , s = a.length * 8
  158. , l = []
  159. , c = 1732584193
  160. , u = -271733879
  161. , p = -1732584194
  162. , f = 271733878
  163. , d = -1009589776;
  164. i[s >> 5] |= 128 << 24 - s % 32,
  165. i[(s + 64 >>> 9 << 4) + 15] = s;
  166. for (var v = 0; v < i.length; v += 16) {
  167. for (var y = c, S = u, g = p, C = f, A = d, w = 0; w < 80; w++) {
  168. if (w < 16)
  169. l[w] = i[v + w];
  170. else {
  171. var T = l[w - 3] ^ l[w - 8] ^ l[w - 14] ^ l[w - 16];
  172. l[w] = T << 1 | T >>> 31
  173. }
  174. var U = (c << 5 | c >>> 27) + d + (l[w] >>> 0) + (w < 20 ? (u & p | ~u & f) + 1518500249 : w < 40 ? (u ^ p ^ f) + 1859775393 : w < 60 ? (u & p | u & f | p & f) - 1894007588 : (u ^ p ^ f) - 899497514);
  175. d = f,
  176. f = p,
  177. p = u << 30 | u >>> 2,
  178. u = c,
  179. c = U
  180. }
  181. c += y,
  182. u += S,
  183. p += g,
  184. f += C,
  185. d += A
  186. }
  187. return [c, u, p, f, d]
  188. }
  189. function stringToBytes(e) {
  190. for (var t = [], r = 0; r < e.length; r++)
  191. t.push(e.charCodeAt(r) & 255);
  192. return t
  193. }
  194. function bytesToString(e) {
  195. for (var t = [], r = 0; r < e.length; r++)
  196. t.push(String.fromCharCode(e[r]));
  197. return t.join("")
  198. }
  199. function bytesToWords(r) {
  200. for (var n = [], o = 0, a = 0; o < r.length; o++,
  201. a += 8)
  202. n[a >>> 5] |= r[o] << 24 - a % 32;
  203. return n
  204. }
  205. function wordsToBytes(r) {
  206. for (var n = [], o = 0; o < r.length * 32; o += 8)
  207. n.push(r[o >>> 5] >>> 24 - o % 32 & 255);
  208. return n
  209. }
  210. function bytesToHex(r) {
  211. for (var n = [], o = 0; o < r.length; o++)
  212. n.push((r[o] >>> 4).toString(16)),
  213. n.push((r[o] & 15).toString(16));
  214. return n.join("")
  215. }
  216. function hexToBytes(r) {
  217. for (var n = [], o = 0; o < r.length; o += 2)
  218. n.push(parseInt(r.substr(o, 2), 16));
  219. return n
  220. }
  221. function bytesToBase64(r) {
  222. for (var n = [], o = 0; o < r.length; o += 3)
  223. for (var a = r[o] << 16 | r[o + 1] << 8 | r[o + 2], i = 0; i < 4; i++)
  224. o * 8 + i * 6 <= r.length * 8 ? n.push(e.charAt(a >>> 6 * (3 - i) & 63)) : n.push("=");
  225. return n.join("")
  226. }
  227. function base64ToBytes(r) {
  228. r = r.replace(/[^A-Z0-9+\/]/ig, "");
  229. for (var n = [], o = 0, a = 0; o < r.length; a = ++o % 4)
  230. a != 0 && n.push((e.indexOf(r.charAt(o - 1)) & Math.pow(2, -2 * a + 8) - 1) << a * 2 | e.indexOf(r.charAt(o)) >>> 6 - a * 2);
  231. return n
  232. }
  233. export function __jsEvalReturn() {
  234. return {
  235. init: init,
  236. home: home,
  237. homeVod: homeVod,
  238. category: category,
  239. detail: detail,
  240. play: play,
  241. search: search,
  242. };
  243. }