Merge branch 'patch-2025.03.1' into patch-2025.03.2

This commit is contained in:
freearhey 2025-03-21 02:53:50 +03:00
commit 99c4f4b621
4 changed files with 33 additions and 9 deletions

View file

@ -79,15 +79,13 @@ async function main() {
for (const [i, row] of rowsCopy.entries()) {
fileErrors = fileErrors.concat(validateChannelId(row, i))
fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i))
fileErrors = fileErrors.concat(validateReplacedBy(row, i))
fileErrors = fileErrors.concat(
checkValue(i, row, 'id', 'subdivision', buffer.get('subdivisions'))
)
fileErrors = fileErrors.concat(
checkValue(i, row, 'id', 'categories', buffer.get('categories'))
)
fileErrors = fileErrors.concat(
checkValue(i, row, 'id', 'replaced_by', buffer.get('channels'))
)
fileErrors = fileErrors.concat(
checkValue(i, row, 'id', 'languages', buffer.get('languages'))
)
@ -102,9 +100,7 @@ async function main() {
for (const [i, row] of rowsCopy.entries()) {
fileErrors = fileErrors.concat(validateChannel(row.channel, i))
fileErrors = fileErrors.concat(validateTimezones(row, i))
fileErrors = fileErrors.concat(
checkValue(i, row, 'id', 'replaced_by', buffer.get('channels'))
)
fileErrors = fileErrors.concat(validateReplacedBy(row, i))
}
break
case 'blocklist':
@ -198,6 +194,30 @@ function checkValue(
return errors
}
function validateReplacedBy(row: { [key: string]: string }, i: number) {
const errors = new Collection()
if (!row.replaced_by) return errors
const channels = buffer.get('channels')
const feeds = buffer.get('feeds')
const [channelId, feedId] = row.replaced_by.split('@')
if (channels.missing(channelId)) {
errors.push({
line: i + 2,
message: `"${row.id}" has an invalid replaced_by "${row.replaced_by}"`
})
} else if (feedId && feeds.missing(channelId + feedId)) {
errors.push({
line: i + 2,
message: `"${row.id}" has an invalid replaced_by "${row.replaced_by}"`
})
}
return errors
}
function validateChannel(channelId: string, i: number) {
const errors = new Collection()
const channels = buffer.get('channels')

View file

@ -1,2 +1,2 @@
id,name,alt_names,network,owners,country,subdivision,city,broadcast_area,languages,categories,is_nsfw,launched,closed,replaced_by,website,logo
002RadioTV.do,002 Radio TV,,,,DO,,,c/DO,spa,,FALSE,,,,ttps://www.002radio.com/,https://i.imgur.com/7oNe8xj.png
002RadioTV.do,002 Radio TV,,,,DO,,,c/DO,spa,,FALSE,,,002RadioTV.do@4K,ttps://www.002radio.com/,https://i.imgur.com/7oNe8xj.png
1 id name alt_names network owners country subdivision city broadcast_area languages categories is_nsfw launched closed replaced_by website logo
2 002RadioTV.do 002 Radio TV DO c/DO spa FALSE 002RadioTV.do@4K ttps://www.002radio.com/ https://i.imgur.com/7oNe8xj.png

View file

@ -1,4 +1,5 @@
channel,id,name,is_main,broadcast_area,timezones,languages,video_format,launched,closed,replaced_by
KSTVKids.ua,HD,HD,TRUE,c/UA,America/Santo_Domingo,ukr,480i,,,
PeoplesWeather.do,SD,SD,TRUE,c/DO,America/Santo_Domingo,spa,480i,,,
PeoplesWeather.do,HD,HD,FALSE,c/DO,America/Santo_Domingo,spa,1080i,,,KSTVKids.ua
PeoplesWeather.do,HD,HD,FALSE,c/DO,America/Santo_Domingo,spa,1080i,,,KSTVKids.ua@HD
PeoplesWeather.do,West,West,FALSE,c/DO,America/Santo_Domingo,spa,1080i,,,
1 channel id name is_main broadcast_area timezones languages video_format launched closed replaced_by
2 KSTVKids.ua HD HD TRUE c/UA America/Santo_Domingo ukr 480i
3 PeoplesWeather.do SD SD TRUE c/DO America/Santo_Domingo spa 480i
4 PeoplesWeather.do HD HD FALSE c/DO America/Santo_Domingo spa 1080i KSTVKids.ua KSTVKids.ua@HD
5 PeoplesWeather.do West West FALSE c/DO America/Santo_Domingo spa 1080i

View file

@ -61,6 +61,9 @@ describe('db:validate', () => {
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain('"aaa.us" is missing in the channels.csv')
expect((error as ExecError).stdout).toContain(
'"002RadioTV.do" has an invalid replaced_by "002RadioTV.do@4K"'
)
expect((error as ExecError).stdout).toContain(
'002RadioTV.do: "website" must be a valid uri with a scheme matching the http|https pattern'
)
@ -75,7 +78,7 @@ describe('db:validate', () => {
expect((error as ExecError).stdout).toContain(
'SD: "video_format" with value "576I" fails to match the required pattern'
)
expect((error as ExecError).stdout).toContain('7 error(s)')
expect((error as ExecError).stdout).toContain('8 error(s)')
}
})