Update editor.ts

This commit is contained in:
freearhey 2023-11-17 16:41:14 +03:00
parent 4aeef51c10
commit d310ff388d

View file

@ -29,7 +29,7 @@ async function main() {
const parser = new ChannelsParser({ storage }) const parser = new ChannelsParser({ storage })
const parsedChannels = await parser.parse(filepath) const parsedChannels = await parser.parse(filepath)
options = parsedChannels.map((channel: Channel) => { options = parsedChannels.map((channel: Channel): { channel: Channel; delete: boolean } => {
return { return {
channel, channel,
delete: false delete: false
@ -41,18 +41,18 @@ async function main() {
const channels = new Collection(channelsContent).map(data => new ApiChannel(data)) const channels = new Collection(channelsContent).map(data => new ApiChannel(data))
const buffer = new Dictionary() const buffer = new Dictionary()
options.forEach(async (option: { channel: Channel; delete: boolean }) => { for (let option of options.all()) {
const channel = option.channel const channel: Channel = option.channel
if (channel.xmltv_id) { if (channel.xmltv_id) {
if (channel.xmltv_id !== '-') { if (channel.xmltv_id !== '-') {
buffer.set(`${channel.xmltv_id}/${channel.lang}`, true) buffer.set(`${channel.xmltv_id}/${channel.lang}`, true)
} }
return continue
} }
const choices = getOptions(channels, channel) const choices = getOptions(channels, channel)
const question: QuestionCollection = { const question: QuestionCollection = {
name: 'option', name: 'option',
message: 'Choose an option:', message: `Choose xmltv_id for "${channel.name}" (${channel.site_id}):`,
type: 'list', type: 'list',
choices, choices,
pageSize: 10 pageSize: 10
@ -103,7 +103,7 @@ async function main() {
} }
} }
}) })
}) }
} }
main() main()
@ -154,7 +154,7 @@ function getOptions(channels: Collection, channel: Channel) {
const closed = _channel.closed ? `[closed:${_channel.closed}]` : '' const closed = _channel.closed ? `[closed:${_channel.closed}]` : ''
const replacedBy = _channel.replacedBy ? `[replaced_by:${_channel.replacedBy}]` : '' const replacedBy = _channel.replacedBy ? `[replaced_by:${_channel.replacedBy}]` : ''
variants.add(`${_channel.name}${altNames} | ${_channel.id} ${closed}${replacedBy}[api]`) variants.add(`${_channel.name}${altNames} | ${_channel.id}${closed}${replacedBy}`)
}) })
variants.add('Overwrite') variants.add('Overwrite')
variants.add('Skip') variants.add('Skip')