diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index 6d6ef89f..cfbae66e 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -18,7 +18,6 @@ jobs: hd-plus.de, astro.com.my, comteco.com.bo, - albepg.com, mi.tv, meo.pt, tvgid.ua, @@ -36,6 +35,7 @@ jobs: tvtv.us, tv.lv, vidio.com, + tvguide.com, tvprofil.com ] steps: diff --git a/codes.csv b/codes.csv index 2ae650d2..998dbacc 100644 --- a/codes.csv +++ b/codes.csv @@ -858,6 +858,7 @@ beIN Sports 11,beINSports11.qa beIN Sports 12,beINSports12.qa beIN Sports 13,beINSports13.qa beIN Sports 2,beINSports2.qa +beIN Sports 2 Asia,beINSports2Asia.qa beIN Sports 3,beINSports3.qa beIN Sports Canada,beINSportsCanada.qa beIN Sports en Español,beINSportsenEspanol.qa diff --git a/sites/albepg.com.channels.xml b/sites/albepg.com.channels.xml deleted file mode 100755 index 15864a2d..00000000 --- a/sites/albepg.com.channels.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - 21 Junior - 21 Popullore - 24 Kitchen Srbija - 3 Plus - ABC News - AlbUK TV - Alsat - Animal Planet Europe - Arena Sport 1 - Arena Sport 2 - Arena Sport 3 - Arena Sport 4 - Arta - BBF Music TV - BabyTV Europe - Balkanika TV - Bang Bang - Boomerang EMEA - Click TV - Discovery Channel Bulgaria - Elrodi TV - Euronews Albania - Eurosport 1 - Explorer Histori - Explorer Natyra - Explorer Shkencë - Family HD - FashionTV Europe - Film Aksion - Film Drame - Film Dy HD - Film Hits - Film Hits +1 - Film Komedi - Film Një HD - Film Thriller - Folk+ - Fox Life Regional - Fox Srbija - In TV - Investigation Discovery Europe - Junior TV - Kanal 10 - Kanal D Drama - Kanali 7 - Klan Kosova - Klan Macedonia - Klan Plus - Kohavision - Living HD - MFM - MTV Live HD - Muse - My Music - National Geographic Channel HD Europe - Nesër TV - News 24 - On-TV - Ora News - Peace TV English - RTSH 1 - RTSH 2 - RTSH 3 - RTSH Agro - RTSH Femije - RTSH Film - RTSH Korca - RTSH Muzikë - RTSH Plus - RTSH Shkolle - RTSH Shqip - RTSH Sport - RTV21 - STV Folk - Stinët - Super Sonic TV - SuperSport 1 - SuperSport 2 - SuperSport 3 - SuperSport 4 - SuperSport 5 - SuperSport 6 - SuperSport Kosova 1 - SuperSport Kosova 2 - SuperSport Kosova 3 - T7 - TV 21 Macedonia - TV Klan - TV Koha - TV Shenja - TV Tetova - TVM2 - Telesport - Tip TV - Top Channel - Top News - Tribuna Channel - Tring Action - Tring Comedy - Tring Family - Tring Fantasy - Tring History - Tring International - Tring Jolly - Tring Kids - Tring Life - Tring Planet - Tring Shqip - Tring Smile - Tring Sport 1 - Tring Sport 2 - Tring Sport 3 - Tring Sport 4 - Tring Sport News - Tring Super - Tring Tring - Tring World - Vizion Plus - Çufo - - \ No newline at end of file diff --git a/sites/albepg.com.config.js b/sites/albepg.com.config.js deleted file mode 100644 index dcfe09fb..00000000 --- a/sites/albepg.com.config.js +++ /dev/null @@ -1,51 +0,0 @@ -const epgParser = require('epg-parser') -const dayjs = require('dayjs') -const utc = require('dayjs/plugin/utc') -const customParseFormat = require('dayjs/plugin/customParseFormat') - -dayjs.extend(utc) -dayjs.extend(customParseFormat) - -module.exports = { - lang: 'sq', - site: 'albepg.com', - channels: 'albepg.com.channels.xml', - output: '.gh-pages/guides/albepg.com.guide.xml', - request: { - timeout: 15000, - headers: { - Referer: 'http://albepg.com/epg.html' - } - }, - url: function () { - return `http://albepg.com/epg/guide.xml` - }, - logo: function ({ channel }) { - return `http://albepg.com/tvlogi/${channel.site_id}.png` - }, - parser: function ({ content, channel, date }) { - const results = epgParser.parse(content) - let programs = [] - results.programs - .filter(item => item.channel === channel.site_id) - .forEach(item => { - if (item.title.length && item.start && item.stop) { - const description = item.desc.length ? item.desc[0].value : null - const category = item.category.length ? item.category[0].value : null - const start = dayjs.utc(item.start, 'YYYYMMDDHHmmss Z') - const stop = dayjs.utc(item.stop, 'YYYYMMDDHHmmss Z') - if (start.diff(date.format('YYYY-MM-DD'), 'd') === 0) { - programs.push({ - title: item.title[0].value, - description, - category, - start: start.toString(), - stop: stop.toString() - }) - } - } - }) - - return programs - } -} diff --git a/sites/andorradifusio.ad.config.js b/sites/andorradifusio.ad.config.js index 476da9f6..175f4324 100644 --- a/sites/andorradifusio.ad.config.js +++ b/sites/andorradifusio.ad.config.js @@ -2,11 +2,14 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom 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) +let PM = false module.exports = { lang: 'ca', site: 'andorradifusio.ad', @@ -16,36 +19,59 @@ module.exports = { return `https://www.andorradifusio.ad/programacio/${channel.site_id}` }, parser({ content, date }) { - const day = date.day() - 1 const programs = [] - const dom = new JSDOM(content) - const cols = dom.window.document.querySelectorAll('.programacio-dia') - const colNum = day < 0 ? 6 : day - const times = cols[colNum].querySelectorAll(`h4`) - const titles = cols[colNum].querySelectorAll(`p`) - - times.forEach((time, i) => { - const title = titles[i] ? titles[i].textContent : null - if (!time || !title) return false - - const start = dayjs - .utc(time.textContent, 'HH:mm') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (!start.isValid()) return false - - if (programs.length && !programs[programs.length - 1].stop) { + const items = parseItems(content, date) + items.forEach(item => { + const title = parseTitle(item) + let start = parseStart(item, date) + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + const stop = parseStop(item, date) + if (programs.length) { programs[programs.length - 1].stop = start } programs.push({ title, - start + start, + stop }) }) return programs } } + +function parseStop(item, date) { + return date.tz('Europe/Madrid').endOf('d').add(6, 'h') +} + +function parseStart(item, date) { + let time = (item.time || { textContent: '' }).textContent + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Madrid') +} + +function parseTitle(item) { + return (item.title || { textContent: '' }).textContent +} + +function parseItems(content, date) { + const items = [] + const dom = new JSDOM(content) + const day = date.day() - 1 + const colNum = day < 0 ? 6 : day + const cols = dom.window.document.querySelectorAll('.programacio-dia') + const col = cols[colNum] + const timeRows = col.querySelectorAll(`h4`) + const titleRows = col.querySelectorAll(`p`) + timeRows.forEach((time, i) => { + items.push({ + time, + title: titleRows[i] + }) + }) + + return items +} diff --git a/sites/comteco.com.bo.config.js b/sites/comteco.com.bo.config.js index 6def9c7a..021c913e 100644 --- a/sites/comteco.com.bo.config.js +++ b/sites/comteco.com.bo.config.js @@ -2,9 +2,11 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom 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 = { @@ -25,38 +27,43 @@ module.exports = { }, parser: function ({ content, date }) { const programs = [] - const dom = new JSDOM(content) - const items = dom.window.document.querySelectorAll('#datosasociados > div > .list-group-item') + const items = parseItems(content) items.forEach(item => { - const time = ( - item.querySelector('div > div.col-xs-11 > p > span') || { textContent: '' } - ).textContent - .toString() - .trim() - const title = ( - item.querySelector('div > div.col-xs-11 > p > strong') || { textContent: '' } - ).textContent - .toString() - .trim() - - if (time && title) { - const start = dayjs - .utc(time, 'HH:mm:ss') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (programs.length && !programs[programs.length - 1].stop) { - programs[programs.length - 1].stop = start - } - - programs.push({ - title, - start: start.toString() - }) + const title = parseTitle(item) + let start = parseStart(item, date) + const stop = parseStop(item, date) + if (programs.length) { + programs[programs.length - 1].stop = start } + + programs.push({ title, start, stop }) }) return programs } } + +function parseStop(item, date) { + return date.tz('America/La_Paz').endOf('d') +} + +function parseStart(item, date) { + let time = ( + item.querySelector('div > div.col-xs-11 > p > span') || { textContent: '' } + ).textContent.trim() + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm:ss', 'America/La_Paz') +} + +function parseTitle(item) { + return ( + item.querySelector('div > div.col-xs-11 > p > strong') || { textContent: '' } + ).textContent.trim() +} + +function parseItems(content) { + const dom = new JSDOM(content) + + return dom.window.document.querySelectorAll('#datosasociados > div > .list-group-item') +} diff --git a/sites/hd-plus.de.config.js b/sites/hd-plus.de.config.js index 2ad6cc01..e69ec966 100644 --- a/sites/hd-plus.de.config.js +++ b/sites/hd-plus.de.config.js @@ -2,12 +2,12 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') -const customParseFormat = require('dayjs/plugin/customParseFormat') const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(utc) -dayjs.extend(customParseFormat) dayjs.extend(timezone) +dayjs.extend(customParseFormat) module.exports = { lang: 'de', @@ -26,29 +26,42 @@ module.exports = { return img ? img.src : null }, - parser({ content }) { - const dom = new JSDOM(content) - const items = dom.window.document.querySelectorAll('table > tbody > tr') - let programs = [] + parser({ content, date }) { + const programs = [] + const items = parseItems(content) items.forEach(item => { - const title = (item.querySelector('td:nth-child(1) > a') || { textContent: '' }).textContent - const fullDate = (item.querySelector('td:nth-child(2)') || { textContent: '' }).textContent - if (title && fullDate) { - const time = fullDate.split(' ').pop() - const local = dayjs.utc(time, 'HH:mm').toString() - const start = dayjs.tz(local.toString(), 'Europe/Berlin').toString() - - if (programs.length && !programs[programs.length - 1].stop) { - programs[programs.length - 1].stop = start - } - - programs.push({ - title, - start - }) + const title = parseTitle(item) + let start = parseStart(item, date) + const stop = parseStop(item, date) + if (programs.length) { + programs[programs.length - 1].stop = start } + + programs.push({ title, start, stop }) }) return programs } } + +function parseStop(item, date) { + return date.endOf('d') +} + +function parseStart(item, date) { + let time = (item.querySelector('td:nth-child(2)') || { textContent: '' }).textContent + time = time.split(' ').pop() + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Berlin') +} + +function parseTitle(item) { + return (item.querySelector('td:nth-child(1) > a') || { textContent: '' }).textContent +} + +function parseItems(content) { + const dom = new JSDOM(content) + + return dom.window.document.querySelectorAll('table > tbody > tr') +} diff --git a/sites/m.tv.sms.cz.config.js b/sites/m.tv.sms.cz.config.js index cef55833..e820ef0d 100644 --- a/sites/m.tv.sms.cz.config.js +++ b/sites/m.tv.sms.cz.config.js @@ -3,13 +3,14 @@ const iconv = require('iconv-lite') const { JSDOM } = jsdom const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') -var customParseFormat = require('dayjs/plugin/customParseFormat') -var timezone = require('dayjs/plugin/timezone') +const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(utc) -dayjs.extend(customParseFormat) dayjs.extend(timezone) +dayjs.extend(customParseFormat) +let PM = false module.exports = { lang: 'cs', site: 'm.tv.sms.cz', @@ -28,40 +29,53 @@ module.exports = { }, parser: function ({ buffer, date }) { const programs = [] - const string = iconv.decode(buffer, 'win1250') - const dom = new JSDOM(string) - const items = dom.window.document.querySelectorAll('#obsah > div > div.porady > div.porad') + const items = parseItems(buffer) items.forEach((item, i) => { - const time = (item.querySelector('div > span') || { textContent: '' }).textContent - .toString() - .trim() - const title = (item.querySelector('a > div') || { textContent: '' }).textContent - .toString() - .trim() - const description = (item.querySelector('a > div.detail') || { textContent: '' }).textContent - .toString() - .trim() - - if (time && title) { - let local = dayjs.utc(time, 'HH.mm').date(date.date()).month(date.month()).year(date.year()) - - if (local.hour() <= 6 && i > items.length / 2) { - local = local.date(local.date() + 1) - } - const start = dayjs.tz(local.toString(), 'Europe/Prague').toString() - - if (programs.length && !programs[programs.length - 1].stop) { - programs[programs.length - 1].stop = start - } - - programs.push({ - title, - description, - start - }) + const title = parseTitle(item) + const description = parseDescription(item) + let start = parseStart(item, date) + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + const stop = parseStop(item, date) + if (programs.length) { + programs[programs.length - 1].stop = start } + + programs.push({ + title, + description, + start, + stop + }) }) return programs } } + +function parseStop(item, date) { + return date.tz('Europe/Prague').endOf('d').add(6, 'h') +} + +function parseStart(item, date) { + let time = (item.querySelector('div > span') || { textContent: '' }).textContent.trim() + + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH.mm', 'Europe/Prague') +} + +function parseDescription(item) { + return (item.querySelector('a > div.detail') || { textContent: '' }).textContent.trim() +} + +function parseTitle(item) { + return (item.querySelector('a > div') || { textContent: '' }).textContent.trim() +} + +function parseItems(buffer) { + const string = iconv.decode(buffer, 'win1250') + const dom = new JSDOM(string) + + return dom.window.document.querySelectorAll('#obsah > div > div.porady > div.porad') +} diff --git a/sites/meo.pt.channels.xml b/sites/meo.pt.channels.xml index 8b41aff9..9a55f5d8 100755 --- a/sites/meo.pt.channels.xml +++ b/sites/meo.pt.channels.xml @@ -114,5 +114,9 @@ i24 News English i24 News Français Первый канал + TVCine Top + TVCine Edition + TVCine Emotion + TVCine Action \ No newline at end of file diff --git a/sites/mi.tv.config.js b/sites/mi.tv.config.js index 94cdfbe7..27820789 100644 --- a/sites/mi.tv.config.js +++ b/sites/mi.tv.config.js @@ -2,11 +2,14 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom 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) +let PM = false module.exports = { lang: 'pt', site: 'mi.tv', @@ -23,32 +26,48 @@ module.exports = { }, parser({ content, date }) { const programs = [] - const dom = new JSDOM(content) - const items = dom.window.document.querySelectorAll('#listings > ul > li') + const items = parseItems(content) items.forEach(item => { - const title = (item.querySelector('a > div.content > h2') || { textContent: '' }).textContent - const time = (item.querySelector('a > div.content > span.time') || { textContent: '' }) - .textContent - - if (title && time) { - const start = dayjs - .utc(time, 'HH:mm') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (programs.length && !programs[programs.length - 1].stop) { - programs[programs.length - 1].stop = start - } - - programs.push({ - title, - start - }) + const title = parseTitle(item) + let start = parseStart(item, date) + if (!start) return + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + const stop = parseStop(item, start) + if (programs.length) { + programs[programs.length - 1].stop = start } + + programs.push({ + title, + start, + stop + }) }) return programs } } + +function parseStop(item, date) { + return date.endOf('d').add(6, 'h') +} + +function parseStart(item, date) { + let time = (item.querySelector('a > div.content > span.time') || { textContent: '' }).textContent + if (!time) return null + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'America/Sao_Paulo') +} + +function parseTitle(item) { + return (item.querySelector('a > div.content > h2') || { textContent: '' }).textContent +} + +function parseItems(content) { + const dom = new JSDOM(content) + + return dom.window.document.querySelectorAll('#listings > ul > li') +} diff --git a/sites/programtv.onet.pl.config.js b/sites/programtv.onet.pl.config.js index 9c4baf6c..19e61d8a 100644 --- a/sites/programtv.onet.pl.config.js +++ b/sites/programtv.onet.pl.config.js @@ -2,11 +2,14 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom 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) +let PM = false module.exports = { lang: 'pl', site: 'programtv.onet.pl', @@ -24,24 +27,16 @@ module.exports = { }, parser: function ({ content, date }) { const programs = [] - const dom = new JSDOM(content) - const items = dom.window.document.querySelectorAll( - '#channelTV > section > div.emissions > ul > li' - ) - + const items = parseItems(content) items.forEach(item => { - const title = (item.querySelector('.titles > a') || { textContent: '' }).textContent - const description = (item.querySelector('.titles > p') || { textContent: '' }).textContent - const category = (item.querySelector('.titles > .type') || { textContent: '' }).textContent - const hour = (item.querySelector('.hours > .hour') || { textContent: '' }).textContent - - const start = dayjs - .utc(hour, 'H:mm') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (programs.length && !programs[programs.length - 1].stop) { + const title = parseTitle(item) + const description = parseDescription(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 = parseStop(item, date) + if (programs.length) { programs[programs.length - 1].stop = start } @@ -49,10 +44,40 @@ module.exports = { title, description, category, - start + start, + stop }) }) return programs } } + +function parseStop(item, date) { + return date.add(1, 'd').hour(3).startOf('h') +} + +function parseStart(item, date) { + let time = (item.querySelector('.hours > .hour') || { textContent: '' }).textContent + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Warsaw') +} + +function parseCategory(item) { + return (item.querySelector('.titles > .type') || { textContent: '' }).textContent +} + +function parseDescription(item) { + return (item.querySelector('.titles > p') || { textContent: '' }).textContent +} + +function parseTitle(item) { + return (item.querySelector('.titles > a') || { textContent: '' }).textContent +} + +function parseItems(content) { + const dom = new JSDOM(content) + + return dom.window.document.querySelectorAll('#channelTV > section > div.emissions > ul > li') +} diff --git a/sites/tvgid.ua.config.js b/sites/tvgid.ua.config.js index 511dbb6b..b54fca8a 100644 --- a/sites/tvgid.ua.config.js +++ b/sites/tvgid.ua.config.js @@ -3,11 +3,14 @@ const iconv = require('iconv-lite') const { JSDOM } = jsdom 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) +let PM = false module.exports = { lang: 'uk', site: 'tvgid.ua', @@ -18,36 +21,50 @@ module.exports = { }, parser: function ({ buffer, date }) { const programs = [] - const string = iconv.decode(buffer, 'win1251') - const dom = new JSDOM(string) - const items = dom.window.document.querySelectorAll( - '#container > tbody > tr:nth-child(2) > td > table > tbody > tr > td > table:nth-child(2) > tbody > tr' - ) - + const items = parseItems(buffer) items.forEach(item => { - const time = (item.querySelector('td > table > tbody > tr > td.time') || { textContent: '' }) - .textContent - const title = ( - item.querySelector('td > table > tbody > tr > td.item > a') || - item.querySelector('td > table > tbody > tr > td.item') || { textContent: '' } - ).textContent - - const start = dayjs - .utc(time, 'HH:mm') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (programs.length && !programs[programs.length - 1].stop) { + const title = parseTitle(item) + let start = parseStart(item, date) + if (!start) return + if (start.hour() > 11) PM = true + if (start.hour() < 12 && PM) start = start.add(1, 'd') + const stop = parseStop(item, start) + if (programs.length) { programs[programs.length - 1].stop = start } - programs.push({ - title, - start - }) + programs.push({ title, start, stop }) }) return programs } } + +function parseStop(item, date) { + return date.hour(7) +} + +function parseStart(item, date) { + let time = (item.querySelector('td > table > tbody > tr > td.time') || { textContent: '' }) + .textContent + if (!time) return null + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Europe/Kiev') +} + +function parseTitle(item) { + return ( + item.querySelector('td > table > tbody > tr > td.item > a') || + item.querySelector('td > table > tbody > tr > td.item') || { textContent: '' } + ).textContent +} + +function parseItems(buffer) { + const string = iconv.decode(buffer, 'win1251') + const dom = new JSDOM(string) + + return dom.window.document.querySelectorAll( + '#container > tbody > tr:nth-child(2) > td > table > tbody > tr > td > table:nth-child(2) > tbody > tr:not(:first-child)' + ) +} diff --git a/sites/tvguide.com.channels.xml b/sites/tvguide.com.channels.xml new file mode 100755 index 00000000..5ad87d8e --- /dev/null +++ b/sites/tvguide.com.channels.xml @@ -0,0 +1,93 @@ + + + + A&E East + ABC East + AMC East + Animal Planet East + BBC America East + BET East + Bravo East + Cartoon Network East + CBS East + Cinemax East + CMT East + CNBC US + CNN USA + Comedy Central East + Discovery Channel East + Discovery Life Channel + Disney Channel East + Disney XD East + DIY Network USA + E! East + ESPN + ESPN 2 US + ESPN Classic USA + ESPNU + Flix East + Food Network East + Fox East + Fox News Channel + Fox Sports 1 + Freeform East + Fuse East + FX East + FX Movie Channel + FXX East + FYI East + Game Show Network East + Golf Channel US + Hallmark Channel East + HBO 2 East + HBO East + HBO Signature East + HGTV East + History East + IFC East + Investigation Discovery East + ION TV East + Lifetime East + Lifetime Movies East + Lifetime Real Women + MoreMax East + MSNBC + MTV East + MyNetworkTV + National Geographic East + NBC East + NBCSN + NewsNation East + Nickelodeon East + Oprah Winfrey Network East + Oxygen East + Paramount Network East + PBS East + Pop East + QVC US + Reelz + Science + Showtime 2 East + Showtime East + Smithsonian Channel East + Starz East + Starz Encore East + Sundance TV East + Syfy East + TBS East + TCM US + Telemundo Este + The CW East + The Movie Channel East + TLC East + TNT East + Travel Channel East + truTV East + TV Land East + TVG + Univisión East + USA Network East + VH1 East + We TV East + + \ No newline at end of file diff --git a/sites/tvguide.com.config.js b/sites/tvguide.com.config.js new file mode 100644 index 00000000..f6c13ac1 --- /dev/null +++ b/sites/tvguide.com.config.js @@ -0,0 +1,47 @@ +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') + +dayjs.extend(utc) +dayjs.extend(timezone) + +module.exports = { + lang: 'en', + site: 'tvguide.com', + channels: 'tvguide.com.channels.xml', + output: '.gh-pages/guides/tvguide.com.guide.xml', + url: function ({ date, channel }) { + const localTime = date.tz('America/New_York') + const parts = channel.site_id.split('#') + const start = localTime.startOf('d') + const duration = localTime.endOf('d').diff(start, 'm') + const url = `https://cmg-prod.apigee.net/v1/xapi/tvschedules/tvguide/${ + parts[0] + }/web?start=${start.unix()}&duration=${duration}&channelSourceIds=${parts[1]}` + + return url + }, + parser: function ({ content }) { + const programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.title, + start: parseTime(item.startTime), + stop: parseTime(item.endTime) + }) + }) + + return programs + } +} + +function parseTime(timestamp) { + return dayjs.unix(timestamp) +} + +function parseItems(content) { + const json = JSON.parse(content) + + return json.data.items[0].programSchedules +} diff --git a/sites/tvtv.us.channels.xml b/sites/tvtv.us.channels.xml index ffe99308..60675d52 100755 --- a/sites/tvtv.us.channels.xml +++ b/sites/tvtv.us.channels.xml @@ -2437,7 +2437,7 @@ MASN2 MBC America MBC America (WKTB-CD5) - MBC Drama (Korean) + MBC Drama MCAETv MCAETv (K38JP-DT3) MGM HD USA diff --git a/sites/vidio.com.channels.xml b/sites/vidio.com.channels.xml index 527e0676..748cde94 100644 --- a/sites/vidio.com.channels.xml +++ b/sites/vidio.com.channels.xml @@ -27,6 +27,7 @@ Champions TV 2 Fox Sports Asia beIN Sports 1 Asia + beIN Sports 2 Asia Fox Sports 2 Asia Fox Sports 3 Asia Arirang TV diff --git a/sites/znbc.co.zm.config.js b/sites/znbc.co.zm.config.js index f36d259a..7f078b55 100644 --- a/sites/znbc.co.zm.config.js +++ b/sites/znbc.co.zm.config.js @@ -2,9 +2,11 @@ const jsdom = require('jsdom') const { JSDOM } = jsdom 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 = { @@ -24,43 +26,52 @@ module.exports = { return img ? img.dataset.src : null }, parser({ content, date }) { - const day = date.day() // 0 => Sunday const programs = [] - const dom = new JSDOM(content) - const tabs = dom.window.document.querySelectorAll( - `.elementor-tabs-content-wrapper > div[id*='elementor-tab-content']` - ) - const items = tabs[day].querySelectorAll(`table > tbody > tr`) - + const items = parseItems(content, date) items.forEach(item => { - const row = (item.querySelector('td > p') || { textContent: '' }).textContent - const parts = row.split(' ') - const time = parts.shift() - const title = parts - .filter(str => str && /\S/g.test(str)) - .map(i => i.trim()) - .join(' ') - - if (!time || !title) return false - - const start = dayjs - .utc(time, 'HH:mm') - .set('D', date.get('D')) - .set('M', date.get('M')) - .set('y', date.get('y')) - - if (!start.isValid()) return false - - if (programs.length && !programs[programs.length - 1].stop) { + const title = parseTitle(item) + const start = parseStart(item, date) + const stop = parseStop(item, date) + if (programs.length) { programs[programs.length - 1].stop = start } - programs.push({ - title, - start - }) + programs.push({ title, start, stop }) }) return programs } } + +function parseStop(item, date) { + return date.endOf('d') +} + +function parseStart(item, date) { + const row = (item.querySelector('td > p') || { textContent: '' }).textContent + let time = row.split(' ').shift() + time = `${date.format('MM/DD/YYYY')} ${time}` + + return dayjs.tz(time, 'MM/DD/YYYY HH:mm', 'Africa/Lusaka') +} + +function parseTitle(item) { + const row = (item.querySelector('td > p') || { textContent: '' }).textContent + const title = row.split(' ') + title.shift() + + return title + .map(i => i.trim()) + .filter(s => s) + .join(' ') +} + +function parseItems(content, date) { + const day = date.day() // 0 => Sunday + const dom = new JSDOM(content) + const tabs = dom.window.document.querySelectorAll( + `.elementor-tabs-content-wrapper > div[id*='elementor-tab-content']` + ) + + return tabs[day].querySelectorAll(`table > tbody > tr:not(:first-child)`) +}