mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-12 18:10:04 -04:00
Create scripts/store/setters
This commit is contained in:
parent
21b8ce8731
commit
42d8a670d2
13 changed files with 156 additions and 0 deletions
25
scripts/store/setters/status.js
Normal file
25
scripts/store/setters/status.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const statuses = require('../../data/statuses')
|
||||
|
||||
module.exports = function ({ title, status = {} }) {
|
||||
if (title) {
|
||||
const [_, label] = title.match(/\[(.*)\]/i) || [null, null]
|
||||
|
||||
return Object.values(statuses).find(s => s.label === label) || statuses['online']
|
||||
}
|
||||
|
||||
if (status) {
|
||||
switch (status.code) {
|
||||
case 'not_247':
|
||||
case 'geo_blocked':
|
||||
return status
|
||||
case 'offline':
|
||||
return statuses['not_247']
|
||||
case 'timeout':
|
||||
return statuses['timeout']
|
||||
default:
|
||||
return statuses['online']
|
||||
}
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue