From f6582acbb86a2108107561f42f308b86c33aecb5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:25:53 +0300 Subject: [PATCH 1/6] Create content.html --- sites/tvpassport.com/__data__/content.html | 578 +++++++++++++++++++++ 1 file changed, 578 insertions(+) create mode 100644 sites/tvpassport.com/__data__/content.html diff --git a/sites/tvpassport.com/__data__/content.html b/sites/tvpassport.com/__data__/content.html new file mode 100644 index 00000000..82d9a75f --- /dev/null +++ b/sites/tvpassport.com/__data__/content.html @@ -0,0 +1,578 @@ + + + + + + + + +TV Schedule for Youtoo America - Network | TV Passport + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+ +
+
+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+
+
+
+
+ +
+

TV Schedule for Youtoo America - Network

+
    +
  • Online
  • +
  • +
  • +
  • +
+

Visit website

+
+
+
+
+
+
+ +
+
+ + + +
+
+ +
+
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+ +
+ +
+
+
+
+ + + + +
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file From 1630cccd914600b164934c08b5c52d786a431004 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:25:59 +0300 Subject: [PATCH 2/6] Create tvpassport.com.test.js --- sites/tvpassport.com/tvpassport.com.test.js | 63 +++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 sites/tvpassport.com/tvpassport.com.test.js diff --git a/sites/tvpassport.com/tvpassport.com.test.js b/sites/tvpassport.com/tvpassport.com.test.js new file mode 100644 index 00000000..2edf8e32 --- /dev/null +++ b/sites/tvpassport.com/tvpassport.com.test.js @@ -0,0 +1,63 @@ +// npx epg-grabber --config=sites/tvpassport.com/tvpassport.com.config.js --channels=sites/tvpassport.com/tvpassport.com_us.channels.xml --output=guide.xml --days=2 +// npm run channels:parse -- --config=./sites/tvpassport.com/tvpassport.com.config.js --output=./sites/tvpassport.com/tvpassport.com_us.channels.xml + +const { parser, url, request } = require('./tvpassport.com.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('2022-10-04', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: 'youtoo-america-network/5463', + xmltv_id: 'YTATV.us' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://www.tvpassport.com/tv-listings/stations/youtoo-america-network/5463/2022-10-04' + ) +}) + +it('can generate valid request headers', () => { + expect(request.headers).toMatchObject({ + Cookie: 'cisession=e49ff13191d6875887193cae9e324b44ef85768d;' + }) +}) + +it('can parse response', () => { + const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html')) + + let results = parser({ content }) + results = results.map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(results[0]).toMatchObject({ + start: '2022-10-04T10:00:00.000Z', + stop: '2022-10-04T10:30:00.000Z', + title: 'Charlie Moore: No Offense', + sub_title: 'Under the Influencer', + category: ['Sports', 'Outdoors'], + icon: 'https://cdn.tvpassport.com/image/show/960x540/69103.jpg', + rating: { + system: 'MPA', + value: 'TV-G' + }, + actors: ['John Reardon', 'Mayko Nguyen', 'Justin Kelly'], + director: ['Rob McElhenney'], + guest: ['Sean Penn'], + description: + 'Celebrity interviews while fishing in various locations throughout the United States.' + }) +}) + +it('can handle empty guide', () => { + const result = parser({ content: '' }) + expect(result).toMatchObject([]) +}) From 39d7d87751d8d10e6cc29f71303e76a6f66070f5 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:26:03 +0300 Subject: [PATCH 3/6] Create tvpassport.com.config.js --- sites/tvpassport.com/tvpassport.com.config.js | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 sites/tvpassport.com/tvpassport.com.config.js diff --git a/sites/tvpassport.com/tvpassport.com.config.js b/sites/tvpassport.com/tvpassport.com.config.js new file mode 100644 index 00000000..7836937b --- /dev/null +++ b/sites/tvpassport.com/tvpassport.com.config.js @@ -0,0 +1,140 @@ +const axios = require('axios') +const dayjs = require('dayjs') +const cheerio = require('cheerio') +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: 'tvpassport.com', + url({ channel, date }) { + return `https://www.tvpassport.com/tv-listings/stations/${channel.site_id}/${date.format( + 'YYYY-MM-DD' + )}` + }, + request: { + headers: { + Cookie: 'cisession=e49ff13191d6875887193cae9e324b44ef85768d;' + } + }, + parser: function ({ content }) { + let programs = [] + const items = parseItems(content) + for (let item of items) { + const $item = cheerio.load(item) + const start = parseStart($item) + const duration = parseDuration($item) + const stop = start.add(duration, 'm') + programs.push({ + title: parseTitle($item), + sub_title: parseSubTitle($item), + description: parseDescription($item), + icon: parseIcon($item), + category: parseCategory($item), + rating: parseRating($item), + actors: parseActors($item), + guest: parseGuest($item), + director: parseDirector($item), + start, + stop + }) + } + + return programs + }, + async channels() { + const content = await axios + .get(`https://www.tvpassport.com/tv-listings`, { + headers: { + Cookie: 'cisession=317b3a464bfe449650b7cc4b16ccf900a6646d88;' + } + }) + .then(r => r.data) + .catch(console.log) + const $ = cheerio.load(content) + + return $('.channel_cell') + .map((i, el) => { + const site_id = $(el) + .find('a') + .attr('href') + .replace('https://www.tvpassport.com/tv-listings/stations/', '') + const name = $(el).find('.sr-only').text().trim() + + return { + site_id, + name + } + }) + .get() + } +} + +function parseDescription($item) { + return $item('*').data('description') +} + +function parseIcon($item) { + const showpicture = $item('*').data('showpicture') + const url = new URL(showpicture, 'https://cdn.tvpassport.com/image/show/960x540/') + + return url.href +} + +function parseTitle($item) { + return $item('*').data('showname') +} + +function parseSubTitle($item) { + return $item('*').data('episodetitle') +} + +function parseCategory($item) { + return $item('*').data('showtype').split(', ') +} + +function parseActors($item) { + return $item('*').data('cast').split(', ') +} + +function parseDirector($item) { + return $item('*').data('director').split(', ') +} + +function parseGuest($item) { + return $item('*').data('guest').split(', ') +} + +function parseRating($item) { + const rating = $item('*').data('rating') + + return rating + ? { + system: 'MPA', + value: rating.replace(/^TV/, 'TV-') + } + : null +} + +function parseStart($item) { + const time = $item('*').data('st') + + return dayjs.tz(time, 'YYYY-MM-DD HH:mm:ss', 'America/New_York') +} + +function parseDuration($item) { + const duration = $item('*').data('duration') + + return parseInt(duration) +} + +function parseItems(content) { + if (!content) return [] + const $ = cheerio.load(content) + + return $(`.station-listings .list-group-item`).toArray() +} From c9b9ccbe39a6c8048b524ac226489aa9b32b60ae Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:26:20 +0300 Subject: [PATCH 4/6] Create tvpassport.com_us.channels.xml --- .../tvpassport.com_us.channels.xml | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 sites/tvpassport.com/tvpassport.com_us.channels.xml diff --git a/sites/tvpassport.com/tvpassport.com_us.channels.xml b/sites/tvpassport.com/tvpassport.com_us.channels.xml new file mode 100644 index 00000000..b3dc7a6c --- /dev/null +++ b/sites/tvpassport.com/tvpassport.com_us.channels.xml @@ -0,0 +1,148 @@ + + + + Hope Channel (W20CQ-D) Hempstead, NY + Esperanza (W20CQ-D2) Hempstead, NY + ABC (WABC) New York, NY + Localish (WABC-DT2) New York, NY + THIS (WABC-TV3) New York, NY + HSN (WABC-TV4) New York, NY + Estrella (WASA-LD) Port Jervis, NY + CBS (WCBS) New York, NY + Start TV (WCBS-TV2) New York, NY + DABL (WCBS-TV3) New York, NY + The Country Network (WDVB) Edison, NJ + SSTN (WDVB-CD2) Edison, NJ + Connecticut Public Television (WEDW) Bridgeport + CPTV Spirit (WEDW-DT3) Bridgeport, CT + UniMás (WFTY) Smithtown, NY + UNI (WFTY-DT2) New York, NY + ION Mystery (WFTY-DT4) Smithtown, NY + True Crime Network (WFUT-DT2) Newark, NJ + GetTV (WFUT-DT3) Newark, NJ + ION Mystery (WFUT-DT4) Newark, NJ + Laff (WJLP2) New Jersey + Grit TV (WJLP3) New Jersey/New York + ION Mystery (WJLP4) New Jersey/New York + Retro TV (WJLP5) Middletown Township, NJ + Heartland (WJLP6) Middletown Township, NJ + Azteca (WKOB) New York, NY + Daystar (WKOB-LD2) New York, NY + Peace TV (WKOB-LD3) New York, NY + SonLife Network (WKOB-LD5) New York, NY + Estrella (WKOB-DT6) New York, NY + Shop LC (WKOB-DT7) New York, NY + ONTV4U (WKOB-DT8) New York, NY + PBS (WLIW) Long Island, NY + Create (WLIW2) Long Island, NY + PBS World (WLIW3) Long Island, NY + Comet TV (WLNY-TV2) Riverhead, NY + Stadium (WLNY-TV3) Riverhead, NY + THIS (WLNY-TV4) Riverhead, NY + Circle (WLNY-TV5) Riverhead, NY + Quest (WMBC-TV2) Newton, NJ + New Tang Dynasty TV (WMBC-DT5) Newton, NJ + Aliento Vision (WMBC-TV7) Newton, NJ + Biz-TV (WMBQ-CD) New York, NY + Hope Channel (WMBQ-CD2) New York, NY + NBC (WNBC) New York, NY + Cozi (WNBC-DT2) New York, NY + FNX (WNDT-CD) Manhattan, NY + PBS (WNET) New York, NY + PBS Kids (WNET-DT2) New York, NY + V-Me (WNET-DT3) New York, NY + NJ PBS (WNJB) New Brunswick, NJ + NJ PBS (WNJN) Montclair, NJ + NJ PBS (WNJT) Trenton, NJ + NHK World (WNJT-TV2) Trenton, NJ + Telemundo (WNJU) Teterboro, NJ + TeleXitos (WNJU2) Teterboro, NJ + Infomercials (WNMF) New York, NY + Jewelry TV (WNMF-LD2) New York, NY + CGTN (WNXY-LD) New York, NY + CCTV-4 (WNXY-LD2) New York, NY + CGTN Spanish (WNXY-LD3) New York, NY + NYC Life (WNYE-DT1) New York, NY + NYC Gov (WNYE-DT2) New York, NY + CUNY (WNYE-DT3) New York, NY + France 24 (WNYJ-DT3) West Milford, NJ + Azteca (WNYN) New York, NY + Azteca (WNYN-LD3) New York, NY + FOX (WNYW) New York, NY + Movies! (WNYW2) New York, NY + MNT (WNYW3) New York, NY + The Grio (WNYW4) New York, NY + Decades (WNYW5) New York, NY + CGTN (WNYX-LD) New York, NY + CCTV-4 (WNYX-LD2) New York, NY + CGTN Spanish (WNYX-LD3) New York, NY + REV'N (WNYX-LD4) New York, NY + Retro TV (WNYX-LD5) New York, NY + Antenna (WPIX2) New York, NY + Court TV (WPIX3) New York, NY + Rewind TV US (WPIX4) New York, NY + Localish (WPVI-DT2) Philadelphia, PA + THIS (WPVI-TV3) Philadelphia, PA + ION (WPXN) New York, NY + Bounce (WPXN-TV2) New York, NY + ION Mystery (WPXN-TV3) New York, NY + Defy (WPXN-TV4) New York, NY + Laff (WPXN-TV5) New York, NY + TrueReal (WPXN-TV6) New York, NY + Newsy (WPXN-TV7) New York, NY + América TeVé (WPXO-LD) East Orange, NJ + Court TV (WPXU-TV2) Jacksonville, NC + Grit TV (WPXU-TV3) Jacksonville, NC + Laff (WPXU-TV4) Jacksonville, NC + QVC (WPXU-TV5) Jacksonville, NC + Circle (WRNN-TV2) New York + Canal de La Fe (WRNN-DT3) New York, NY + QVC2 (WRNN-TV4) New York, NY + TBN (WTBY) New York, NY + Smile (WTBY-TV2) New York, NY + Enlace (WTBY-TV3) New York, NY + PosiTiV (WTBY-TV4) New York, NY + ABC (WTNH) SD New Haven, CT + ABC (WTNH-DT1) HD New Haven, CT + Rewind TV US (WTNH2) New Haven, CT + MNT (WWOR) New York, NY + Circle (WWOR-TV2) New York, NY + Buzzr TV (WWOR-TV3) New York, NY + H&I (WWOR-DT4) New York, NY + CGTN (WXNY-LD) New York, NY + CCTV-4 (WXNY-LD2) New York, NY + CGTN Spanish (WXNY-LD3) New York, NY + Retro TV (WXNY-LD4) New York, NY + Retro TV (WXNY-LD5) New York, NY + UNI (WXTV) Teaneck, NJ + Bounce (WXTV-DT2) Paterson, NJ + Twist (WXTV-DT3) Paterson, NJ + Grit TV (WXTV-DT4) Paterson, NJ + CGTN (WYXN-LD) New York, NY + Youtoo America - Network + + + + + + + + + + + + + + + + + + + + + + + + + + From 1790126f39bfbc95d205c4d9ad0d6f7270ea8f9c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:26:23 +0300 Subject: [PATCH 5/6] Create tvpassport.com.yml --- .github/workflows/tvpassport.com.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/tvpassport.com.yml diff --git a/.github/workflows/tvpassport.com.yml b/.github/workflows/tvpassport.com.yml new file mode 100644 index 00000000..e29d9eca --- /dev/null +++ b/.github/workflows/tvpassport.com.yml @@ -0,0 +1,17 @@ +name: tvpassport.com +on: + schedule: + - cron: '0 3 * * *' + workflow_dispatch: + workflow_run: + workflows: [_trigger] + types: + - completed +jobs: + load: + uses: ./.github/workflows/_load.yml + with: + site: ${{github.workflow}} + secrets: + APP_ID: ${{ secrets.APP_ID }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} From 92c928df55a22f0c9bcbf939fe4226b8eaef1532 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Tue, 4 Oct 2022 22:29:06 +0300 Subject: [PATCH 6/6] Update tvpassport.com_us.channels.xml --- sites/tvpassport.com/tvpassport.com_us.channels.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/sites/tvpassport.com/tvpassport.com_us.channels.xml b/sites/tvpassport.com/tvpassport.com_us.channels.xml index b3dc7a6c..02f96c0e 100644 --- a/sites/tvpassport.com/tvpassport.com_us.channels.xml +++ b/sites/tvpassport.com/tvpassport.com_us.channels.xml @@ -103,7 +103,6 @@ Enlace (WTBY-TV3) New York, NY PosiTiV (WTBY-TV4) New York, NY ABC (WTNH) SD New Haven, CT - ABC (WTNH-DT1) HD New Haven, CT Rewind TV US (WTNH2) New Haven, CT MNT (WWOR) New York, NY Circle (WWOR-TV2) New York, NY