|
2 | 2 | // http://localhost:5757/api/人人视频?ac=detail&ids=447 |
3 | 3 | // http://localhost:5757/api/人人视频?wd=&pg=1 |
4 | 4 | // http://localhost:5757/api/人人视频?play=&flag=人人视频 |
5 | | -const {getPublicIp} = $.require('./_lib.request.js'); |
6 | | - |
| 5 | +const {getPublicIp} = $.require('_lib.request.js'); |
7 | 6 | var rule = { |
8 | 7 | 类型: '影视', |
9 | 8 | title: '人人视频', |
@@ -100,12 +99,13 @@ var rule = { |
100 | 99 | let playmap = {}; |
101 | 100 | for (const i in playlist) { |
102 | 101 | let form = playlist[i].player_info.show |
| 102 | + let user_agent = playlist[i].player_info.user_agent |
103 | 103 | const list = playlist[i].urls |
104 | 104 | if (!playmap.hasOwnProperty(form)) { |
105 | 105 | playmap[form] = []; |
106 | 106 | } |
107 | 107 | for (const i in list) { |
108 | | - playmap[form].push(list[i].name.trim() + '$' + encodeURIComponent(list[i].parse_api_url)); |
| 108 | + playmap[form].push(list[i].name.trim() + '$' + encodeURIComponent(list[i].parse_api_url + '#' + user_agent)); |
109 | 109 |
|
110 | 110 | } |
111 | 111 | } |
@@ -141,69 +141,87 @@ var rule = { |
141 | 141 | lazy: async function (flag, id, flags) { |
142 | 142 | let {getProxyUrl, input} = this; |
143 | 143 | if (input.indexOf('m3u8') < 0) { |
144 | | - input = input.replace('$ip',rule.ip); |
145 | | - let html = JSON.parse((await req(input, { |
146 | | - method: 'post', |
147 | | - // headers: { |
148 | | - // 'User-Agent': 'Mozilla/9.0 (Macintosh; Intel Mac OS X 10.8; rv:69.0) Gecko/20100101 Firefox/69.0' |
149 | | - // }, |
150 | | - headers: rule.headers, |
151 | | - })).content) |
152 | | - let link = html.url |
153 | | - return {parse: 0, url: link} |
154 | | - // return {parse: 0, url: getProxyUrl() + '&url=' + encodeURIComponent(link), js: ''} |
| 144 | + if (input.indexOf('json.php') > 0) { |
| 145 | + let html = JSON.parse((await req(input.split('#')[0], { |
| 146 | + method: 'post', |
| 147 | + headers: { |
| 148 | + 'User-Agent': input.split('#')[1] |
| 149 | + } |
| 150 | + })).content) |
| 151 | + let link = html.url |
| 152 | + return {parse: 0, url: getProxyUrl() + '&url=' + encodeURIComponent(link), js: ''} |
| 153 | + } else if (input.indexOf('parse.php') > 0) { |
| 154 | + let html = JSON.parse((await req(input.split('#')[0], { |
| 155 | + method: 'post', |
| 156 | + headers: { |
| 157 | + 'User-Agent': input.split('#')[1], |
| 158 | + 'Connection': 'Keep-Alive', |
| 159 | + 'Accept-Encoding': 'gzip', |
| 160 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' |
| 161 | + } |
| 162 | + })).content) |
| 163 | + let link = html.url |
| 164 | + return {parse: 0, url: link, js: ''} |
| 165 | + } else { |
| 166 | + let html = JSON.parse((await req(input.split('#')[0], { |
| 167 | + method: 'post', |
| 168 | + headers: { |
| 169 | + 'User-Agent': input.split('#')[1], |
| 170 | + 'Connection': 'Keep-Alive', |
| 171 | + 'Accept-Encoding': 'gzip', |
| 172 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' |
| 173 | + } |
| 174 | + })).content) |
| 175 | + let link = html.url |
| 176 | + return {parse: 0, url: link, js: ''} |
| 177 | + } |
155 | 178 | } else { |
156 | | - return {parse: 0, url: getProxyUrl() + '&url=' + input, js: ''} |
| 179 | + return {parse: 0, url: getProxyUrl() + '&url=' + encodeURIComponent(input.split('#')[0]), js: ''} |
157 | 180 | } |
158 | 181 | }, |
159 | | - proxy_rule: async function (params) { |
| 182 | + proxy_rule: async function () { |
160 | 183 | let {input} = this; |
161 | | - input = decodeURIComponent(input); |
162 | | - if (input.includes('.mp4')) { |
163 | | - return [302, getContentType(input), '', {location: input}]; |
164 | | - } |
165 | 184 | if (input.indexOf('m3u8') < 0) { |
166 | | - let m3u8_content = (await req(input)).content |
| 185 | + let m3u8_content = (await req(decodeURIComponent(input))).content |
167 | 186 | let m3u8 = m3u8_content.replace(/#EXTINF:10\.333333,\s*https?:\/\/[^\s]+\n#EXT-X-DISCONTINUITY/, '') |
168 | 187 | return [200, 'application/vnd.apple.mpegurl', m3u8] |
169 | 188 | } else { |
170 | | - let m3u8_content = (await req(input)).content |
| 189 | + let m3u8_content = (await req(decodeURIComponent(input))).content.replace(/#EXTINF:10\.333333,\s*https?:\/\/[^\s]+\n#EXT-X-DISCONTINUITY/, '') |
171 | 190 | //https?:\/\/[^\s]+piantou\.(txt|zip)|piantou.txt|piantou.zip |
172 | | - if (m3u8_content.indexOf('piantou') > 0) { |
| 191 | + if (m3u8_content.match(/https?:\/\/[^\s]+piantou\.(txt|zip|psd)|piantou.txt|piantou.zip|piantou.psd/)) { |
173 | 192 | const lines = m3u8_content.split('\n'); |
174 | 193 | const tsUrls = []; |
175 | 194 | let link_start = '' |
176 | 195 | lines.forEach(line => { |
177 | | - if (line.trim().startsWith('http') && line.trim().indexOf('piantou') < 0 && line.trim().endsWith('.txt') || line.trim().endsWith('.zip')) { |
| 196 | + if (line.trim().startsWith('http') && line.trim().indexOf('piantou') < 0 && /txt|zip|psd/.test(line.trim())) { |
178 | 197 | tsUrls.push(line) |
179 | 198 | } |
180 | | - if (line.trim().endsWith('.txt') || line.trim().endsWith('.zip') && line.trim().indexOf('piantou') < 0) { |
| 199 | + if (/txt|zip|psd/.test(line.trim()) && line.trim().indexOf('piantou') < 0) { |
181 | 200 | link_start = input.split('?')[0].replace('playlist.m3u8', '') |
182 | 201 | tsUrls.push(link_start + line.trim()) |
183 | 202 | } else { |
184 | 203 | tsUrls.push(line) |
185 | 204 | } |
186 | 205 | }) |
187 | 206 | let m3u8_text = tsUrls.join('\n') |
188 | | - // log(m3u8_text) |
| 207 | + log(m3u8_text) |
189 | 208 | return [200, 'application/vnd.apple.mpegurl', m3u8_text] |
190 | 209 | } else { |
191 | 210 | const lines = m3u8_content.split('\n'); |
192 | 211 | const tsUrls = []; |
193 | 212 | let link_start = '' |
194 | 213 | lines.forEach(line => { |
195 | | - if (line.trim().startsWith('http') && line.trim().endsWith('.txt') || line.trim().endsWith('.zip')) { |
| 214 | + if (line.trim().startsWith('http') && /txt|zip|psd/.test(line.trim())) { |
196 | 215 | tsUrls.push(line) |
197 | 216 | } |
198 | | - if (line.trim().endsWith('.txt') || line.trim().endsWith('.zip')) { |
| 217 | + if (/txt|zip|psd/.test(line.trim())) { |
199 | 218 | link_start = input.split('?')[0].replace('playlist.m3u8', '') |
200 | 219 | tsUrls.push(link_start + line.trim()) |
201 | 220 | } else { |
202 | 221 | tsUrls.push(line) |
203 | 222 | } |
204 | 223 | }) |
205 | 224 | let m3u8_text = tsUrls.join('\n') |
206 | | - log(m3u8_text) |
207 | 225 | return [200, 'application/vnd.apple.mpegurl', m3u8_text] |
208 | 226 | } |
209 | 227 | } |
|
0 commit comments