From f390955ad82ed36070aa3e8378dc9320effae4fd Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:57:39 +0300 Subject: [PATCH] Update watch.sportsnet.ca --- sites/watch.sportsnet.ca/readme.md | 21 +++++++++++++++++++ .../watch.sportsnet.ca.channels.xml | 16 +++++++------- .../watch.sportsnet.ca.config.js | 19 +++++++++++++++++ 3 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 sites/watch.sportsnet.ca/readme.md diff --git a/sites/watch.sportsnet.ca/readme.md b/sites/watch.sportsnet.ca/readme.md new file mode 100644 index 00000000..47972314 --- /dev/null +++ b/sites/watch.sportsnet.ca/readme.md @@ -0,0 +1,21 @@ +# watch.sportsnet.ca + +https://watch.sportsnet.ca/schedule/tvlistings + +### Download the guide + +```sh +npm run grab -- --site=watch.sportsnet.ca +``` + +### Update channel list + +```sh +npm run channels:parse -- --config=./sites/watch.sportsnet.ca/watch.sportsnet.ca.config.js --output=./sites/watch.sportsnet.ca/watch.sportsnet.ca.channels.xml +``` + +### Test + +```sh +npm test -- watch.sportsnet.ca +``` diff --git a/sites/watch.sportsnet.ca/watch.sportsnet.ca.channels.xml b/sites/watch.sportsnet.ca/watch.sportsnet.ca.channels.xml index 46b43660..a8b70bd7 100644 --- a/sites/watch.sportsnet.ca/watch.sportsnet.ca.channels.xml +++ b/sites/watch.sportsnet.ca/watch.sportsnet.ca.channels.xml @@ -1,11 +1,11 @@ - SportsNet 360 - SportsNet East - SportsNet One - SportsNet Ontario - SportsNet Pacific - SportsNet West - SportsNet World - WWE Network Canada + SN 360 + SN East + SN One + SN Ontario + SN Pacific + SN West + SN World + WWE Network diff --git a/sites/watch.sportsnet.ca/watch.sportsnet.ca.config.js b/sites/watch.sportsnet.ca/watch.sportsnet.ca.config.js index 9dba972b..70f80d1f 100644 --- a/sites/watch.sportsnet.ca/watch.sportsnet.ca.config.js +++ b/sites/watch.sportsnet.ca/watch.sportsnet.ca.config.js @@ -25,6 +25,25 @@ module.exports = { }) return programs + }, + async channels() { + const axios = require('axios') + const html = await axios + .get(`https://watch.sportsnet.ca/schedule/tvlistings`) + .then(r => r.data) + .catch(console.log) + + let [, __data] = html.match(/window\.__data \= ([^<]+)<\/script>/) + const func = new Function(`"use strict";return ${__data}`) + const data = func() + + return data.cache.list['678|page_size=24'].list.items.map(item => { + return { + lang: 'en', + site_id: item.id, + name: item.title + } + }) } }