Parse season and episode for visionplus.id.

Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
Toha 2024-11-24 17:01:19 +07:00
parent 9ab13c3583
commit f6d53587f3
No known key found for this signature in database
GPG key ID: 2D7AA6389D44DCAB
4 changed files with 24 additions and 16 deletions

View file

@ -1 +1 @@
{"err":0,"mes":"OK","ver":1732325411000,"vie":"cd-events-grid-view","evs":[{"hd":true,"eid":"DLVY1765437886009340","sta":"2024-11-23T00:15:00Z","end":"2024-11-23T01:00:00Z","liv":false,"vid":[],"aul":["ENG"],"aud":[],"stl":[],"imb":false,"loc":[{"lan":""}],"pro":[],"con":{"cid":"STND3755114695006275","typ":"STANDALONE","oti":"Kiko","gid":["5;5;0;0"],"oda":"2014","dur":1800,"par":4,"categories":["Children/Cartoons","Children"],"str":0,"loc":[{"tit":"Kiko","lan":"ENG","syn":"Kiko tells of a child of a goldfish who is very independent, even though he is an only child. Kiko who is always cheerful has four good friends, namely Lola the discus fish, Ting Ting the crab, Patino the catfish and Poli the betta fish. On the other hand, the antagonists, Karkus the catfish and Pupus the eel, always make Kiko's life chaotic. One day, the lake where Kiko lives is polluted due to the reckless acts of humans, causing Kiko and friends to turn into mutants.","img":{"dir":"cn/14535","img_cnt":{"sna":{"s":1,"l":1,"m":1,"xl":1},"bac":{"l":1,"m":1},"pos":{"s":1,"l":1,"m":1,"xl":1},"blk":{"s":1,"l":1,"m":1,"xl":1}}}}],"cou":["IDN"],"lan":"ENG","adult":false,"srs":[],"ses":"0","ctn":["CATCHUP_GLOBAL"]},"ppv":false,"sid":"00000000000000000001","rep":false,"cas":"2024-11-23T01:05:00Z","cae":"2024-11-29T22:49:30Z","soa":true,"lan":["ENG - English"]}]}
{"err":0,"mes":"OK","ver":1732411811000,"vie":"cd-events-grid-view","evs":[{"hd":true,"eid":"DLVY0278042864001880","sta":"2024-11-23T23:30:00Z","end":"2024-11-24T00:15:00Z","liv":false,"vid":[],"aul":["ENG"],"aud":[],"stl":[],"imb":false,"loc":[{"lan":""}],"pro":[],"con":{"cid":"STND0277891997009717","typ":"STANDALONE","oti":"FBI: Most Wanted S4, Ep 18","gid":["11;15;10;0","11;1;0;0"],"oda":"2022","dur":3000,"par":7,"categories":["Series/Thriller","Series"],"str":0,"loc":[{"tit":"FBI: Most Wanted S4, Ep 18","lan":"ENG","syn":"After two agents from the Bureau of Land Management go missing while executing a land seizure warrant in Wyoming, the Fugitive Task Force heads west to track them down in an unwelcoming county.","img":{"dir":"cn/113495","img_cnt":{"sna":{"s":1,"l":1,"m":1,"xl":1},"bac":{"l":1,"m":1},"pos":{"s":1,"l":1,"m":1,"xl":1},"blk":{"s":1,"l":1,"m":1,"xl":1}}}}],"cou":["USA"],"lan":"ENG","adult":false,"srs":[],"ses":"0","ctn":["CATCHUP_GLOBAL"]},"ppv":false,"sid":"00000000000000000079","rep":false,"cas":"2024-11-24T00:20:00Z","cae":"2024-11-30T22:04:30Z","soa":true,"lan":["ENG - English"]}]}

View file

@ -1 +1 @@
{"err":0,"mes":"OK","ver":1732325411000,"vie":"cd-events-grid-view","evs":[{"hd":true,"eid":"DLVY1765437886009340","sta":"2024-11-23T00:15:00Z","end":"2024-11-23T01:00:00Z","liv":false,"vid":[],"aul":["ENG"],"aud":[],"stl":[],"loc":[{"lan":""}],"imb":false,"pro":[],"con":{"cid":"STND3755114695006275","typ":"STANDALONE","oti":"Kiko","gid":["5;5;0;0"],"oda":"2014","dur":1800,"par":4,"categories":["Children/Cartoons","Children"],"str":0,"loc":[{"tit":"Kiko","lan":"IND","syn":"Kiko, seekor anak ikan mas koki yang sangat mandiri, walaupun ia anak tunggal. Kiko selalu riang dan memiliki empat sahabat baik yaitu Lola si ikan diskus, Ting Ting si kepiting, Patino si ikan patin dan Poli si ikan cupang. Di sisi lain, sosok antagonis, Karkus si ikan lele dan Pupus si belut, selalu membuat ricuh kehidupan Kiko.","img":{"dir":"cn/14534","img_cnt":{"sna":{"s":1,"l":1,"m":1,"xl":1},"bac":{"l":1,"m":1},"pos":{"s":1,"l":1,"m":1,"xl":1},"blk":{"s":1,"l":1,"m":1,"xl":1}}}}],"cou":["IDN"],"lan":"IND","adult":false,"srs":[],"ses":"0","ctn":["CATCHUP_GLOBAL"]},"ppv":false,"sid":"00000000000000000001","rep":false,"cas":"2024-11-23T01:05:00Z","cae":"2024-11-29T22:49:30Z","soa":true,"lan":["ENG - English"]}]}
{"err":0,"mes":"OK","ver":1732411811000,"vie":"cd-events-grid-view","evs":[{"hd":true,"eid":"DLVY0278042864001880","sta":"2024-11-23T23:30:00Z","end":"2024-11-24T00:15:00Z","liv":false,"vid":[],"aul":["ENG"],"aud":[],"stl":[],"loc":[{"lan":""}],"imb":false,"pro":[],"con":{"cid":"STND0277891997009717","typ":"STANDALONE","oti":"FBI: Most Wanted S4, Ep 18","gid":["11;15;10;0","11;1;0;0"],"oda":"2022","dur":3000,"par":7,"categories":["Series/Thriller","Series"],"str":0,"loc":[{"tit":"FBI: Most Wanted S4, Ep 18","lan":"IND","syn":"Satgas Buronan pergi ke wilayah barat untuk melacak keberadaan dua petugas Biro Pengelolaan Lahan yang menghilang saat menjalankan perintah penyitaan lahan di negara bagian yang tak ramah, Wyoming.","img":{"dir":"cn/113494","img_cnt":{"sna":{"s":1,"l":1,"m":1,"xl":1},"bac":{"l":1,"m":1},"pos":{"s":1,"l":1,"m":1,"xl":1},"blk":{"s":1,"l":1,"m":1,"xl":1}}}}],"cou":["USA"],"lan":"IND","adult":false,"srs":[],"ses":"0","ctn":["CATCHUP_GLOBAL"]},"ppv":false,"sid":"00000000000000000079","rep":false,"cas":"2024-11-24T00:20:00Z","cae":"2024-11-30T22:04:30Z","soa":true,"lan":["ENG - English"]}]}

View file

@ -28,10 +28,14 @@ module.exports = {
if (Array.isArray(json.evs)) {
for (const ev of json.evs) {
if (ev.sid === channel.site_id) {
const title = ev.con && ev.con.loc ? ev.con.loc[0].tit : ev.con.oti
const [, , season, , episode] = title.match(/( S(\d+))?(, Ep (\d+))/) || [null, null, null, null, null]
programs.push({
title: ev.con && ev.con.loc ? ev.con.loc[0].tit : ev.con.oti,
title,
description: ev.con && ev.con.loc ? ev.con.loc[0].syn : null,
categories: ev.con ? ev.con.categories : null,
season: season ? parseInt(season) : season,
episode: episode ? parseInt(episode) : episode,
start: dayjs(ev.sta),
stop: dayjs(ev.end)
})

View file

@ -9,10 +9,10 @@ dayjs.extend(utc)
jest.mock('axios')
const date = dayjs.utc('2024-11-23', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2024-11-24', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '00000000000000000001',
xmltv_id: 'RCTI.id',
site_id: '00000000000000000079',
xmltv_id: 'AXN.id',
lang: 'en'
}
const channelId = { ...channel, lang: 'id' }
@ -20,10 +20,10 @@ const channelId = { ...channel, lang: 'id' }
it('can generate valid url', () => {
expect(url({ channel, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=ENG&serviceId=00000000000000000001&start=2024-11-23T00%3A00%3A00Z&end=2024-11-24T00%3A00%3A00Z&view=cd-events-grid-view'
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=ENG&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
expect(url({ channel: channelId, date })).toBe(
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=IND&serviceId=00000000000000000001&start=2024-11-23T00%3A00%3A00Z&end=2024-11-24T00%3A00%3A00Z&view=cd-events-grid-view'
'https://www.visionplus.id/managetv/tvinfo/events/schedule?language=IND&serviceId=00000000000000000079&start=2024-11-24T00%3A00%3A00Z&end=2024-11-25T00%3A00%3A00Z&view=cd-events-grid-view'
)
})
@ -38,10 +38,12 @@ it('can parse response', () => {
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T00:15:00.000Z',
stop: '2024-11-23T01:00:00.000Z',
title: 'Kiko',
description: "Kiko tells of a child of a goldfish who is very independent, even though he is an only child. Kiko who is always cheerful has four good friends, namely Lola the discus fish, Ting Ting the crab, Patino the catfish and Poli the betta fish. On the other hand, the antagonists, Karkus the catfish and Pupus the eel, always make Kiko's life chaotic. One day, the lake where Kiko lives is polluted due to the reckless acts of humans, causing Kiko and friends to turn into mutants."
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description: 'After two agents from the Bureau of Land Management go missing while executing a land seizure warrant in Wyoming, the Fugitive Task Force heads west to track them down in an unwelcoming county.',
season: 4,
episode: 18
})
content = fs.readFileSync(path.resolve(__dirname, '__data__/content_id.json'))
@ -54,10 +56,12 @@ it('can parse response', () => {
expect(results.length).toBe(1)
expect(results[0]).toMatchObject({
start: '2024-11-23T00:15:00.000Z',
stop: '2024-11-23T01:00:00.000Z',
title: 'Kiko',
description: 'Kiko, seekor anak ikan mas koki yang sangat mandiri, walaupun ia anak tunggal. Kiko selalu riang dan memiliki empat sahabat baik yaitu Lola si ikan diskus, Ting Ting si kepiting, Patino si ikan patin dan Poli si ikan cupang. Di sisi lain, sosok antagonis, Karkus si ikan lele dan Pupus si belut, selalu membuat ricuh kehidupan Kiko.'
start: '2024-11-23T23:30:00.000Z',
stop: '2024-11-24T00:15:00.000Z',
title: 'FBI: Most Wanted S4, Ep 18',
description: 'Satgas Buronan pergi ke wilayah barat untuk melacak keberadaan dua petugas Biro Pengelolaan Lahan yang menghilang saat menjalankan perintah penyitaan lahan di negara bagian yang tak ramah, Wyoming.',
season: 4,
episode: 18
})
})