From cb863682b10962d2c29f9efb57b4d2a2722b9d32 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:17:38 +0300 Subject: [PATCH 1/4] Delete readme.md --- sites/tva.tv/readme.md | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 sites/tva.tv/readme.md diff --git a/sites/tva.tv/readme.md b/sites/tva.tv/readme.md deleted file mode 100644 index 871bcdc2..00000000 --- a/sites/tva.tv/readme.md +++ /dev/null @@ -1,21 +0,0 @@ -# tva.tv - -https://tva.tv/ - -### Download the guide - -```sh -npm run grab --- --site=tva.tv -``` - -### Update channel list - -```sh -npm run channels:parse --- --config=./sites/tva.tv/tva.tv.config.js --output=./sites/tva.tv/tva.tv.channels.xml -``` - -### Test - -```sh -npm test --- tva.tv -``` From 791179daf6d00ff3abd8a537c0c1aa89aa58f5f2 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:17:51 +0300 Subject: [PATCH 2/4] Delete tva.tv.channels.xml --- sites/tva.tv/tva.tv.channels.xml | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 sites/tva.tv/tva.tv.channels.xml diff --git a/sites/tva.tv/tva.tv.channels.xml b/sites/tva.tv/tva.tv.channels.xml deleted file mode 100644 index 62440b20..00000000 --- a/sites/tva.tv/tva.tv.channels.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - Doc TV - Hamedan TV - IRIB 1 - IRIB 2 - IRIB 3 - IRIB 4 - IRIB 5 - Omid TV - IRINN - Irkala TV - Jame-Jam TV Network 1 - Khorasan Razavi TV - Namayesh TV - Nasim - Salaam TV - Sepehr - Taban TV - TVA 1 - TVA 2 - TVA Avand - TVA Bourse - TVA Film - TVA Kids - TVA Mahfel - TVA Nava - TVA Sport - TVA Sport 2 - Velayat TV Network - \ No newline at end of file From 62640b33711d4e484b30c4c1a6fcf353262f654d Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:18:04 +0300 Subject: [PATCH 3/4] Delete tva.tv.config.js --- sites/tva.tv/tva.tv.config.js | 58 ----------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 sites/tva.tv/tva.tv.config.js diff --git a/sites/tva.tv/tva.tv.config.js b/sites/tva.tv/tva.tv.config.js deleted file mode 100644 index 41b9a756..00000000 --- a/sites/tva.tv/tva.tv.config.js +++ /dev/null @@ -1,58 +0,0 @@ -const axios = require('axios') -const dayjs = require('dayjs') - -module.exports = { - site: 'tva.tv', - days: 2, - url: function ({ date, channel }) { - return `https://api.ott.tva.tv/v2/epg/program_events.json?channel_id=${ - channel.site_id - }&pivot_date=${date.format('YYYY-MM-DD')}` - }, - parser: function ({ content }) { - const programs = [] - const items = parseItems(content) - items.forEach(item => { - programs.push({ - title: item.name, - description: item.description, - start: dayjs(item.start_at), - stop: dayjs(item.end_at) - }) - }) - - return programs - }, - async channels() { - const data = await axios - .get( - 'https://api.ott.tva.tv/v1/channels?client_id=66797942-ff54-46cb-a109-3bae7c855370&client_version=0.0.1&expand%5Bchannel%5D=images&locale=en-GB&page%5Blimit%5D=100&page%5Boffset%5D=0&timezone=10800', - { - headers: { - Origin: 'https://tva.tv' - } - } - ) - .then(r => r.data) - .catch(console.log) - - const channels = [] - for (let item of data.data) { - channels.push({ - lang: 'fa', - site_id: item.id, - name: item.name, - xmltv_id: item.slug - }) - } - - return channels - } -} - -function parseItems(content) { - const data = JSON.parse(content) - if (!data || !Array.isArray(data.data)) return [] - - return data.data -} From 96704b45de2a3acfd522d8237eae50face9c5e9c Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sun, 19 Jan 2025 17:18:18 +0300 Subject: [PATCH 4/4] Delete tva.tv.test.js --- sites/tva.tv/tva.tv.test.js | 47 ------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 sites/tva.tv/tva.tv.test.js diff --git a/sites/tva.tv/tva.tv.test.js b/sites/tva.tv/tva.tv.test.js deleted file mode 100644 index 9ccb72fd..00000000 --- a/sites/tva.tv/tva.tv.test.js +++ /dev/null @@ -1,47 +0,0 @@ -const { parser, url } = require('./tva.tv.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('2021-11-25', 'YYYY-MM-DD').startOf('d') -const channel = { - site_id: '6fcc0a2e-1135-482c-b054-08a96e68b758', - xmltv_id: 'IRIB2.ir' -} -const content = - '{"data":[{"id":"c0667229-eaf8-472f-8ba7-ad4417348baf","start_at":"2021-11-24T00:20:39.000Z","end_at":"2021-11-24T00:32:11.000Z","description":"تلفن های شبکه 5 سیما: تلفن: 23511000 -تلفن گویا:2786500 نمابر:23511289","name":"میان برنامه","subtitle":"","season_number":null,"episode_number":null,"channel_id":"6fcc0a2e-1135-482c-b054-08a96e68b758","program_id":"e495c06e-80de-46ee-9120-619631f554d9","competition_id":null,"object":"program_event","cast_members":[],"genres":[],"images":[],"program_type":null,"certification_ratings":[]}]}' - -it('can generate valid url', () => { - expect(url({ channel, date })).toBe( - 'https://api.ott.tva.tv/v2/epg/program_events.json?channel_id=6fcc0a2e-1135-482c-b054-08a96e68b758&pivot_date=2021-11-25' - ) -}) - -it('can parse response', () => { - const result = parser({ content, channel, date }).map(p => { - p.start = p.start.toJSON() - p.stop = p.stop.toJSON() - return p - }) - - expect(result).toMatchObject([ - { - start: '2021-11-24T00:20:39.000Z', - stop: '2021-11-24T00:32:11.000Z', - title: 'میان برنامه', - description: 'تلفن های شبکه 5 سیما: تلفن: 23511000 -تلفن گویا:2786500 نمابر:23511289' - } - ]) -}) - -it('can handle empty guide', () => { - const result = parser({ - date, - channel, - content: - '{"errors":[{"id":"ebbebfb7-ffb0-4e0b-bcfb-1d9cd3e6c03c","code":"not_found","links":{"about":{"href":"https://app.bugsnag.com/jeytv/API/errors?filters[event.since][]=30d&filters[user.name][]=ebbebfb7-ffb0-4e0b-bcfb-1d9cd3e6c03c"}},"title":"Requested resource was not found","fallback_message":null,"object":"error"}],"meta":{"status":404}}' - }) - expect(result).toMatchObject([]) -})