1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- var video = {
- getVideoSource(vids, videoEls) {
- // let vids = ['8892551']
- // var videoEls = {
- // '8892551': 'lookup',
- // }
- var mp4UrlMap = {}
- $.ajax({
- type: "GET",
- dataType: "json",
- url: `//video.duowan.com/jsapi/playPageVideoInfo/?vids=${vids.join(',')}`,
- success: function(data) {
- for(var i in data) {
- let resouce = video.deCodeArg(data[i].c).all,
- source = resouce.yuanhua || resouce[1300] || resouce[1000] || resouce[350]
- let name = videoEls[i]
- mp4UrlMap[name] = source.src
- }
- console.log(mp4UrlMap)
-
- for(var key in mp4UrlMap) {
- document.getElementById(key).src = mp4UrlMap[key]
- }
- }
- })
- },
- decr(r) {
- var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@!~*-_.()'".split("");
- var n = [];
- var a = [];
- r.split("").reverse().forEach(function (r, t) {
- var o = e.indexOf(r);
- if (parseInt((t + 1) % 2) == 1) {
- a.push(o)
- } else {
- var p = parseInt(o - a[(t + 1) / 2 - 1]);
- n.push(e[p])
- }
- });
- var t = n.join("").replace(/@/g, "%");
- return decodeURIComponent(t)
- },
- /**
- * 解密数据
- */
- deCodeArg(target) {
- var srcMap = {};
- if (JSON.parse) {
- srcMap = JSON.parse(this.decr(target));
- } else {
- srcMap = eval('(' + this.decr(target) + ')');
- }
- return srcMap;
- },
- }
- export default video
|