diff --git a/sites/mytelly.co.uk/__data__/content.html b/sites/mytelly.co.uk/__data__/content.html new file mode 100644 index 00000000..1732193d --- /dev/null +++ b/sites/mytelly.co.uk/__data__/content.html @@ -0,0 +1,1076 @@ + + + BBC One London - TV Listings Guide + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+
+ +
+
+ BBC One London +
+

BBC One London

+
+ Live +
+ Find out what's on BBC One London tonight at the + UK TV Listings Guide +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
Time
+
+
TV Show
+
+
12:15 am
+
+
+ + The Rap Game UK +
+
+
01:20 am
+
+
+ + The Graham Norton Show +
+
+
02:13 am
+
+
+ + Weather for the Week Ahead +
+
+
02:15 am
+
+
+ + BBC News +
+
+
06:00 am
+
+
+ + Breakfast +
+
+
07:30 am
+
+
+ + Match of the Day +
+
+
09:00 am
+
+
+ + Sunday with Laura Kuenssberg +
+
+
10:00 am
+
+
+ + Politics London +
+
+
10:30 am
+
+
+ + Animal Park +
+
+
11:00 am
+
+
+ + Amanda & Alan's Italian Job +
+
+
11:30 am
+
+
+ + Amanda & Alan's Italian Job +
+
+
12:00 pm
+
+
+ + Bargain Hunt +
+
+
1:00 pm
+
+
+ + BBC News +
+
+
1:10 pm
+
+
+ + Weather for the Week Ahead +
+
+
1:15 pm
+
+
+ + Songs of Praise +
+
+
2:00 pm
+
+
+ + Planet Earth III +
+
+
3:00 pm
+
+
+ + Live Snooker: UK Championship +
+
+
4:55 pm
+
+
+ + BBC News +
+
+
5:10 pm
+
+
+ + BBC London News; Weather +
+
+
5:15 pm
+
+
+ + Weather +
+
+
5:20 pm
+
+
+ + Countryfile +
+
+
6:20 pm
+
+
+ + Planet Earth III +
+
+
7:20 pm
+
+
+ + Strictly Come Dancing +
+
+
8:00 pm
+
+
+ + Survivor +
+
+
9:00 pm
+
+
+ + Boat Story +
+
+
10:00 pm
+
+
+ + BBC News; Weather +
+
+
10:25 pm
+
+
+ + BBC London News; Weather +
+
+
10:30 pm
+
+
+ + Match of the Day 2 +
+
+
11:30 pm
+
+
+ + The Women's Football Show +
+
+ + | + More channels at My Telly..
+

+
+
+
+ +
+ +
+ +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sites/mytelly.co.uk/mytelly.co.uk.channels.xml b/sites/mytelly.co.uk/mytelly.co.uk.channels.xml new file mode 100644 index 00000000..db9e4130 --- /dev/null +++ b/sites/mytelly.co.uk/mytelly.co.uk.channels.xml @@ -0,0 +1,489 @@ + + + 4Music + 4seven + 4seven HD + 5Action + 5Action HD + 5SELECT + 5STAR + 5STAR +1 + 5USA + 5USA +1 + Alibi + Alibi HD + Alibi +1 + Al Jazeera English + Al Jazeera English HD + Animal Planet + Animal Planet HD + Animal Planet +1 + Arirang HD + Ayozat TV + B4U Movies + B4U Music + Baby TV + BBC Alba + BBC Alba HD + BBC Four + BBC Four HD + BBC News + BBC News HD + BBC One + BBC One Cambridgeshire + BBC One Cambridgeshire HD + BBC One Channel Islands + BBC One Channel Islands HD + BBC One East + BBC One East HD + BBC One East Midlands + BBC One East Midlands HD + BBC One HD + BBC One London + BBC One London HD + BBC One North East & Cumbria + BBC One North East & Cumbria HD + BBC One Northern Ireland + BBC One Northern Ireland HD + BBC One North West + BBC One North West HD + BBC One Oxfordshire + BBC One Oxfordshire HD + BBC One Scotland + BBC One Scotland HD + BBC One South + BBC One South East + BBC One South East HD + BBC One South HD + BBC One South West + BBC One South West HD + BBC One Wales + BBC One Wales HD + BBC One West + BBC One West HD + BBC One West Midlands + BBC One West Midlands HD + BBC One Yorkshire + BBC One Yorkshire HD + BBC One Yorkshire & Lincolnshire HD + BBC Parliament + BBC Parliament HD + BBC Red Button 1 + BBC Red Button 1 HD + BBC Red Button HD + BBC Scotland + BBC Scotland HD + BBC Scotland HD (Freeview) + BBC Three + BBC Three HD + BBC Two England + BBC Two HD + BBC Two Northern Ireland + BBC Two Northern Ireland HD + BBC Two Wales + BBC Two Wales HD + Blaze + Blaze (Freeview) + Bloomberg HD + Boomerang + Boomerang HD + Boomerang +1 + Cartoonito + Cartoon Network + Cartoon Network HD + Cartoon Network +1 + CBBC + CBBC HD + CBeebies + CBeebies HD + CBS Reality + CBS Reality +1 + Challenge + Channel 4 + Channel 4 HD + Channel 4 +1 + Channel 5 + Channel 5 HD + Channel 5 +1 + Channels 24 + Clubland TV + CNBC UK + CNBC UK HD + CNN + CNN HD + Colors Cineplex + Colors Gujrati + Colors + Colors HD + Colors Rishtey + Comedy Central + Comedy Central Extra + Comedy Central HD + Comedy Central +1 + Create & Craft + Create & Craft HD + Crime + Investigation + Crime + Investigation HD + Crime + Investigation +1 + Cula4 HD + Dave + Dave HD + Dave ja vu + Discovery Channel + Discovery Channel HD + Discovery Channel +1 + Discovery History + Discovery History +1 + Discovery Science + Discovery Science +1 + Discovery Turbo + Discovery Turbo +1 + DMAX + DMAX +1 + Drama + Drama HD + Drama +1 + E! Entertainment + E4 + E4 Extra + E4 HD + E4 +1 + Earthx TV + Eden + Eden HD + Eden +1 + E! Entertainment HD + Euronews + Eurosport 1 + Eurosport 1 HD + Eurosport 2 + Eurosport 2 HD + Film4 + Film4 HD + Film4 +1 + Food Network + Food Network +1 + Foodxp + France 24 English + France 24 English HD + GB News + GB News HD + GEO News + GEO TV + GOLD + GOLD HD + GOLD +1 + GREAT! action + GREAT! action +1 + GREAT! movies + GREAT! movies +1 + GREAT! movies christmas + GREAT! movies christmas +1 + GREAT! tv + GREAT! tv +1 + HGTV + HGTV +1 + HorrorXtra + HorrorXtra +1 + Ideal World + Investigation Discovery + Investigation Discovery +1 + ITV1 Anglia + ITV1 Anglia HD + ITV1 Anglia +1 + ITV1 Border England + ITV1 Border HD + ITV1 Border Scotland + ITV1 Central + ITV1 Central HD + ITV1 Central +1 + ITV1 Channel Television + ITV1 Granada + ITV1 Granada HD + ITV1 Granada +1 + ITV1 London + ITV1 London HD + ITV1 London +1 + ITV1 Meridian + ITV1 Meridian HD + ITV1 Meridian +1 + ITV1 Tyne Tees + ITV1 Tyne Tees HD + ITV1 Tyne Tees +1 + ITV1 Wales + ITV1 Wales HD + ITV1 Wales +1 + ITV1 West + ITV1 West Country + ITV1 West Country HD + ITV1 West Country +1 + ITV1 West HD + ITV1 West +1 + ITV1 Yorkshire + ITV1 Yorkshire HD + ITV1 Yorkshire +1 + ITV2 + ITV2 HD + ITV2 +1 + ITV3 + ITV3 HD + ITV3 +1 + ITV3 +1 (Freeview) + ITV4 + ITV4 HD + ITV4 +1 + ITVBe + ITVBe HD + ITVBe +1 + Kerrang! TV + Kiss TV + Legend + LFC TV HD + London Live + Magic + More4 + More4 HD + More4 +1 + Christmas 24 + Christmas 24+ + MTV + MTV 80s + MTV 90s + MTV HD + MTV Hits + MTV Live HD + MTV Music + MUTV + MUTV HD + National Geographic Channel + National Geographic Channel HD + National Geographic Channel +1 + National Geographic WILD + National Geographic WILD HD + NDTV 24x7 + New Vision + NHK World + NHK World HD + Nickelodeon + Nickelodeon HD + Nickelodeon +1 + Nick Jr. + Nick Jr. HD + Nick Jr. +1 + Nick Jr. Peppa + NickLoudHouse + Notts TV + NOW 70s + NOW 80s + NOW Rock + PBS America + PBS America (Freeview) + Phoenix CNE Channel HD + Pop + Pop Max + Pop Max +1 + Pop +1 + Quest + Quest HD + Quest +1 + Quest Red + Quest Red +1 + QVC + QVC2 + QVC Beauty + QVC Extra + QVC HD + QVC Style + QVC Style HD + Racing TV + Racing TV HD + RealityXtra + Really + RTE2 + RTE2 HD + RTE Jr + RTE News + RTE One + S4C + S4C HD + Sanskar + Sky Arts + Sky Arts HD + Sky Atlantic + Sky Atlantic HD + Sky Atlantic +1 + Sky Cinema Action + Sky Cinema Action HD + Sky Cinema Animation + Sky Cinema Animation HD + Sky Cinema Comedy + Sky Cinema Comedy HD + Sky Cinema Christmas + Sky Cinema Christmas HD + Sky Cinema Family + Sky Cinema Family HD + Sky Cinema Greats + Sky Cinema Greats HD + Sky Cinema Bourne + Sky Cinema Hits HD + Sky Cinema Premiere + Sky Cinema Premiere HD + Sky Cinema Premiere +1 + Sky Cinema Sci-fi/Horror + Sky Cinema Sci-fi/Horror HD + Sky Cinema Heroines + Sky Cinema Heroines HD + Sky Cinema Thriller + Sky Cinema Thriller HD + Sky Comedy + Sky Comedy HD + Sky Crime + Sky Crime HD + Sky Crime +1 + Sky Documentaries + Sky Documentaries HD + Sky History + Sky History 2 + Sky History 2 HD + Sky History HD + Sky History +1 + Sky Kids + Sky Kids HD + Sky Max + Sky Max HD + Sky Mix + Sky Mix HD + Sky Nature + Sky Nature HD + Sky News + Sky News HD + Sky Replay + Sky Sci-Fi + Sky Sci-Fi HD + Sky Showcase + Sky Showcase HD + Sky Showcase +1 + Sky Sports Arena + Sky Sports Arena HD + Sky Sports Box Office + Sky Sports Cricket + Sky Sports Cricket HD + Sky Sports F1 + Sky Sports F1 HD + Sky Sports Football + Sky Sports Football HD + Sky Sports Golf + Sky Sports Golf HD + Sky Sports Main Event + Sky Sports Main Event HD + Sky Sports Main Event Ultra HDR + Sky Sports Mix + Sky Sports Mix HD + Sky Sports News + Sky Sports News HD + Sky Sports NFL + Sky Sports NFL HD + Sky Sports Premier League + Sky Sports Premier League HD + Sky Sports Racing + Sky Sports Racing HD + Sky Witness + Sky Witness HD + Sky Witness +1 + Sony Entertainment TV Asia + Sony Entertainment TV Asia HD + Sony MAX 2 + Sony MAX + Sony MAX HD + Sony SAB + Sportystuff TV HD + STV Central + STV Central +1 + STV HD + STV North + STV North +1 + TalkBirmingham + TalkBristol + TalkCardiff + Talking Pictures TV + TalkLeeds + TalkLiverpool + TalkNorthWales + TalkTeesside + Talk TV + Talk TV HD + TalkTyne&Wear + TG4 + TG4 HD + That's 60s + That's 60s (MCR Freeview) + That's Christmas + That's 70s (MCR Freeview) + That's 80s + That's 80s (Freeview) + That's 90s + That's 90s (MCR Freeview) + That's TV + That's TV (Freeview) + The Box + Tiny Pop + Tiny Pop (Freeview) + Tiny Pop +1 + TLC + TLC HD + TLC +1 + TNT Sports 1 + TNT Sports 10 + TNT Sports 10 HD + TNT Sports 1 HD + TNT Sports 2 + TNT Sports 2 HD + TNT Sports 3 + TNT Sports 3 HD + TNT Sports 4 + TNT Sports 4 HD + TNT Sports 5 + TNT Sports 5 HD + TNT Sports 6 + TNT Sports 6 HD + TNT Sports 7 + TNT Sports 7 HD + TNT Sports 8 + TNT Sports 8 HD + TNT Sports 9 + TNT Sports 9 HD + TNT Sports Box Office HD 2 + Sky Sports Box Office HD + TNT Sports Box Office HD + TNT Sports Ultimate + TNT Sports Ultimate + Together TV + Together TV +1 + Trace Vault + Travelxp + TRT World + TRT World HD + TVC News + Utsav Bharat + Utsav Gold + Utsav Gold HD + Utsav Plus + Utsav Plus HD + UTV + UTV HD + UTV +1 + Viaplay Sports 1 HD + Viaplay Sports 2 HD + Viaplay Xtra HD + W + W HD + WildEarth + W +1 + Yesterday + Yesterday HD + Yesterday +1 + Zee Cinema HD + Zee Cinema + Zee TV HD + Zee TV + diff --git a/sites/mytelly.co.uk/mytelly.co.uk.config.js b/sites/mytelly.co.uk/mytelly.co.uk.config.js new file mode 100644 index 00000000..7272a0a6 --- /dev/null +++ b/sites/mytelly.co.uk/mytelly.co.uk.config.js @@ -0,0 +1,133 @@ +const cheerio = require('cheerio') +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: 'mytelly.co.uk', + days: 2, + url: function ({ date, channel }) { + return `https://www.mytelly.co.uk/tv-guide/listings/channel/${ + channel.site_id + }.html?dt=${date.format('YYYY-MM-DD')}` + }, + parser: function ({ content, date, channel }) { + const programs = [] + const items = parseItems(content) + items.forEach(item => { + const prev = programs[programs.length - 1] + const $item = cheerio.load(item) + let start = parseStart($item, date, channel) + if (prev) { + if (start.isBefore(prev.start)) { + start = start.add(1, 'd') + date = date.add(1, 'd') + } + prev.stop = start + } + const stop = start.add(30, 'm') + programs.push({ + title: parseTitle($item), + start, + stop + }) + }) + + return programs + }, + async channels() { + const axios = require('axios') + const _ = require('lodash') + + const providers = [ + '-3000053', + '-4000118', + '-11000199', + '-1000007', + '-2000007', + '-12000220', + '-5000136', + '-10000178' + ] + const regions = [ + 'Cambridgeshire', + 'Channel Islands', + 'Cumbria', + 'East', + 'East Midlands', + 'Yorkshire & Lincolnshire', + 'London', + 'North East', + 'North West', + 'Northern Ireland', + 'Oxfordshire', + 'Scotland (Borders)', + 'Scotland (Central)', + 'Scotland (North)', + 'South', + 'South East', + 'South West', + 'Wales', + 'West', + 'West Midlands', + 'Yorkshire' + ] + + const channels = [] + for (let provider of providers) { + for (let region of regions) { + const data = await axios + .post(`https://www.mytelly.co.uk/tv-guide/schedule`, null, { + params: { + provider, + region, + TVperiod: 'Night', + date: dayjs().format('YYYY-MM-DD'), + st: 0, + u_time: 1955, + is_mobile: 1 + } + }) + .then(r => r.data) + .catch(console.log) + + const $ = cheerio.load(data) + $('.channelname').each((i, el) => { + const name = $(el).find('center > a:eq(1)').text() + const url = $(el).find('center > a:eq(1)').attr('href') + const [, number, slug] = url.match(/\/(\d+)\/(.*)\.html$/) + + channels.push({ + lang: 'en', + name, + site_id: `${number}/${slug}` + }) + }) + } + } + + return _.uniqBy(channels, 'site_id') + } +} + +function parseStart($item, date, channel) { + const timeString = $item('td:eq(0)').text().trim() + const dateString = `${date.format('YYYY-MM-DD')} ${timeString}` + + return dayjs.tz(dateString, 'YYYY-MM-DD H:mm a', 'Europe/London') +} + +function parseTitle($item) { + return $item('td:eq(1)').text().trim() +} + +function parseItems(content) { + const $ = cheerio.load(content) + + return $('table.table > tbody > tr').toArray() +} diff --git a/sites/mytelly.co.uk/mytelly.co.uk.test.js b/sites/mytelly.co.uk/mytelly.co.uk.test.js new file mode 100644 index 00000000..328ec6e5 --- /dev/null +++ b/sites/mytelly.co.uk/mytelly.co.uk.test.js @@ -0,0 +1,53 @@ +// npm run channels:parse -- --config=./sites/mytelly.co.uk/mytelly.co.uk.config.js --output=./sites/mytelly.co.uk/mytelly.co.uk.channels.xml +// npm run grab -- --site=mytelly.co.uk + +const { parser, url } = require('./mytelly.co.uk.config.js') +const fs = require('fs') +const path = require('path') +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('2023-11-26', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '713/bbc-one-london', + xmltv_id: 'BBCOneLondon.uk' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://www.mytelly.co.uk/tv-guide/listings/channel/713/bbc-one-london.html?dt=2023-11-26' + ) +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + const results = parser({ content, channel, date }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results[0]).toMatchObject({ + start: '2023-11-26T00:15:00.000Z', + stop: '2023-11-26T01:20:00.000Z', + title: 'The Rap Game UK' + }) + + expect(results[28]).toMatchObject({ + start: '2023-11-26T23:30:00.000Z', + stop: '2023-11-27T00:00:00.000Z', + title: "The Women's Football Show" + }) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: '' + }) + expect(result).toMatchObject([]) +})