Update index.js

- added content type check
- added request headers (like in VLC)
This commit is contained in:
freearhey 2019-09-08 05:48:16 +03:00
parent 7c1ffdeadf
commit d584bbcaae
1 changed files with 21 additions and 1 deletions

View File

@ -22,6 +22,12 @@ const instance = axios.create({
}), }),
validateStatus: function (status) { validateStatus: function (status) {
return status >= 200 && status < 404 return status >= 200 && status < 404
},
headers: {
'Accept': '*/*',
'Accept-Language': 'en_US',
'User-Agent': 'VLC/3.0.8 LibVLC/3.0.8',
'Range': 'bytes=0-'
} }
}) })
@ -57,16 +63,30 @@ async function test() {
console.log(`Checking '${item.url}'...`) console.log(`Checking '${item.url}'...`)
} }
await instance.get(item.url) let response = await instance.get(item.url)
let string = response.data.toString()
let head = string.slice(0,7)
if(head !== '#EXTM3U') {
stats.failures++
writeToLog(country.url, 'Wrong content type', item.url)
}
continue continue
} catch (err) { } catch (err) {
if(err.response || (err.request && ['ENOTFOUND'].indexOf(err.code) > -1)) { if(err.response || (err.request && ['ENOTFOUND'].indexOf(err.code) > -1)) {
stats.failures++ stats.failures++
writeToLog(country.url, err.message, item.url) writeToLog(country.url, err.message, item.url)
} }
} }