diff --git a/sites/tv.blue.ch/tv.blue.ch.config.js b/sites/tv.blue.ch/tv.blue.ch.config.js new file mode 100644 index 00000000..16d85630 --- /dev/null +++ b/sites/tv.blue.ch/tv.blue.ch.config.js @@ -0,0 +1,88 @@ +const axios = require('axios') +const cheerio = require('cheerio') +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') + +dayjs.extend(utc) + +module.exports = { + site: 'tv.blue.ch', + url: function ({ channel, date }) { + return `https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=${ + channel.site_id + };start=${date.format('YYYYMMDDHHss')};end=${date + .add(1, 'd') + .format('YYYYMMDDHHss')};level=normal)` + }, + logo({ channel }) { + return `https://services.sg101.prd.sctv.ch/content/images/tv/channel/${channel.site_id}_image_7_w116.webp` + }, + parser: function ({ content }) { + let programs = [] + const items = parseItems(content) + items.forEach(item => { + const title = parseTitle(item) + if (title === 'Sendepause') return + programs.push({ + title, + description: parseDescription(item), + icon: parseIcon(item), + start: parseStart(item), + stop: parseStop(item) + }) + }) + + return programs + }, + async channels() { + const items = await axios + .get(`https://services.sg101.prd.sctv.ch/portfolio/tv/channels`) + .then(r => r.data) + .catch(console.log) + + return items.map(item => { + return { + lang: item.Languages[0] || 'de', + site_id: item.Identifier, + name: item.Title + } + }) + } +} + +function parseTitle(item) { + return item.Content.Description.Title +} + +function parseDescription(item) { + return item.Content.Description.Summary +} + +function parseIcon(item) { + const image = item.Content.Nodes ? item.Content.Nodes.Items.find(i => i.Kind === 'Image') : null + const path = image ? image.ContentPath : null + + return path ? `https://services.sg101.prd.sctv.ch/content/images${path}_w1920.webp` : null +} + +function parseStart(item) { + const available = item.Availabilities.length ? item.Availabilities[0] : null + + return dayjs(available.AvailabilityStart) +} + +function parseStop(item) { + const available = item.Availabilities.length ? item.Availabilities[0] : null + + return dayjs(available.AvailabilityEnd) +} + +function parseItems(content) { + const data = JSON.parse(content) + const nodes = data.Nodes.Items.filter(i => i.Kind === 'Channel') + if (!nodes.length) return [] + + return nodes[0].Content.Nodes && Array.isArray(nodes[0].Content.Nodes.Items) + ? nodes[0].Content.Nodes.Items.filter(i => i.Kind === 'Broadcast') + : [] +} diff --git a/sites/tv.blue.ch/tv.blue.ch.test.js b/sites/tv.blue.ch/tv.blue.ch.test.js new file mode 100644 index 00000000..fa8cc6e8 --- /dev/null +++ b/sites/tv.blue.ch/tv.blue.ch.test.js @@ -0,0 +1,78 @@ +// node ./scripts/commands/parse-channels.js --config=./sites/tv.blue.ch/tv.blue.ch.config.js --output=./sites/tv.blue.ch/tv.blue.ch_ch.channels.xml +// npx epg-grabber --config=sites/tv.blue.ch/tv.blue.ch.config.js --channels=sites/tv.blue.ch/tv.blue.ch_ch.channels.xml --output=guide.xml --days=2 + +const { parser, url, logo } = require('./tv.blue.ch.config.js') +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-01-17', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '1221', + xmltv_id: 'BlueZoomD.ch' +} + +it('can generate valid url', () => { + expect(url({ channel, date })).toBe( + 'https://services.sg101.prd.sctv.ch/catalog/tv/channels/list/(ids=1221;start=202201170000;end=202201180000;level=normal)' + ) +}) + +it('can get logo url', () => { + expect(logo({ channel })).toBe( + 'https://services.sg101.prd.sctv.ch/content/images/tv/channel/1221_image_7_w116.webp' + ) +}) + +it('can parse response', () => { + const content = `{"Nodes":{"Count":1,"TotalItemCount":1,"Items":[{"Domain":"TV","Identifier":"1221","Kind":"Channel","Content":{"Description":{"Title":"blue Zoom D","Language":"de"},"Nodes":{"Count":29,"TotalItemCount":29,"Items":[{"Domain":"TV","Identifier":"t1221ddc59247d45","Kind":"Broadcast","Channel":"1221","Content":{"Description":{"Title":"Weekend on the Rocks","Summary":" - «R.E.S.P.E.C.T», lieber Charles Nguela. Der Comedian tourt fleissig durch die Schweiz, macht für uns aber einen Halt, um in der neuen Ausgabe von «Weekend on the Rocks» mit Moderatorin Vania Spescha über die Entertainment-News der Woche zu plaudern.","ShortSummary":"","Country":"CH","ReleaseDate":"2021-01-01T00:00:00Z","Source":"13","Language":"de","Duration":"00:30:00"},"Nodes":{"Count":1,"TotalItemCount":1,"Items":[{"Domain":"TV","Identifier":"t1221ddc59247d45_landscape","Kind":"Image","Role":"Landscape","ContentPath":"/tv/broadcast/1221/t1221ddc59247d45_landscape","Version":{"Date":"2022-01-04T08:55:22.567Z"}}]},"TechnicalAttributes":{"Stereo":true}},"Version":{"Hash":"60d3"},"Availabilities":[{"AvailabilityStart":"2022-01-16T23:30:00Z","AvailabilityEnd":"2022-01-17T00:00:00Z"}],"Relations":[{"Domain":"TV","Kind":"Reference","Role":"ChannelIdentifier","TargetIdentifier":"2b0898c7-3920-3200-7048-4ea5d9138921"},{"Domain":"TV","Kind":"Reference","Role":"OriginalAirSeries","TargetIdentifier":"false"},{"Domain":"TV","Kind":"Reference","Role":"ExternalBroadcastIdentifier","TargetIdentifier":"167324536-11"},{"Domain":"TV","Kind":"Reference","Role":"ProgramIdentifier","TargetIdentifier":"p12211351631155","Title":"Original"}]}]}}}]}}` + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-01-16T23:30:00.000Z', + stop: '2022-01-17T00:00:00.000Z', + title: 'Weekend on the Rocks', + description: + ' - «R.E.S.P.E.C.T», lieber Charles Nguela. Der Comedian tourt fleissig durch die Schweiz, macht für uns aber einen Halt, um in der neuen Ausgabe von «Weekend on the Rocks» mit Moderatorin Vania Spescha über die Entertainment-News der Woche zu plaudern.', + icon: 'https://services.sg101.prd.sctv.ch/content/images/tv/broadcast/1221/t1221ddc59247d45_landscape_w1920.webp' + } + ]) +}) + +it('can parse response without image', () => { + const content = `{"Nodes":{"Count":1,"TotalItemCount":1,"Items":[{"Domain":"TV","Identifier":"1221","Kind":"Channel","Content":{"Description":{"Title":"blue Zoom D","Language":"de"},"Nodes":{"Count":29,"TotalItemCount":29,"Items":[{"Domain":"TV","Identifier":"t10014a78a8b0668","Kind":"Broadcast","Channel":"1001","Content":{"Description":{"Title":"Sendepause","Language":"fr","Duration":"00:01:00"}},"Version":{"Hash":"440e"},"Availabilities":[{"AvailabilityStart":"2022-01-17T04:59:00Z","AvailabilityEnd":"2022-01-17T05:00:00Z"}],"Relations":[{"Domain":"TV","Kind":"Reference","Role":"ChannelIdentifier","TargetIdentifier":"3553a4f2-ff63-5200-7048-d8d59d805f81"},{"Domain":"TV","Kind":"Reference","Role":"Dummy","TargetIdentifier":"True"},{"Domain":"TV","Kind":"Reference","Role":"ProgramIdentifier","TargetIdentifier":"p1"}]}]}}}]}}` + const result = parser({ content }).map(p => { + p.start = p.start.toJSON() + p.stop = p.stop.toJSON() + return p + }) + + expect(result).toMatchObject([ + { + start: '2022-01-17T04:59:00.000Z', + stop: '2022-01-17T05:00:00.000Z', + title: 'Sendepause' + } + ]) +}) + +it('can handle wrong site id', () => { + const result = parser({ + content: `{"Status":{"Version":"7","Status":"OK","ProcessingTime":"00:00:00.0160674","ExecutionTime":"2022-01-17T13:47:30.584Z"},"Request":{"Domain":"TV","Resource":"Channels","Action":"List","Parameters":"(ids=12210;start=202201170000;end=202201180000;level=normal)","Identifiers":["12210"],"Start":"2022-01-17T00:00:00Z","End":"2022-01-18T00:00:00Z","DataLevel":"Normal"},"DataSource":{"Snapshot":"Tv_20220117114748","DbCreationTime":"2022-01-17T11:49:14.608Z","IncrementCreationTime":"0001-01-01T00:00:00Z"},"Nodes":{"Items":[]}}` + }) + expect(result).toMatchObject([]) +}) + +it('can handle empty guide', () => { + const result = parser({ + content: `{"Status":{"Version":"7","Status":"OK","ExecutionTime":"2022-01-17T15:30:37.97Z"},"Request":{"Domain":"TV","Resource":"Channels","Action":"List","Parameters":"(ids=1884;start=202201170000;end=202201180000;level=normal)","Identifiers":["1884"],"Start":"2022-01-17T00:00:00Z","End":"2022-01-18T00:00:00Z","DataLevel":"Normal"},"DataSource":{"Snapshot":"Tv_20220117144354","DbCreationTime":"2022-01-17T14:45:11.84Z","IncrementCreationTime":"0001-01-01T00:00:00Z"},"Nodes":{"Count":1,"TotalItemCount":1,"Items":[{"Domain":"TV","Identifier":"1884","Kind":"Channel","Content":{"Description":{"Title":"Fisu.tv 1","Language":"en"}}}]}}` + }) + expect(result).toMatchObject([]) +}) diff --git a/sites/tv.blue.ch/tv.blue.ch_ch.channels.xml b/sites/tv.blue.ch/tv.blue.ch_ch.channels.xml new file mode 100644 index 00000000..18edbb1b --- /dev/null +++ b/sites/tv.blue.ch/tv.blue.ch_ch.channels.xml @@ -0,0 +1,578 @@ + + + + 2M Monde + Alarabiya + Aljazeera Channel + Al Masriyah + Dubai TV + Watania 1 + BN TV Satelitski + Hayat Folk + Hayat Plus + OBN + CT 24 + 13th Street Deutschland + 3+ + 3sat + 4+ + 5+ + 6+ + 7+ & Nick Schweiz + Alpenland TV + Animal Planet Europe + Anixe HD Serie + ARD Alpha + ARTE Deutsch + Auftanken TV + Auto Motor og Sport TV + Auto Motor und Sport + Bayerisches Fernsehen Süd + Bergblick + Bibel TV + Bild + Blue Zoom D + Bodensee TV + Bon Gusto + Boomerang Deutschland + Cartoon Network Deutschland + Comedy Central Hungary + Crime + Investigation Deutschland + Das Erste + DAZN 1 Deutschland + Deluxe Music + Deutsches Musik Fernsehen + Discovery Channel Deutschland + Disney Channel Deutschland + DMAX Deutschland + Duck TV SD + DW Deutsch + E! Deutschland + ESports 1 + Eurochannel + EuroNews Deutsch + Eurosport 1 Germany + Eurosport 2 + Fix & Foxi + Folx + Game TV + Geo TV + Goldstar TV + GoTV + Heimatkanal + Helvetia One TV + HGTV Deutschland + History Deutschland + HitExpress TV + Hope TV Deutsch + HR Fernsehen + HSE + Junior + Kabel Eins Classics + Kabel Eins Doku Deutschland + Kabel Eins Schweiz + Kanal 9 + KIKA + Kinowelt TV + K-TV + Loly TV + Marco Polo TV + MDR Fernsehen Sachsen + Melodie TV + More Than Sports TV + Motorvision TV + MTV Germany + musig24 TV + N24 Doku + National Geographic Deutschland + National Geographic Wild Deutschland + NDR Fernsehen Hamburg + Nicktoons Deutschland + Nitro Deutschland + N-TV + One + One 1 Music TV + ORF 1 + ORF 2 + ORF III + ORF Sport + + Phoenix TV! + Premium Shopping TV + ProSieben Fun + ProSieben Maxx Deutschland + ProSieben Schweiz + Puls Acht + R9 + Radio Pilatus TV + RBB Berlin + regioTVplus + Rheinwelten TV + RiC + Romance TV Deutschland + rrotv + RTL Crime Deutschland + RTL Living Deutschland + RTL Passion Hrvatska + RTL Schweiz + RTL UHD + RTL Up + RTL Zwei Schweiz + S1 + Sat. 1 Deutschland + Sat. 1 Gold Deutschland + Schaffhauser Fernsehen + Schlager Deluxe + Servus TV Deutschland + Sixx Deutschland + Sony AXN + Sony Channel Deutschland + Spiegel Geschichte + Spiegel TV Wissen + Sport 1 + Sport 1+ + Sportdigital Fussball + SRF 1 + SR Fernsehen + SRF Info + SRF Zwei + Star TV + Stingray Classica + Südostschweiz + Super RTL Deutschland + Swiss 1 + Swiss Sport TV + SWR Fernsehen Baden-Württemberg + Syfy Deutschland + Tagesschau 24 + Tele 1 + Tele 5 + TeleBärn + Telebasel + TeleBielingue + Tele D + Tele M1 + Tele Top + Televista + Tele Z + Tele Zentralschweiz + TeleZüri + TLC Germany + Toggo Plus + TV 24 + TV 25 + TV4TNG + TVO + TV Oberwallis + TV Rheintal + UHD 1 + Universal TV Deutschland + Volksmusik TV + Vox Deutschland + Voxup + Warner TV Comedy + Warner TV Film + Warner TV Serie + WDR Fernsehen Köln + Welt + Welt der Wunder TV + Wetter.com TV + ZDF + ZDF Info + ZDF Neo + Zwei 2 Music TV + ERT World + RIK Sat + 4Seven + 5 Select + 5 Star + 5 USA + Aljazeera English + BBC Four + BBC News + BBC One + BBC Parliament + BBC Two + BBC World News + Bloomberg TV Europe + CBBC + CBeebies UK + CBS Reality Europe + Challenge UK + Channel 4 UK + Channel 5 + CITV + Clubland TV + CNBC UK + CNN International Europe + Dave UK + DMAX UK + Drama UK + DW English + E4 UK + Edge Sport + E! Europe + English Club TV + EuroNews English + Eurosport 1 + Extreme Sports Channel + FashionTV Europe + Film 4 UK + Food Network UK + Fox News Channel + France 24 English + FreeSports + FunBox UHD + GB News + Ginx eSports TV International + Great! Movies + Great! Movies Action + Great! Movies Classic + I24 News English + Insight HD + Insight UHD + ITV 2 + ITV 3 + ITV 4 + ITV Be + ITV London + Kerrang! + Kiss TV + Love Nature + More 4 UK + NASA TV Public + NHK World Japan + Now 70's + Now 80's + Now 90's + Paramount Network UK + PBS America + Pick UK + Quest UK + RT News + Sky News International + Smithsonian Channel UK + Stingray Festival 4K + Stingray IConcerts + The Box UK + Trace Hits + Voice of America + Yesterday + Aragón TV Internacional + Canal 24 Horas + Canal Extremadura Satélite + Canal Sur Andalucía + De Película Europa/Australia + GVAX TV + Las Estrellas Europa + Latinos 1 TV + Teledeporte + Telehit Música + Telesur + Tlnovelas Europa + TVE Internacional Europa + 13ème Rue + 6ter Suisse + AB 1 + AB 3 + Action + Ajoie TV + Alsace 20 + Animaux + ARTE Français + Automoto la chaîne + BET France + BFM Business + BFM TV + Boing France + Boomerang France + C8 + Canal Alpha JU + Canal Alpha NE + Canal J + Canal + Cinéma France + Canal + Décalé + Canal + France + Canal + Kids + Canal + Séries France + Canal + Sport France + Cartoon Network France + Chérie 25 + Cine + Classic + Cine + Club + Cine + Émotion + Cine + Famiz + Cine + Frisson + Cine + Premier + Clique TV + C News + Comédie + + Crime District + C Star + Discovery Channel France + Discovery Science France + Disney Channel France + Disney Junior France + E! France + Equidia + ES1 + EuroNews Français + Eurosport 1 France + Eurosport 2 France + France 2 + France 24 Français + France 3 + France 4 + France 5 + Franceinfo: + Game One + Genève Région Télévision + Golf Channel France + Golf + + Grand Genève TV + Gulli + Histoire TV + I24 News Français + InfoSport + + J-One + KTO + La Chaîne Météo + La Télé + LCI + LCP Assemblée Nationale + Léman Bleu + L'Équipe + LFM TV + M6 Suisse + Mangas + Max TV + MCM France + MCM Top + Melody + Mezzo + Mezzo Live HD + National Geographic France + National Geographic Wild France + Nickelodeon France + Nickelodeon Junior France + Nickelodeon Teen + Novelas TV + NRJ 12 + NRTV + OCS choc + OCS City génération HBO + OCS geants + OCS max + Olympia TV + One TV + ORTB TV + Paramount Channel France + Piwi + + Planète + + Planète + A&E + Planète + CI + Polar + + RFM TV + RMC Découverte + RMC Sport 1 + RMC Sport 2 + RMC Story + Rouge TV + RTL 9 + RTS 1 + RTS 2 + Science & Vie TV + Seasons + Stingray Djazz + Syfy France + TeleSwizz + TéléToon + + TF 1 Séries Films + TF 1 Suisse + TFX Suisse + Tiji + TMC Suisse + Toonami France + Toute l'Histoire + Trace Caribbean + Trace Urban + Trek + TV5Monde Europe + TV5Monde France Belgique Suisse + TV8 Mont-Blanc + TV Breizh + TVM 3 + TV Onex + TV Suisse Plus + Ultra Nature + Ushuaïa TV + Vernier Visions + W9 Suisse + Warner TV France + Galicia TV Europa + The Israeli Network + Utsav Gold + Utsav Plus + CMC TV + HRT 1 + HRT International + Z1 + Duna TV + Duna World + M1 + M2 + M5 + 20 Mediaset + 7 Gold + Alma TV + Boing Italia + Camera dei Deputati + Canale 5 + Canale Italia + Cartoonito Italia + Cielo + Cine 34 + Class TV Moda + Deejay TV + Discovery Channel Italia + Discovery Science Italia + DMAX Italia + Espansione TV + EuroNews Italiano + Eurosport 1 Italia + Eurosport 2 Italia + Focus + Food Network Italia + Frisbee + Giallo + GO-TV Canale 163 + HGTV Italia + History Italia + Iris + Italia 1 + Italia 2 + Italia Channel + Italian Fishing TV + K2 + La 5 + La 7 + La 7 d + Mediaset Extra + Motor Trend + National Geographic Italia + National Geographic Wild Italia + Nove + Paramount Network Italia + Radionorba TV + Radio Ticino Channel + Rai 1 + Rai 2 + Rai 3 + Rai 4 + Rai 5 + Rai Gulp + Rai Movie + Rai News 24 + Rai Premium + Rai Scuola + Rai Sport + Rai Sport + HD + Rai Storia + Rai Yoyo + Real Time Italia + Rete 4 + RSI La 1 + RSI La 2 + RTL 102.5 RadioVisione + San Marino RTV + Senato TV + Sky TG 24 + Spike Italia + Sportitalia + Super! + Super Tennis + Telelombardia + Telenova + TeleTicino + TGCom 24 + Top Calcio 24 + Top Crime + TV 2000 + TV 8 + Uninettuno University TV + VH1 Italy + Video Italia + KBS World + Kurdistan TV + Rûdaw + TRT Kurdî + BVN TV Europa + TVP Polonia + Record TV Europa + RTP 3 + RTP Internacional Europa + SIC Internacional + SIC Notícias + TVI Ficção + TVI Internacional + B1 + Digi 24 + Pro TV International + TVR International + Karusel International + Nash Kinomir + Ost West + Perviy kanal Europa + RTR Planeta + Telebom & Teledom + ABC News + Arta + EuroNews Albania + Fax News + First Channel + Kohavision + Ora + RTK 1 + RTSH 3 + RTV 21 Sat + Syri TV + T7 + Top Channel + TV 21 Macedonia + TV Dukagjini + TV Klan + BN Music + DM Sat + K CN 3 + Pink Extra + Pink Film + Pink Folk 1 + Pink Kids + Pink Koncert + Pink Music + Pink Plus + Pink Reality + Pink Serije + Pink World + RTS Svet + TV Duga + + Vijay TV + Thai TV Global Network + 360 + ATV Avrupa + ATV Türkiye + CNN Türk + EuroStar + Show Max + Show TV + TGRT EU + TRT Belgesel + TRT Çocuk + TRT Müzik + TRT Spor + TRT Türk + TV 8 International + CCTV 4 Europe + CGTN + Phoenix InfoNews Channel + +