From 6138c472aca777ce190123a43ed0fd9832118999 Mon Sep 17 00:00:00 2001 From: fraudiay79 <60631277+fraudiay79@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:55:28 -0500 Subject: [PATCH 1/5] Create galamtv.kz.config.js --- sites/galamtv.kz/galamtv.kz.config.js | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sites/galamtv.kz/galamtv.kz.config.js diff --git a/sites/galamtv.kz/galamtv.kz.config.js b/sites/galamtv.kz/galamtv.kz.config.js new file mode 100644 index 00000000..98b1562b --- /dev/null +++ b/sites/galamtv.kz/galamtv.kz.config.js @@ -0,0 +1,64 @@ +const axios = require('axios') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(utc) +dayjs.extend(timezone) +dayjs.extend(customParseFormat) + +module.exports = { + site: 'galamtv.kz', + timezone: 'Asia/Almaty', + days: 2, + request: { + method: 'GET', + headers: { + Referer: 'https://galamtv.kz/', + Origin: 'https://galamtv.kz', + Accept: '*/*', + 'Accept-Encoding': 'gzip, deflate, br, zstd', + } + }, + url({ channel, date }) { + const todayEpoch = date.startOf('day').unix() + const nextDayEpoch = date.add(1, 'day').startOf('day').unix() + return `https://galam.server-api.lfstrm.tv/channels/${channel.site_id}/programs?period=${todayEpoch}:${nextDayEpoch}` + }, + parser: function({ content }) { + let programs = [] + const data = JSON.parse(content) + const programsData = data.programs || [] + + programsData.forEach(program => { + const start = dayjs.unix(program.scheduleInfo.start) + const stop = dayjs.unix(program.scheduleInfo.end) + + programs.push({ + title: program.metaInfo.title, + description: program.metaInfo.description, + image: program.mediaInfo.thumbnails[0].url, + start, + stop + }) + }) + + return programs + }, + async channels() { + try { + const response = await axios.get(`https://galam.server-api.lfstrm.tv/channels-now`) + return response.data.channels.map(item => { + return { + lang: 'kk', + site_id: item.channels.id, + name: item.channels.info.metaInfo.title + } + }) + } catch (error) { + console.error('Error fetching channels:', error) + return [] + } + } +} From 156adee9799a2def1cecd257a16e812099b6ab89 Mon Sep 17 00:00:00 2001 From: fraudiay79 <60631277+fraudiay79@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:55:54 -0500 Subject: [PATCH 2/5] Create galamtv.kz.channels.xml --- sites/galamtv.kz/galamtv.kz.channels.xml | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sites/galamtv.kz/galamtv.kz.channels.xml diff --git a/sites/galamtv.kz/galamtv.kz.channels.xml b/sites/galamtv.kz/galamtv.kz.channels.xml new file mode 100644 index 00000000..f2a04103 --- /dev/null +++ b/sites/galamtv.kz/galamtv.kz.channels.xml @@ -0,0 +1,30 @@ + + + Qazaqstan + Хабар + 24KZ + Balapan + Munara TV + Turan TV + Седьмой канал + 31 Канал + Ел Арна + Almaty TV + Jibek Joly + Новое Телевидение + Жетысу + твоЁтв + Мир 24 + Hit TV + Первый канал Евразия + Atameken Business + ТДК 42 + КТК + Мир + TRT Avaz + Turkistan + Astana TV + НТК + Caspian News + INSPORT + From 0ef69335a2847a17eee75ec745cec6eaaefc0ec1 Mon Sep 17 00:00:00 2001 From: fraudiay79 <60631277+fraudiay79@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:57:01 -0500 Subject: [PATCH 3/5] Create galamtv.kz.test.js --- sites/galamtv.kz/galamtv.kz.test.js | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sites/galamtv.kz/galamtv.kz.test.js diff --git a/sites/galamtv.kz/galamtv.kz.test.js b/sites/galamtv.kz/galamtv.kz.test.js new file mode 100644 index 00000000..e3445c5a --- /dev/null +++ b/sites/galamtv.kz/galamtv.kz.test.js @@ -0,0 +1,66 @@ +const { parser, url, channels } = require('./galamtv.kz.config.js') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const customParseFormat = require('dayjs/plugin/customParseFormat') + +dayjs.extend(customParseFormat) +dayjs.extend(utc) + +const date = dayjs.utc('2025-01-10', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '636e54cf8a8f73bae8244f41', + xmltv_id: 'Qazaqstan.kz' +} + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe(`https://galam.server-api.lfstrm.tv/channels/${channel.site_id}/programs?period=${date.unix()}:${date.add(1, 'day').unix()}`) +}) + +it('can parse response', () => { + const content = JSON.stringify({ + programs: [ + { + metaInfo: { + title: "Гимн", + description: "Государственный гимн Республики Казахстан" + }, + scheduleInfo: { + start: 1736470800, + end: 1736471100 + }, + mediaInfo: { + thumbnails: [ + { + url: "http://galam.server-img.lfstrm.tv:80/image/aHR0cDovL2dhbGFtLmltZy1vcmlnaW5hbHMubGZzdHJtLnR2OjgwL3R2aW1hZ2VzL3RodW1iL2YyNWFmYWY2ZDkzYjU5YjdkMjBiZDNiODhiZjg4NWI0X29yaWcuanBn" + } + ] + } + } + ] + }) + + const result = parser({ content, channel }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2025-01-10T01:00:00.000Z', + stop: '2025-01-10T01:05:00.000Z', + title: 'Гимн', + description: 'Государственный гимн Республики Казахстан', + image: 'http://galam.server-img.lfstrm.tv:80/image/aHR0cDovL2dhbGFtLmltZy1vcmlnaW5hbHMubGZzdHJtLnR2OjgwL3R2aW1hZ2VzL3RodW1iL2YyNWFmYWY2ZDkzYjU5YjdkMjBiZDNiODhiZjg4NWI0X29yaWcuanBn', + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: '{"programs":[]}' + }) + expect(result).toMatchObject([]) +}) From 8c73df923b811ed38aeea5ede61c2c7b38fa7727 Mon Sep 17 00:00:00 2001 From: fraudiay79 <60631277+fraudiay79@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:59:19 -0500 Subject: [PATCH 4/5] Create readme.md --- sites/galamtv.kz/readme.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sites/galamtv.kz/readme.md diff --git a/sites/galamtv.kz/readme.md b/sites/galamtv.kz/readme.md new file mode 100644 index 00000000..e72c39f3 --- /dev/null +++ b/sites/galamtv.kz/readme.md @@ -0,0 +1,21 @@ +# galamtv.kz + +https://galamtv.kz/channels/now + +### Download the guide + +```sh +npm run grab --- --site=galamtv.kz +``` + +### Update channel list + +```sh +npm run channels:parse --- --config=./sites/galamtv.kz/galamtv.kz.config.js --output=./sites/galamtv.kz/galamtv.kz.channels.xml +``` + +### Test + +```sh +npm test --- galamtv.kz +``` From 92d0afcb792e15ac18e20351bc59159e86489410 Mon Sep 17 00:00:00 2001 From: PopeyeTheSai10r <107763146+PopeyeTheSai10r@users.noreply.github.com> Date: Wed, 15 Jan 2025 15:41:19 -0800 Subject: [PATCH 5/5] Update galamtv.kz.config.js