es6py.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. if (typeof Object.assign != 'function') {
  2. Object.assign = function () {
  3. let target = arguments[0];
  4. for (let i = 1; i < arguments.length; i++) {
  5. let source = arguments[i];
  6. for (let key in source) {
  7. if (Object.prototype.hasOwnProperty.call(source, key)) {
  8. target[key] = source[key];
  9. }
  10. }
  11. }
  12. return target;
  13. };
  14. }
  15. if (!String.prototype.includes) {
  16. String.prototype.includes = function (search, start) {
  17. if (typeof start !== 'number') {
  18. start = 0;
  19. }
  20. if (start + search.length > this.length) {
  21. return false;
  22. } else {
  23. return this.indexOf(search, start) !== -1;
  24. }
  25. };
  26. }
  27. if (!Array.prototype.includes) {
  28. Object.defineProperty(Array.prototype, 'includes', {
  29. value: function (searchElement, fromIndex) {
  30. if (this == null) {//this是空或者未定义,抛出错误
  31. throw new TypeError('"this" is null or not defined');
  32. }
  33. var o = Object(this);//将this转变成对象
  34. var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
  35. if (len === 0) {//length为0直接返回false未找到目标值
  36. return false;
  37. }
  38. var n = fromIndex | 0;//查找起始索引
  39. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
  40. while (k < len) {//从起始索引处开始循环
  41. if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
  42. return true;
  43. }
  44. k++;
  45. }
  46. return false;//未找到,返回false
  47. }
  48. });
  49. }
  50. if (typeof String.prototype.startsWith != 'function') {
  51. String.prototype.startsWith = function (prefix){
  52. return this.slice(0, prefix.length) === prefix;
  53. };
  54. }
  55. if (typeof String.prototype.endsWith != 'function') {
  56. String.prototype.endsWith = function(suffix) {
  57. return this.indexOf(suffix, this.length - suffix.length) !== -1;
  58. };
  59. }
  60. Object.prototype.myValues=function(obj){
  61. if(obj ==null) {
  62. throw new TypeError("Cannot convert undefined or null to object");
  63. }
  64. var res=[]
  65. for(var k in obj){
  66. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  67. res.push(obj[k]);
  68. }
  69. }
  70. return res;
  71. }
  72. if (typeof Object.prototype.values != 'function') {
  73. Object.prototype.values=function(obj){
  74. if(obj ==null) {
  75. throw new TypeError("Cannot convert undefined or null to object");
  76. }
  77. var res=[]
  78. for(var k in obj){
  79. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  80. res.push(obj[k]);
  81. }
  82. }
  83. return res;
  84. }
  85. }
  86. if (typeof Array.prototype.join != 'function') {
  87. Array.prototype.join = function (emoji) {
  88. // emoji = emoji||',';
  89. emoji = emoji||'';
  90. let self = this;
  91. let str = "";
  92. let i = 0;
  93. if (!Array.isArray(self)) {throw String(self)+'is not Array'}
  94. if(self.length===0){return ''}
  95. if (self.length === 1){return String(self[0])}
  96. i = 1;
  97. str = this[0];
  98. for (; i < self.length; i++) {
  99. str += String(emoji)+String(self[i]);
  100. }
  101. return str;
  102. };
  103. }
  104. String.prototype.rstrip = function (chars) {
  105. let regex = new RegExp(chars + "$");
  106. return this.replace(regex, "");
  107. };
  108. Array.prototype.append = Array.prototype.push;
  109. String.prototype.strip = String.prototype.trim;
  110. function 是否正版(vipUrl){
  111. let flag = new RegExp('qq\.com|iqiyi\.com|youku\.com|mgtv\.com|bilibili\.com|sohu\.com|ixigua\.com|pptv\.com|miguvideo\.com|le\.com|1905\.com|fun\.tv');
  112. return flag.test(vipUrl);
  113. }
  114. function urlDeal(vipUrl){
  115. if(!vipUrl){
  116. return ''
  117. }
  118. if(!是否正版(vipUrl)){
  119. return vipUrl
  120. }
  121. if(!/miguvideo/.test(vipUrl)){
  122. vipUrl=vipUrl.split('#')[0].split('?')[0];
  123. }
  124. return vipUrl
  125. }
  126. function setResult(d){
  127. if(!Array.isArray(d)){
  128. return []
  129. }
  130. VODS = [];
  131. // console.log(JSON.stringify(d));
  132. d.forEach(function (it){
  133. let obj = {
  134. vod_id:it.url||'',
  135. vod_name: it.title||'',
  136. vod_remarks: it.desc||'',
  137. vod_content: it.content||'',
  138. vod_pic: it.pic_url||it.img||'',
  139. };
  140. let keys = Object.keys(it);
  141. if(keys.includes('tname')){
  142. obj.type_name = it.tname||'';
  143. }
  144. if(keys.includes('tid')){
  145. obj.type_id = it.tid||'';
  146. }
  147. if(keys.includes('year')){
  148. obj.vod_year = it.year||'';
  149. }
  150. if(keys.includes('actor')){
  151. obj.vod_actor = it.actor||'';
  152. }
  153. if(keys.includes('director')){
  154. obj.vod_director = it.director||'';
  155. }
  156. if(keys.includes('area')){
  157. obj.vod_area = it.area||'';
  158. }
  159. VODS.push(obj);
  160. });
  161. return VODS
  162. }
  163. function setResult2(res){
  164. VODS = res.list||[];
  165. return VODS
  166. }
  167. function setHomeResult(res){
  168. if(!res||typeof(res)!=='object'){
  169. return []
  170. }
  171. return setResult(res.list);
  172. }
  173. // 千万不要用for in 推荐 forEach (for in 会打乱顺序)
  174. //猫函数
  175. function maoss(jxurl, ref, key) {
  176. eval(getCryptoJS());
  177. try {
  178. var getVideoInfo = function (text) {
  179. return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
  180. };
  181. var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
  182. if (ref) {
  183. var html = request(jxurl, {
  184. headers: {
  185. 'Referer': ref
  186. }
  187. });
  188. } else {
  189. var html = request(jxurl);
  190. }
  191. // print(html);
  192. if (html.indexOf('&btwaf=') != -1) {
  193. html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
  194. headers: {
  195. 'Referer': ref
  196. }
  197. })
  198. }
  199. var token_iv = html.split('_token = "')[1].split('"')[0];
  200. var key = CryptoJS.enc.Utf8.parse(token_key);
  201. var iv = CryptoJS.enc.Utf8.parse(token_iv);
  202. // log("iv:"+iv);
  203. // log(html);
  204. // print(key);
  205. // print(iv);
  206. eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
  207. // config.url = config.url.replace(/,/g,'');
  208. // print(config.url);
  209. if (!config.url.startsWith('http')) {
  210. //config.url = decodeURIComponent(AES(config.url, key, iv));
  211. config.url = CryptoJS.AES.decrypt(config.url, key, {
  212. iv: iv,
  213. padding: CryptoJS.pad.Pkcs7
  214. }).toString(CryptoJS.enc.Utf8)
  215. }
  216. return config.url;
  217. } catch (e) {
  218. return '';
  219. }
  220. }
  221. function urlencode (str) {
  222. str = (str + '').toString();
  223. return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
  224. replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
  225. }
  226. globalThis.VODS = [];// 一级或者搜索需要的数据列表
  227. globalThis.VOD = {};// 二级的单个数据
  228. globalThis.encodeUrl = urlencode;
  229. globalThis.urlencode = urlencode;
  230. globalThis.是否正版 = 是否正版;
  231. globalThis.urlDeal = urlDeal;
  232. globalThis.setResult = setResult;
  233. globalThis.setResult2 = setResult2;
  234. globalThis.setHomeResult = setHomeResult;
  235. globalThis.maoss = maoss;
  236. // globalThis.urljoin2 = joinUrl;
  237. // export default {
  238. // 是否正版:是否正版,
  239. // urlDeal:urlDeal,
  240. // setResult:setResult,
  241. // setResult2:setResult2,
  242. // setHomeResult:setHomeResult,
  243. // maoss:maoss,
  244. // urlencode:urlencode
  245. // }