From 97d65be0214c4002d26736de0eb0b79ef8db2ee5 Mon Sep 17 00:00:00 2001 From: RevGear <95308545+RevGear@users.noreply.github.com> Date: Sun, 20 Mar 2022 11:48:36 +0000 Subject: [PATCH] Add guide for bt.com --- sites/bt.com/bt.com.config.js | 48 +++++++ sites/bt.com/bt.com.test.js | 51 ++++++++ sites/bt.com/bt.com_uk.channels.xml | 189 ++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 sites/bt.com/bt.com.config.js create mode 100644 sites/bt.com/bt.com.test.js create mode 100644 sites/bt.com/bt.com_uk.channels.xml diff --git a/sites/bt.com/bt.com.config.js b/sites/bt.com/bt.com.config.js new file mode 100644 index 00000000..89a6d61d --- /dev/null +++ b/sites/bt.com/bt.com.config.js @@ -0,0 +1,48 @@ +const dayjs = require('dayjs') + +module.exports = { + site: 'bt.com', + url: function ({ date, channel }) { + return `https://voila.metabroadcast.com/4/schedules/${channel.site_id}.json?key=b4d2edb68da14dfb9e47b5465e99b1b1&from=${date.utc().format()}&to=${date.add(1, 'd').utc().format()}&source=api.youview.tv&annotations=content.description` + }, + parser: function ({ content }) { + const programs = [] + const items = parseItems(content) + items.forEach(item => { + programs.push({ + title: item.item.title, + description: item.item.description, + icon: parseIcon(item), + season: parseSeason(item), + episode: parseEpisode(item), + start: parseStart(item), + stop: parseStop(item) + }) + }) + + return programs + } +} + +function parseItems(content) { + const data = JSON.parse(content) + return data && data.schedule.entries ? data.schedule.entries : [] +} +function parseSeason(item) { + if (item.item.type !== 'episode') return null + return item.item.series_number || null +} +function parseEpisode(item) { + if (item.item.type !== 'episode') return null + return item.item.episode_number || null +} +function parseIcon(item) { + return item.item.image || null +} +function parseStart(item) { + return dayjs(item.broadcast.transmission_time) + } + + function parseStop(item) { + return dayjs(item.broadcast.transmission_end_time) + } \ No newline at end of file diff --git a/sites/bt.com/bt.com.test.js b/sites/bt.com/bt.com.test.js new file mode 100644 index 00000000..12d81cf1 --- /dev/null +++ b/sites/bt.com/bt.com.test.js @@ -0,0 +1,51 @@ +// node ./scripts/commands/parse-channels.js --config=./sites/bt.com/bt.com.config.js --output=./sites/bt.com/bt.com_uk-ny.channels.xml --set=zip:10001 +// npx epg-grabber --config=sites/bt.com/bt.com.config.js --channels=sites/bt.com/bt.com_uk.channels.xml --output=guide.xml --days=2 + +const { parser, url } = require('./bt.com.config.js') +const axios = require('axios') +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('2022-03-20', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'hsxv', + xmltv_id: 'BBCOneHD.uk' +} + +it('can generate valid url', () => { + expect(url({ date, channel })).toBe( + 'https://voila.metabroadcast.com/4/schedules/hsxv.json?key=b4d2edb68da14dfb9e47b5465e99b1b1&from=2022-03-20T00:00:00Z&to=2022-03-21T00:00:00Z&source=api.youview.tv&annotations=content.description' + ) +}) + +it('can parse response', () => { + const content = `{"schedule":{"channel":{"title":"BBC One HD","id":"hsxv","uri":"http://api.youview.tv/channels/dvb://233a..4484","images":[{"uri":"https://images.metabroadcast.com?source=http%3A%2F%2Fimages-live.youview.tv%2Fimages%2Fentity%2F8c4c0357-d7ee-5d8a-8bc4-b177b6875128%2Fident%2F1_1024x532.png%3Fdefaultimg%3D0&ETag=r5vyecG6of%2BhCbHeEClx0Q%3D%3D","mime_type":"image/png","type":null,"color":"monochrome","theme":"light_monochrome","aspect_ratio":null,"availability_start":null,"availability_end":null,"width":1024,"height":532,"hasTitleArt":null,"source":null}],"available_from":[{"key":"api.youview.tv","name":"YouView JSON","country":"GB"}],"source":{"key":"api.youview.tv","name":"YouView JSON","country":"GB"},"same_as":[],"media_type":"video","broadcaster":null,"aliases":[{"namespace":"youview:serviceLocator","value":"dvb://233a..4484"},{"namespace":"youview:channel:id","value":"8c4c0357-d7ee-5d8a-8bc4-b177b6875128"}],"genres":[],"high_definition":true,"timeshifted":null,"regional":null,"related_links":[],"start_date":null,"advertised_from":null,"advertised_to":null,"short_description":null,"medium_description":null,"long_description":null,"region":null,"target_regions":[],"channel_type":"CHANNEL","interactive":false,"transmission_types":["DTT"],"quality":"HD","hdr":false},"source":"api.youview.tv","entries":[{"broadcast":{"aliases":[{"namespace":"api.youview.tv:slot","value":"dvb://233a..4484;76bc"},{"namespace":"dvb:event-locator","value":"dvb://233a..4484;76bc"},{"namespace":"dvb:pcrid","value":"crid://fp.bbc.co.uk/b/3Q30S2"},{"namespace":"youview:schedule_event:id","value":"79d318f3-b41a-582d-b089-7b0172538b42"}],"transmission_time":"2022-03-19T23:30:00.000Z","transmission_end_time":"2022-03-20T01:20:00.000Z","broadcast_duration":6600,"broadcast_on":"hsxv","schedule_date":null,"repeat":null,"subtitled":true,"signed":null,"audio_described":false,"high_definition":null,"widescreen":null,"surround":null,"live":null,"premiere":null,"continuation":null,"new_series":null,"new_episode":null,"new_one_off":null,"revised_repeat":null,"blackout_restriction":{"all":false}},"item":{"id":"n72nsw","type":"item","display_title":{"title":"The Finest Hours (2016)","subtitle":null},"year":null,"media_type":"video","specialization":"tv","source":{"key":"api.youview.tv","name":"YouView JSON","country":"GB"},"title":"The Finest Hours (2016)","description":"Drama based on a true story, recounting one of history's most daring coastguard rescue attempts. Stranded on a sinking oil tanker along with 30 other sailors, engineer Ray Sybert battles to buy his crew more time as Captain Bernie Webber and three of his colleagues tackle gigantic waves and gale-force winds in their astonishing bid to save the seamen.","image":"https://images.metabroadcast.com?source=http%3A%2F%2Fimages-live.youview.tv%2Fimages%2Fentity%2F52172983%2Fprimary%2F1_1024x576.jpg%3Fdefaultimg%3D0&ETag=z7ucT5kdAq7HuNQf%2FGTEJg%3D%3D","thumbnail":null,"duration":null,"container":null}}]},"terms_and_conditions":{"text":"Specific terms and conditions in your agreement with MetaBroadcast, and with any data provider, apply to your use of this data, and associated systems."},"results":1,"request":{"path":"/4/schedules/hsxv.json","parameters":{"annotations":"content.description","from":"2022-03-20T00:00:00Z","to":"2022-03-21T00:00:00Z","source":"api.youview.tv","key":"b4d2edb68da14dfb9e47b5465e99b1b1"}}}` + + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + title: 'The Finest Hours (2016)', + description: `Drama based on a true story, recounting one of history's most daring coastguard rescue attempts. Stranded on a sinking oil tanker along with 30 other sailors, engineer Ray Sybert battles to buy his crew more time as Captain Bernie Webber and three of his colleagues tackle gigantic waves and gale-force winds in their astonishing bid to save the seamen.`, + icon: 'https://images.metabroadcast.com?source=http%3A%2F%2Fimages-live.youview.tv%2Fimages%2Fentity%2F52172983%2Fprimary%2F1_1024x576.jpg%3Fdefaultimg%3D0&ETag=z7ucT5kdAq7HuNQf%2FGTEJg%3D%3D', + season: null, + episode: null, + start: '2022-03-19T23:30:00.000Z', + stop: '2022-03-20T01:20:00.000Z' + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `{"schedule":{"channel":{"title":"BBC One HD","id":"hsxv","uri":"http://api.youview.tv/channels/dvb://233a..4484","images":[{"uri":"https://images.metabroadcast.com?source=http%3A%2F%2Fimages-live.youview.tv%2Fimages%2Fentity%2F8c4c0357-d7ee-5d8a-8bc4-b177b6875128%2Fident%2F1_1024x532.png%3Fdefaultimg%3D0&ETag=r5vyecG6of%2BhCbHeEClx0Q%3D%3D","mime_type":"image/png","type":null,"color":"monochrome","theme":"light_monochrome","aspect_ratio":null,"availability_start":null,"availability_end":null,"width":1024,"height":532,"hasTitleArt":null,"source":null}],"available_from":[{"key":"api.youview.tv","name":"YouView JSON","country":"GB"}],"source":{"key":"api.youview.tv","name":"YouView JSON","country":"GB"},"same_as":[],"media_type":"video","broadcaster":null,"aliases":[{"namespace":"youview:serviceLocator","value":"dvb://233a..4484"},{"namespace":"youview:channel:id","value":"8c4c0357-d7ee-5d8a-8bc4-b177b6875128"}],"genres":[],"high_definition":true,"timeshifted":null,"regional":null,"related_links":[],"start_date":null,"advertised_from":null,"advertised_to":null,"short_description":null,"medium_description":null,"long_description":null,"region":null,"target_regions":[],"channel_type":"CHANNEL","interactive":false,"transmission_types":["DTT"],"quality":"HD","hdr":false},"source":"api.youview.tv","entries":[]},"terms_and_conditions":{"text":"Specific terms and conditions in your agreement with MetaBroadcast, and with any data provider, apply to your use of this data, and associated systems."},"results":1,"request":{"path":"/4/schedules/hsxv.json","parameters":{"annotations":"content.description","from":"2022-03-20T00:00:00Z","to":"2022-03-21T00:00:00Z","source":"api.youview.tv","key":"b4d2edb68da14dfb9e47b5465e99b1b1"}}}` + }) + expect(result).toMatchObject([]) +}) \ No newline at end of file diff --git a/sites/bt.com/bt.com_uk.channels.xml b/sites/bt.com/bt.com_uk.channels.xml new file mode 100644 index 00000000..8dcb129f --- /dev/null +++ b/sites/bt.com/bt.com_uk.channels.xml @@ -0,0 +1,189 @@ + + + + 4Music + 4seven + 5 Select + 5 Star + 5 USA + Al Jazeera English + BBC Alba + BBC Four + BBC Four HD + BBC News + BBC One Cambridgeshire + BBC One Channel Islands + BBC One East Midlands + BBC One HD + BBC One London + BBC One North East & Cumbria + BBC One North West + BBC One Oxford + BBC One Scotland + BBC One Scotland HD + BBC One South + BBC One South East + BBC One South West + BBC One Wales + BBC One Wales HD + BBC One West + BBC One West Midlands + BBC One Yorks + BBC Parliament + BBC Scotland + BBC Scotland HD + BBC Two England + BBC Two HD + BBC Two Wales + Blaze UK + Boomerang UK + Box Nation + BT Sport 1 + BT Sport 2 + BT Sport 3 + BT Sport Box Office 2 UK + BT Sport Box Office UK + BT Sport / ESPN + BT Sport Extra 1 + BT Sport Extra 2 + BT Sport Extra 3 + BT Sport Extra 4 + BT Sport Extra 5 + BT Sport Extra 6 + BT Sport Ultimate + Cartoonito UK + Cartoon Network UK + Cartoon Network UK + CBBC + CBeebies UK + CBS Drama UK + CBS Justice UK + CBS Reality UK + Challenge UK + Channel 4 + Channel 5 + Channel 5 +1 + CITV + Clubland TV + Comedy Central UK + Craft Store TV + Create and Craft + Dave ja vu + Dave UK + DMAX UK + Drama UK + E4 UK + E4+1 + Eurosport 1 UK + Eurosport 2 UK + Film 4 UK + Film 4 UK +1 + Food Network UK + Forces TV + FreeSports + GB News + Gems TV + Gold HD + Great! Movies + Great! Movies Action + Great! Movies Action + 1 + Great! Movies Classic + Great! Movies Classic +1 + Great! TV + Great! TV +1 + HGTV UK + Horror Channel UK + Ideal Extra + Ideal World + ITV + ITV 2 + ITV 2 +1 + ITV 3 + ITV 3 +1 + ITV 4 + ITV 4 +1 + ITV Be + ITV Border England + ITV London + ITV Wales + Jewellery Maker + LFC TV + More 4 UK + More4+1 + MTV UK + National Geographic UK + National Geographic UK + Nickelodeon Europe + Nick Jr UK + NickToons UK + Now 70's + Now 80's + Now 90's + Paramount Network UK + PBS America + Pick UK + Pop + Pop Max + Quest Red UK + Quest Red UK +1 + Quest + Quest UK +1 + QVC UK Beauty + QVC Style UK + QVC UK + Really UK + S4C + Sky Arts HD + Sky Atlantic + Sky Atlantic HD + Sky Cinema Action HD + Sky Cinema Animation HD + Sky Cinema Comedy HD + Sky Cinema Drama HD + Sky Cinema Family HD + Sky Cinema Greats HD + Sky Cinema Hits HD + Sky Cinema Premiere HD + Sky Cinema Sci-Fi Horror HD + Sky Cinema Select + Sky Cinema Thriller HD + Sky Comedy + Sky Comedy HD + Sky Crime + Sky Crime HD + Sky Documentaries + Sky Documentaries HD + Sky History HD + Sky Max HD + Sky Nature + Sky Nature HD + Sky News HD + Sky Showcase HD + Sky Sports Action + Sky Sports Arena + Sky Sports Box Office + Sky Sports Cricket + Sky Sports F1 + Sky Sports Football + Sky Sports Golf + Sky Sports Main Event + Sky Sports Mix + Sky Sports News UK + Sky Sports Premier League + Sky Sports Racing + Sky Witness HD + Sky Witness + Smithsonian Channel UK + STV + STV+1 + Syfy UK + Talking Pictures TV + TBN UK + Tiny Pop + TJC + Together TV + Xpanded TV + Yesterday + Yesterday+1 + +