maiyoux_open.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  2. /**
  3. * 直播源
  4. * author:Leospring
  5. */
  6. let siteUrl = 'http://api.maiyoux.com:81/mf/';
  7. let siteKey = '';
  8. let siteType = 0;
  9. let cateList = {};
  10. async function request(reqUrl, postData, post) {
  11. let res = await req(reqUrl, {
  12. method: post ? 'post' : 'get',
  13. data: postData || {},
  14. postType: post ? 'form' : '',
  15. });
  16. let content = res.content;
  17. return content;
  18. }
  19. async function init(cfg) {
  20. siteKey = cfg.skey;
  21. siteType = cfg.stype;
  22. if (cfg.ext) {
  23. siteUrl = cfg.ext;
  24. }
  25. cateList = JSON.parse(await request(siteUrl + 'json.txt'));
  26. }
  27. async function home(filter) {
  28. let classes = [];
  29. Object.keys(cateList).forEach(function(key) {
  30. classes.push({
  31. type_id: key,
  32. type_name: key,
  33. });
  34. });
  35. return JSON.stringify({
  36. class: classes,
  37. // filters: filterObj
  38. });
  39. }
  40. async function category(tid, pg, filter, ext) {
  41. let videos = _.map(cateList[tid], (item) => {
  42. return {
  43. vod_id: item['address'],
  44. vod_name: item['title'],
  45. vod_pic: item['xinimg'],
  46. vod_remarks: item['Number']
  47. }
  48. })
  49. return JSON.stringify({
  50. list: videos,
  51. page: pg,
  52. pagecount: 1,
  53. total: videos.length
  54. });
  55. }
  56. async function detail(id) {
  57. try {
  58. const res = JSON.parse(await request(siteUrl + id))['zhubo'];
  59. let playUrls = _.map(res, (vod) => {
  60. return vod.title + '$' + vod.address;
  61. }).join('#');
  62. const video = {
  63. vod_play_from: 'Leospring',
  64. vod_play_url: playUrls,
  65. vod_content: '作者:Leospring 公众号:蚂蚁科技杂谈',
  66. };
  67. const list = [video];
  68. const result = { list };
  69. return JSON.stringify(result);
  70. } catch (e) {
  71. console.log('err', e);
  72. }
  73. return null;
  74. }
  75. async function play(flag, id, flags) {
  76. let playUrl = id;
  77. return JSON.stringify({
  78. parse: 0,
  79. url: playUrl,
  80. });
  81. }
  82. export function __jsEvalReturn() {
  83. return {
  84. init: init,
  85. home: home,
  86. category: category,
  87. detail: detail,
  88. play: play,
  89. };
  90. }