diff --git a/sites/mytelly.co.uk/__data__/content.html b/sites/mytelly.co.uk/__data__/content.html index 1732193d..5dc21205 100644 --- a/sites/mytelly.co.uk/__data__/content.html +++ b/sites/mytelly.co.uk/__data__/content.html @@ -1,1076 +1,838 @@ - - - BBC One London - TV Listings Guide + + +BBC One London - TV Listings Guide - - - - - + + + + + - - - - - - + + + + + + + + - - - - + + + + - + - - - - - + + + + - - + - - - + gtag('config', 'G-5YFXQELX9H'); + + +
- - - - -
- -
-
- -
-
- 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..
-

-
-
-
- -
- -
- -
-
-
-
- -
- + - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sites/mytelly.co.uk/mytelly.co.uk.channels.xml b/sites/mytelly.co.uk/mytelly.co.uk.channels.xml index f3f2440a..f077129c 100644 --- a/sites/mytelly.co.uk/mytelly.co.uk.channels.xml +++ b/sites/mytelly.co.uk/mytelly.co.uk.channels.xml @@ -1,6 +1,89 @@ - 4Music + MTV XMAS + Phoenix CNE Channel + U&Dave + Bloomberg + U&Gold + U&Alibi + Nicktoons + U&Gold +1 + U&Yesterday + U&Eden + U&Eden +1 + Legend Xtra + U&Yesterday +1 + U&Dave ja vu + GREAT! christmas + U&Alibi +1 + Sky Cinema 80s + Sky Cinema Favourites + Sky Cinema Epics + GREAT! christmas +1 + Legend Xtra +1 + U&W + Sky Cinema Favourites HD + U&W +1 + True Crime + Sky Cinema Epics HD + True Crime +1 + True Crime Xtra + Nick Jr. Too + Sky Cinema 80s HD + U&Eden HD + LFC TV + Premier Sports 1 HD + U&W HD + U&Dave HD + BBC One Yorkshire & Lincolnshire + U&Alibi HD + U&Drama + Brit Asia + RTE One HD + Leeds TV + Bristol TV + Tyne & Wear TV + Cardiff TV + NDTV World + Arirang + Birmingham TV + Liverpool TV + Blaze +1 (Freeview) + New Vision TV + Sky Sports + + Sky Sports + HD + U&Gold HD + TNT Sports Box Office + ARY Digital + HUM Europe + Premier Sports 2 HD + U&Drama +1 + TNT Sports Box Office 2 + Talk + U&Yesterday HD + That's Christmas + U&Drama HD + That's Melody MCR + That's Melody + Cula4 + That's TV MCR + That's Fabulous MCR + That's Fabulous + That's TV 2 + North Wales TV + Teesside TV + ITV1 Channel Television HD + ITV1 Border Scotland HD + Sky Sports Tennis + Sky Sports Tennis HD + Rewind TV + Music India + NOW XMAS + That's Christmas + That's TV 2 MCR + That's Dance (Freeview) + That's Dance (MCR and Sky) + Cartoonito HD 4seven 4seven HD 5Action @@ -10,16 +93,11 @@ 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 @@ -38,7 +116,6 @@ 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 @@ -96,8 +173,6 @@ CBBC HD CBeebies CBeebies HD - CBS Reality - CBS Reality +1 Challenge Channel 4 Channel 4 HD @@ -126,9 +201,6 @@ Crime + Investigation HD Crime + Investigation +1 Cula4 HD - Dave - Dave HD - Dave ja vu Discovery Channel Discovery Channel HD Discovery Channel +1 @@ -140,19 +212,10 @@ 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 @@ -163,28 +226,20 @@ 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 @@ -235,20 +290,16 @@ 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 MTV HD MTV Hits MTV Live HD @@ -260,8 +311,6 @@ National Geographic Channel +1 National Geographic WILD National Geographic WILD HD - NDTV 24x7 - New Vision NHK World NHK World HD Nickelodeon @@ -270,8 +319,6 @@ Nick Jr. Nick Jr. HD Nick Jr. +1 - Nick Jr. Peppa - NickLoudHouse Notts TV NOW 70s NOW 80s @@ -288,8 +335,8 @@ Quest +1 Quest Red Quest Red +1 - QVC QVC2 + QVC QVC Beauty QVC Extra QVC HD @@ -297,7 +344,6 @@ QVC Style HD Racing TV Racing TV HD - RealityXtra Really RTE2 RTE2 HD @@ -322,17 +368,10 @@ 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 @@ -342,9 +381,9 @@ Sky Crime +1 Sky Documentaries Sky Documentaries HD - Sky History Sky History 2 Sky History 2 HD + Sky History Sky History HD Sky History +1 Sky Kids @@ -363,9 +402,6 @@ 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 @@ -396,45 +432,21 @@ 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 @@ -452,14 +464,13 @@ TNT Sports 8 HD TNT Sports 9 TNT Sports 9 HD - TNT Sports Box Office HD 2 + TNT Sports 10 + TNT Sports 10 HD 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 @@ -472,16 +483,7 @@ 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 diff --git a/sites/mytelly.co.uk/mytelly.co.uk.config.js b/sites/mytelly.co.uk/mytelly.co.uk.config.js index 7272a0a6..ca76c70b 100644 --- a/sites/mytelly.co.uk/mytelly.co.uk.config.js +++ b/sites/mytelly.co.uk/mytelly.co.uk.config.js @@ -8,126 +8,161 @@ dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(customParseFormat) +const detailedGuide = false +const tz = 'Europe/London' +const nworker = 10 + module.exports = { site: 'mytelly.co.uk', days: 2, - url: function ({ date, channel }) { + url({ 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 }) { + async parser({ 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 - }) - }) + + if (content) { + const queues = [] + const $ = cheerio.load(content) + + $('table.table > tbody > tr').toArray() + .forEach(el => { + const td = $(el).find('td:eq(1)') + const title = td.find('h5 a') + if (detailedGuide) { + queues.push(title.attr('href')) + } else { + const subtitle = td.find('h6') + const time = $(el).find('td:eq(0)') + const dateString = `${date.format('YYYY-MM-DD')} ${time.text().trim()}` + let start = dayjs.tz(dateString, 'YYYY-MM-DD H:mm a', tz) + const prev = programs[programs.length - 1] + 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: parseText(title), + subTitle: parseText(subtitle), + start, + stop + }) + } + }) + } return programs }, async channels() { + const channels = {} const axios = require('axios') - const _ = require('lodash') + const queues = [{ t: 'p', u: 'https://www.mytelly.co.uk/getform' }] - 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 + let n = Math.min(nworker, queues.length) + const workers = [] + const cb = (queue, res) => { + // process form -> provider + if (queue.t === 'p') { + const $ = cheerio.load(res) + $('#guide_provider option').toArray() + .forEach(el => { + const opt = $(el) + const provider = opt.attr('value') + queues.push({ t: 'r', u: 'https://www.mytelly.co.uk/getregions', params: { provider } }) + }) + } + // process provider -> region + if (queue.t === 'r') { + const now = dayjs() + for (const r of Object.values(res)) { + const params = { + provider: queue.params.provider, + region: r.title, + TVperiod: 'Night', + date: now.format('YYYY-MM-DD'), + st: 0, + u_time: now.format('HHmm'), + is_mobile: 1 + } + queues.push({ t: 's', u: 'https://www.mytelly.co.uk/tv-guide/schedule', params }) + } + } + // process schedule -> channels + if (queue.t === 's') { + const $ = cheerio.load(res) + $('.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$/) + const site_id = `${number}/${slug}` + if (channels[site_id] === undefined) { + channels[site_id] = { + lang: 'en', + site_id, + name + } } }) - .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}` - }) - }) + } + // increase worker + if (queues.length > workers.length && workers.length < nworker) { + let nw = Math.min(nworker, queues.length) + if (n < nw) { + n = nw + createWorker() + } } } + const createWorker = () => { + while (workers.length < n) { + startWorker() + } + } + const startWorker = () => { + const worker = () => { + if (queues.length) { + const q = queues.shift() + axios + .post(q.u, q.params || {}) + .then(response => { + if (response.data) { + cb(q, response.data) + } + worker() + }) + .catch(console.error) + } else { + workers.splice(workers.indexOf(worker), 1) + } + } + workers.push(worker) + worker() + } + createWorker() + await new Promise(resolve => { + const interval = setInterval(() => { + if (workers.length === 0) { + clearInterval(interval) + resolve() + } + }, 500) + }) - return _.uniqBy(channels, 'site_id') + return Object.values(channels) } } -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() +function parseText($item) { + return $item.text() + .replace(/\t/g, '') + .replace(/\n/g, ' ') + .replace(/ /g, ' ') + .trim() } diff --git a/sites/mytelly.co.uk/mytelly.co.uk.test.js b/sites/mytelly.co.uk/mytelly.co.uk.test.js index ac368528..e27a0816 100644 --- a/sites/mytelly.co.uk/mytelly.co.uk.test.js +++ b/sites/mytelly.co.uk/mytelly.co.uk.test.js @@ -7,7 +7,7 @@ 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 date = dayjs.utc('2024-12-07', 'YYYY-MM-DD').startOf('d') const channel = { site_id: '713/bbc-one-london', xmltv_id: 'BBCOneLondon.uk' @@ -15,33 +15,34 @@ const channel = { 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' + 'https://www.mytelly.co.uk/tv-guide/listings/channel/713/bbc-one-london.html?dt=2024-12-07' ) }) -it('can parse response', () => { +it('can parse response', async () => { const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) - const results = parser({ content, channel, date }).map(p => { + const results = (await parser({ content, channel, date })).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) + expect(results.length).toBe(25) expect(results[0]).toMatchObject({ - start: '2023-11-26T00:15:00.000Z', - stop: '2023-11-26T01:20:00.000Z', - title: 'The Rap Game UK' + start: '2024-12-07T00:00:00.000Z', + stop: '2024-12-07T02:05:00.000Z', + title: 'Captain Phillips (2013)' }) - - expect(results[28]).toMatchObject({ - start: '2023-11-26T23:30:00.000Z', - stop: '2023-11-27T00:00:00.000Z', - title: "The Women's Football Show" + expect(results[24]).toMatchObject({ + start: '2024-12-07T23:35:00.000Z', + stop: '2024-12-08T00:05:00.000Z', + title: 'The Rap Game UK', + subTitle: 'Past and Pressure - Season 6, Episode 5' }) }) -it('can handle empty guide', () => { - const result = parser({ +it('can handle empty guide', async () => { + const result = await parser({ date, channel, content: ''