MCPcopy Create free account
hub / github.com/develop202/migu_video / getddCalcu

Function getddCalcu

utils/ddCalcuURL.js:107–165  ·  view source on GitHub ↗

* 获取ddCalcu * @param {string} puData - 服务器返回的那个东东 * @param {string} programId - 节目ID * @param {string} clientType - 平台类型 h5 android * @param {string} rateType - 清晰度 2:标清 3:高清 4:蓝光 * @returns {string} - ddCalcu

(puData, programId, clientType, rateType, urlUserId)

Source from the content-addressed store, hash-verified

105 * @returns {string} - ddCalcu
106 */
107function getddCalcu(puData, programId, clientType, rateType, urlUserId) {
108
109 if (puData == null || puData == undefined) {
110 return ""
111 }
112
113 if (programId == null || programId == undefined) {
114 return ""
115 }
116
117 if (clientType != "android" && clientType != "h5") {
118 return ""
119 }
120
121 if (rateType == null || rateType == undefined) {
122 return ""
123 }
124
125 // 不登录标清是默认v
126 const id = urlUserId || userId || process.env.USERID || ""
127 if (id) {
128 const words1 = list.android.keys[id[7]]
129 list.android.words[0] = words1
130 list.h5.words[0] = words1
131 }
132
133 let keys = list[clientType].keys
134 let words = list[clientType].words
135 const thirdReplaceIndex = list[clientType].thirdReplaceIndex
136 // android平台标清
137 if (clientType == "android" && rateType == "2") {
138 words[0] = "v"
139 }
140 if (id.length > 3 && id.length <= 8) {
141 words[0] = "e"
142 }
143 const puDataLength = puData.length
144 let ddCalcu = []
145 for (let i = 0; i < puDataLength / 2; i++) {
146
147 ddCalcu.push(puData[puDataLength - i - 1])
148 ddCalcu.push(puData[i])
149 switch (i) {
150 case 1:
151 ddCalcu.push(words[i - 1])
152 break;
153 case 2:
154 ddCalcu.push(keys[parseInt(getDateString(new Date())[0])])
155 break;
156 case 3:
157 ddCalcu.push(keys[programId[thirdReplaceIndex]])
158 break;
159 case 4:
160 ddCalcu.push(words[i - 1])
161 break;
162 }
163 }
164 return ddCalcu.join("")

Callers 1

getddCalcuURLFunction · 0.85

Calls 1

getDateStringFunction · 0.90

Tested by

no test coverage detected