(ret, fv)
| 189 | } |
| 190 | |
| 191 | function ExtractMovieInfo(ret, fv) { |
| 192 | const sole = new Set(ret.map(s => JSON.stringify(s))); //delete duplicate |
| 193 | const f1 = [...sole].map(p => JSON.parse(p)) |
| 194 | .filter(t => { |
| 195 | t.accuracy = 0; |
| 196 | if (t.name && fv[0]) { //title |
| 197 | if (t.name.includes(fv[0].slice(0, 4))) t.accuracy++; |
| 198 | if (t.name.includes(fv[0].slice(-3))) t.accuracy++; |
| 199 | } |
| 200 | if (t.origin && fv[1]) { //origin title |
| 201 | if (t.origin.includes(fv[1].slice(0, 4))) t.accuracy++; |
| 202 | if (t.origin.includes(fv[1].slice(-3))) t.accuracy++; |
| 203 | } |
| 204 | if (t.pd && fv[2]) { //producer or actor |
| 205 | const len = t.pd.split('/').filter(c => fv[2].includes(c)); |
| 206 | t.accuracy += len.length; |
| 207 | } |
| 208 | if (t.year && fv[3] && t.year == fv[3]) t.accuracy++; //year |
| 209 | return Boolean(t.accuracy); |
| 210 | }); |
| 211 | let x = {}; //assign most similar |
| 212 | const f2 = f1.reduce((p, c) => c.accuracy > p ? (x = c, c.accuracy) : p, 0); |
| 213 | return [x.rating, x.folk, x.name, x.id, f1]; |
| 214 | } |
| 215 | |
| 216 | function GetRawInfo(t) { |
| 217 | let res = []; |
no test coverage detected