diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index 5b4d7407..dc2bdfdf 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -36,6 +36,7 @@ jobs: telkussa.fi, tv.cctv.com, tv.lv, + tv.mail.ru, tv.yandex.ru, tvgid.ua, tvguide.com, diff --git a/README.md b/README.md index bbceed1a..821c1c6b 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ To load a program guide, all you need to do is copy the link to one of the guide 🇩🇿 Algeriahttps://iptv-org.github.io/epg/guides/elcinema.com.guide.xml 🇦🇱 Albaniahttps://iptv-org.github.io/epg/guides/tvprofil.com.guide.xml 🇦🇩 Andorrahttps://iptv-org.github.io/epg/guides/andorradifusio.ad.guide.xml + 🇦🇲 Armeniahttps://iptv-org.github.io/epg/guides/tv.mail.ru.guide.xml 🇦🇴 Angolahttps://iptv-org.github.io/epg/guides/zap.co.ao.guide.xml 🇦🇺 Australiahttps://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml 🇧🇾 Belarushttps://iptv-org.github.io/epg/guides/tv.yandex.ru.guide.xml diff --git a/sites/tv.mail.ru.channels.xml b/sites/tv.mail.ru.channels.xml new file mode 100755 index 00000000..cd3f2290 --- /dev/null +++ b/sites/tv.mail.ru.channels.xml @@ -0,0 +1,26 @@ + + + + Shant TV + Armenia TV + ArmNews + Shant Music + Shant Serial + 21TV + Yerkir Media TV + Kentron TV + Shoghakat TV + 5TV + Nor Hayastan TV + MuzZone TV + ATV + ATV Hay TV + ATV Filmzone + ATV Tava TV + ATV Khaghaliq TV + ATV Kinoman + TBN Armenia + H1 + ATV Bazmoc TV + + \ No newline at end of file diff --git a/sites/tv.mail.ru.config.js b/sites/tv.mail.ru.config.js new file mode 100644 index 00000000..ed77ca6e --- /dev/null +++ b/sites/tv.mail.ru.config.js @@ -0,0 +1,89 @@ +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 = { + lang: 'ru', + days: 3, + site: 'tv.mail.ru', + channels: 'tv.mail.ru.channels.xml', + output: '.gh-pages/guides/tv.mail.ru.guide.xml', + url({ channel, date }) { + return `https://tv.mail.ru/ajax/channel/?region_id=70&channel_id=${ + channel.site_id + }&date=${date.format('YYYY-MM-DD')}` + }, + logo({ content }) { + const json = JSON.parse(content) + if (json.status !== 'OK') return null + + return json.schedule[0].channel.pic_url_64 + }, + parser({ content, date }) { + let PM = false + const programs = [] + const items = parseItems(content) + items.forEach(item => { + const title = parseTitle(item) + const category = parseCategory(item) + let start = parseStart(item, date) + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + const stop = start.add(1, 'h') + if (programs.length) { + programs[programs.length - 1].stop = start + } + + programs.push({ + title, + category, + start, + stop + }) + }) + + return programs + } +} + +function parseStart(item, date) { + const time = `${date.format('MM/DD/YYYY')} ${item.start}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Moscow') +} + +function parseTitle(item) { + return item.name +} + +function parseCategory(item) { + const categories = { + 1: 'Фильм', + 2: 'Сериал', + 6: 'Документальное', + 8: 'Позновательное', + 10: 'Другое', + 14: 'ТВ-шоу', + 16: 'Досуг,Хобби', + 17: 'Ток-шоу', + 18: 'Юмористическое', + 24: 'Развлекательное', + 25: 'Игровое', + 26: 'Новости' + } + + return categories[item.category_id] || null +} + +function parseItems(content) { + const json = JSON.parse(content) + if (json.status !== 'OK') return [] + const event = json.schedule[0].event + + return [...event.past, ...event.current] +}