mirror of
https://github.com/iptv-org/iptv.git
synced 2025-05-13 10:30:03 -04:00
Update db.js
This commit is contained in:
parent
2cbd5e546d
commit
2fa712c1ad
1 changed files with 25 additions and 0 deletions
|
@ -8,6 +8,7 @@ db.load = function () {
|
|||
const items = parser.parseIndex()
|
||||
for (const item of items) {
|
||||
const playlist = parser.parsePlaylist(item.url)
|
||||
db.playlists.add(playlist)
|
||||
for (const channel of playlist.channels) {
|
||||
db.channels.add(channel)
|
||||
|
||||
|
@ -166,4 +167,28 @@ db.categories = {
|
|||
}
|
||||
}
|
||||
|
||||
db.playlists = {
|
||||
list: [],
|
||||
add(playlist) {
|
||||
this.list.push(playlist)
|
||||
},
|
||||
all() {
|
||||
return this.list
|
||||
},
|
||||
only(list = []) {
|
||||
return this.list.filter(playlist => list.includes(playlist.name))
|
||||
},
|
||||
except(list = []) {
|
||||
return this.list.filter(playlist => !list.includes(playlist.name))
|
||||
},
|
||||
sortBy(fields) {
|
||||
this.list = utils.sortBy(this.list, fields)
|
||||
|
||||
return this
|
||||
},
|
||||
count() {
|
||||
return this.list.length
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = db
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue