Merge pull request #103 from iptv-org/add-tv-mail-ru

Add guide from tv.mail.ru
This commit is contained in:
Shadix A 2021-09-26 17:56:12 +03:00 committed by GitHub
commit a8d3b489d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 117 additions and 0 deletions

View file

@ -36,6 +36,7 @@ jobs:
telkussa.fi,
tv.cctv.com,
tv.lv,
tv.mail.ru,
tv.yandex.ru,
tvgid.ua,
tvguide.com,

View file

@ -23,6 +23,7 @@ To load a program guide, all you need to do is copy the link to one of the guide
<tr><td align="left" nowrap>🇩🇿 Algeria</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/elcinema.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇱 Albania</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tvprofil.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇩 Andorra</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/andorradifusio.ad.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇲 Armenia</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tv.mail.ru.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇴 Angola</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/zap.co.ao.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇦🇺 Australia</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/ontvtonight.com.guide.xml</code></td></tr>
<tr><td align="left" nowrap>🇧🇾 Belarus</td><td align="left" nowrap><code>https://iptv-org.github.io/epg/guides/tv.yandex.ru.guide.xml</code></td></tr>

26
sites/tv.mail.ru.channels.xml Executable file
View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<site site="tv.mail.ru">
<channels>
<channel site_id="1641" xmltv_id="ShantTV.am" lang="ru">Shant TV</channel>
<channel site_id="2255" xmltv_id="ArmeniaTV.am" lang="hy">Armenia TV</channel>
<channel site_id="2499" xmltv_id="ArmNews.am" lang="hy">ArmNews</channel>
<channel site_id="2499" xmltv_id="ShantMusic.am" lang="hy">Shant Music</channel>
<channel site_id="2708" xmltv_id="ShantSerial.am" lang="hy">Shant Serial</channel>
<channel site_id="2785" xmltv_id="21TV.am" lang="hy">21TV</channel>
<channel site_id="2787" xmltv_id="YerkirMediaTV.am" lang="hy">Yerkir Media TV</channel>
<channel site_id="2788" xmltv_id="KentronTV.am" lang="hy">Kentron TV</channel>
<channel site_id="2791" xmltv_id="ShoghakatTV.am" lang="hy">Shoghakat TV</channel>
<channel site_id="2861" xmltv_id="5TV.am" lang="hy">5TV</channel>
<channel site_id="2862" xmltv_id="NorHayastanTV.am" lang="hy">Nor Hayastan TV</channel>
<channel site_id="2870" xmltv_id="MuzZoneTV.kz" lang="hy">MuzZone TV</channel>
<channel site_id="2944" xmltv_id="ATV.am" lang="hy">ATV</channel>
<channel site_id="2947" xmltv_id="ATVHayTV.us" lang="hy">ATV Hay TV</channel>
<channel site_id="2951" xmltv_id="ATVFilmzone.am" lang="hy">ATV Filmzone</channel>
<channel site_id="2953" xmltv_id="ATVTavaTV.am" lang="hy">ATV Tava TV</channel>
<channel site_id="2967" xmltv_id="ATVKhaghaliqTV.am" lang="hy">ATV Khaghaliq TV</channel>
<channel site_id="2968" xmltv_id="ATVKinoman.am" lang="hy">ATV Kinoman</channel>
<channel site_id="2969" xmltv_id="TBNArmenia.us" lang="hy">TBN Armenia</channel>
<channel site_id="2995" xmltv_id="H1.am" lang="hy">H1</channel>
<channel site_id="3010" xmltv_id="ATVBazmocTV.am" lang="hy">ATV Bazmoc TV</channel>
</channels>
</site>

View file

@ -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]
}