云盘分享.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. let sourceUrl = "";
  2. let sourceData = {};
  3. function request(url) {
  4. const resp = req(url, {
  5. method: 'GET',
  6. headers: {
  7. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
  8. }
  9. });
  10. return resp.content;
  11. }
  12. function init(ext) {
  13. if (ext && ext.indexOf('http') == 0) {
  14. sourceUrl = ext;
  15. }
  16. }
  17. function home(filter) {
  18. console.log('sourceUrl: ' + sourceUrl);
  19. if (sourceUrl.indexOf('http') < 0) {
  20. return null;
  21. }
  22. const classes = [];
  23. sourceData = {};
  24. let className = '网盘分享';
  25. const text = request(sourceUrl);
  26. for (let line of text.split('\n')) {
  27. line = line.trim().replace(/[,\s$]+/g, ',');
  28. const position = line.indexOf(',');
  29. if (position < 0 && line.indexOf('##') == 0) {
  30. className = line.substring(2).trim();
  31. } else if (position > 1) {
  32. const name = line.substring(0, position).trim();
  33. let url = line.substring(position + 1).trim();
  34. let panName = '';
  35. switch (url.split('://')[0]) {
  36. case 'ali':
  37. url = 'push://https://www.alipan.com/s/' + url.substring(6);
  38. panName = '阿里';
  39. break;
  40. case 'uc':
  41. url = 'push://https://drive.uc.cn/s/' + url.substring(5);
  42. panName = 'UC';
  43. break;
  44. case 'quark':
  45. url = 'push://https://pan.quark.cn/s/' + url.substring(8);
  46. panName = '夸克';
  47. break;
  48. case 'https':
  49. if (url.indexOf('alipan.com') > 0) {
  50. url = 'push://' + url;
  51. panName = '阿里';
  52. } else if (url.indexOf('uc.cn') > 0) {
  53. url = 'push://' + url;
  54. panName = 'UC';
  55. } else if (url.indexOf('quark.cn') > 0) {
  56. url = 'push://' + url;
  57. panName = '夸克';
  58. } else {
  59. continue;
  60. }
  61. break;
  62. default:
  63. continue;
  64. }
  65. if (!(className in sourceData)) {
  66. classes.push({
  67. 'type_id': className,
  68. 'type_name': className,
  69. "type_flag": "1"
  70. });
  71. sourceData[className] = [];
  72. }
  73. sourceData[className].push({
  74. 'vod_id': url,
  75. 'vod_name': name,
  76. 'vod_pic': '',
  77. 'vod_remarks': panName
  78. });
  79. }
  80. }
  81. return JSON.stringify({
  82. 'class': classes,
  83. 'filters': null,
  84. 'type_flag': '1'
  85. });
  86. }
  87. function category(tid, pg, filter, extend) {
  88. return JSON.stringify({
  89. 'page': 1,
  90. 'pagecount': 1,
  91. 'list': sourceData[tid],
  92. 'type_des': ''
  93. });
  94. }
  95. __JS_SPIDER__ = {
  96. init: init,
  97. home: home,
  98. homeVod: null,
  99. category: category,
  100. detail: null,
  101. play: null,
  102. search: null
  103. };