From 056ecfc60dcf056cbaa3481d17441f041b1ffa40 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 18:52:52 +0300 Subject: [PATCH 1/3] Create mts.rs.test.js --- sites/mts.rs/mts.rs.test.js | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sites/mts.rs/mts.rs.test.js diff --git a/sites/mts.rs/mts.rs.test.js b/sites/mts.rs/mts.rs.test.js new file mode 100644 index 00000000..31133b71 --- /dev/null +++ b/sites/mts.rs/mts.rs.test.js @@ -0,0 +1,54 @@ +// npx epg-grabber --config=sites/mts.rs/mts.rs.config.js --channels=sites/mts.rs/mts.rs_rs.channels.xml --output=.gh-pages/guides/rs/mts.rs.epg.xml --days=2 + +const { parser, url, logo, request } = require('./mts.rs.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('2021-11-07', 'YYYY-MM-DD').startOf('d') +const channel = { + site_id: '101#597', + xmltv_id: 'RTS1.rs' +} +const content = `{"page":0,"total_pages":1,"date":"2021-11-07","channels":[{"id":"597","name":"RTS 1","description":null,"link":null,"image":"https:\/\/mts.rs\/oec\/images\/tv_channels\/904ddd8cd6720a4a1c23eae513b5b957.jpg","position":"101","positions":"101","items":[{"id_channel":"597","title":"Zaboravljeni zlo\u010din","description":"Novinarka-fotoreporter, D\u017ein, istra\u017euje okrutno i senzacionalno, nere\u0161eno ubistvo sekirom iz davne 1873. godine. Ubistvo koje koincidira sa nedavnim identi\u010dnim brutalnim dvostrukim ubistvom. Zaplet se odvija izme\u0111u pri\u010de o\u010devica iz toga doba - pri\u010de iz novinske arhive i D\u017einine privatne borbe sa ljubomorom i sumnjom koje prate njen brak.","start":"00:00:00","duration":"103.00","full_start":"2021-11-06 23:44:00","full_end":"2021-11-07 01:43:00","image":"https:\/\/mts.rs\/oec\/images\/epg\/2_abb81cc24d8ce957eece50f991a31e59780e4e53_E7D8ECDE568E84E3C86CCDBDB647355E.jpg","category":"Bioskopski film","subcategory":""}]}]}` + +it('can generate valid url', () => { + const result = url({ date, channel }) + expect(result).toBe('https://mts.rs/oec/epg/program?date=2021-11-07&position=101') +}) + +it('can generate valid request headers', () => { + expect(request.headers).toMatchObject({ + 'X-Requested-With': 'XMLHttpRequest' + }) +}) + +it('can get logo url', () => { + const result = logo({ content, channel }) + expect(result).toBe('https://mts.rs/oec/images/tv_channels/904ddd8cd6720a4a1c23eae513b5b957.jpg') +}) + +it('can parse response', () => { + const result = parser({ date, channel, content }) + expect(result).toMatchObject([ + { + start: '2021-11-06T22:44:00.000Z', + stop: '2021-11-07T00:43:00.000Z', + title: 'Zaboravljeni zlo\u010din', + category: 'Bioskopski film', + icon: 'https://mts.rs/oec/images/epg/2_abb81cc24d8ce957eece50f991a31e59780e4e53_E7D8ECDE568E84E3C86CCDBDB647355E.jpg', + description: `Novinarka-fotoreporter, D\u017ein, istra\u017euje okrutno i senzacionalno, nere\u0161eno ubistvo sekirom iz davne 1873. godine. Ubistvo koje koincidira sa nedavnim identi\u010dnim brutalnim dvostrukim ubistvom. Zaplet se odvija izme\u0111u pri\u010de o\u010devica iz toga doba - pri\u010de iz novinske arhive i D\u017einine privatne borbe sa ljubomorom i sumnjom koje prate njen brak.` + } + ]) +}) + +it('can handle empty guide', () => { + const result = parser({ + date, + channel, + content: `{"message":"Nema rezultata."}` + }) + expect(result).toMatchObject([]) +}) From 561f905eb4d391b227645a654c7d2f99aac5124d Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 18:52:56 +0300 Subject: [PATCH 2/3] Create mts.rs.config.js --- sites/mts.rs/mts.rs.config.js | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 sites/mts.rs/mts.rs.config.js diff --git a/sites/mts.rs/mts.rs.config.js b/sites/mts.rs/mts.rs.config.js new file mode 100644 index 00000000..a4eb30e8 --- /dev/null +++ b/sites/mts.rs/mts.rs.config.js @@ -0,0 +1,65 @@ +const dayjs = require('dayjs') +const utc = require('dayjs/plugin/utc') +const timezone = require('dayjs/plugin/timezone') + +dayjs.extend(utc) +dayjs.extend(timezone) + +module.exports = { + site: 'mts.rs', + url({ date, channel }) { + const [position] = channel.site_id.split('#') + + return `https://mts.rs/oec/epg/program?date=${date.format('YYYY-MM-DD')}&position=${position}` + }, + request: { + timeout: 10000, + headers: { + 'X-Requested-With': 'XMLHttpRequest' + } + }, + logo({ content, channel }) { + const data = parseContent(content, channel) + + return data ? data.image : null + }, + parser: function ({ content, channel, date }) { + let programs = [] + const data = parseContent(content, channel) + const items = parseItems(data) + items.forEach(item => { + const start = parseStart(item) + const stop = parseStop(item) + programs.push({ + title: item.title, + category: item.category, + description: item.description, + icon: item.image, + start: start.toJSON(), + stop: stop.toJSON() + }) + }) + + return programs + } +} + +function parseContent(content, channel) { + const [_, site_id] = channel.site_id.split('#') + const data = JSON.parse(content) + if (!data || !data.channels || !data.channels.length) return null + + return data.channels.find(c => c.id === site_id) || null +} + +function parseStart(item, date) { + return dayjs.tz(item.full_start, 'Europe/Belgrade') +} + +function parseStop(item, date) { + return dayjs.tz(item.full_end, 'Europe/Belgrade') +} + +function parseItems(data) { + return data && Array.isArray(data.items) ? data.items : [] +} From 7c2fb73719c6b52bd118febc4a87977742ce2a2c Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sun, 7 Nov 2021 18:52:59 +0300 Subject: [PATCH 3/3] Create mts.rs_rs.channels.xml --- sites/mts.rs/mts.rs_rs.channels.xml | 364 ++++++++++++++++++++++++++++ 1 file changed, 364 insertions(+) create mode 100644 sites/mts.rs/mts.rs_rs.channels.xml diff --git a/sites/mts.rs/mts.rs_rs.channels.xml b/sites/mts.rs/mts.rs_rs.channels.xml new file mode 100644 index 00000000..45363cfa --- /dev/null +++ b/sites/mts.rs/mts.rs_rs.channels.xml @@ -0,0 +1,364 @@ + + + + 24 Kitchen Srbija + 101 TV + 360 Tune Box + A1 TV Montenegro + Agro TV + Aljazeera Balkans + Alternativna TV + AMC Balkan + Animal Planet Europe + Arena Esport + Arena Fight + Arena Premium 1 + Arena Premium 2 + Arena Premium 3 + Arena Sport 1 + Arena Sport 1x2 + Arena Sport 2 + Arena Sport 3 + Arena Sport 4 + Arena Sport 5 + Arena Sport 6 Hrvatska + Arena Sport 7 Hrvatska + Arena Sport 8 Hrvatska + AXN Adria + AXN Spin Adria + B92 + Baby TV Europe + Balkan Trip + Balkan TV + BBC Earth Romania + Bloomberg TV Europe + BN + BN Music + Boomerang Central & Eastern Europe + Bravo Music + B TV + Cafe & Club + Cartoon Network Central & Eastern Europe + CBS Reality Europe + CCTV 4 Europe + CGTN + Cinemax 2 Central Europe + Cinemax Central Europe + CineStar TV 1 Srbija + CineStar TV Action Srbija + CineStar TV Comedy + CineStar TV Fantasy + Club MTV + CNBC Europe + CNN International Europe + Cool TV + Crime + Investigation UK + Da Vinci + Decija TV + Dexy TV + Discovery Channel Srbija + Discovery Science + Disney Channel Polska + Diva Adria + Dizi + DM Sat + DocuBox HD + Dox TV + DTX East Europe + Duck TV SD + Duna TV + Dunav TV + Duna World + eduTV + E! Europe + Epic Drama + EuroNews English + EuroNews Serbia + Eurosport 1 + Eurosport 2 + Extreme Sports Channel + Face TV + FashionBox HD + Fashion TV Europe + Fast & FunBox HD + Federalna TV + FightBox HD + Fight Network + Film 4 + FilmBox Arthouse Worldwide + FilmBox Extra HD Adria + FilmBox Premium Adria + FilmBox Stars Adria + Film Klub + Film Klub Extra + Film + Hungary + Food Network EMEA + Fox Crime Srbija + Fox Life Srbija + Fox Movies Srbija + Fox News Channel + Fox Srbija + France 24 English + Gametoon + Gradska M TV + H2 Polska + Ha Ha + Happy + Happy Reality 1 + Happy Reality 2 + Hayat + Hayat Folk + Hayat Music + Hayatovci + Hayat Plus + HBO 2 Central Europe + HBO 3 Central Europe + HBO Adria + HGTV Pan Regional + History Europe + Humana TV Plus + Hype TV + Investigation Discovery Europe + Jeka + JimJam Europe + K1 + K3 + K23 TV + KA TV + Kazbuka + K CN 1 + K CN 2 + K CN 3 + K CN Istok + K CN K + K CN Raška + K CN Zapad + Kitchen TV + Klasik TV + Kurir TV + Kuvo TV + LFC TV + Lol + M1 + M2 + M4 Sport + M5 + Minimax Romania + Mostnet + Motorvision TV + MTV 00s + MTV 80s + MTV 90s + MTV Europe + MTV Hits Europe + Muzsika TV + Muzzik + Nat Geo Wild Europe + National Geographic Srbija + NBA TV + Nickelodeon Europe + Nick Jr Central & Eastern Europe + Nicktoons Adria + Novosadska TV + NTV + OBN + OKK + Pannon TV + Pink Action + Pink Classic + Pink Comedy + Pink Crime & Mystery + Pink Extra + Pink Family + Pink Fashion + Pink Film + Pink Folk 1 + Pink Folk 2 + Pink Hits + Pink Hits 2 + Pink Horror + Pink Kids + Pink Koncert + Pink Kuvar + Pink M + Pink Movies + Pink Music + Pink Music 2 + Pink n Roll + Pink Pedia + Pink Plus + Pink Premium + Pink Reality + Pink Romance + Pink Sci-Fi & Fantasy + Pink Serije + Pink Show + Pink Soap + Pink Srbija + Pink Style + Pink Super Kids + Pink Thriller + Pink Western + Pink World + Pink Zabava + Prva Files + Prva Kick + Prva Life + Prva Max + Prva Srpska TV + Prva TV Crna Gora + Prva World + Red TV + Rock & Roll + Rossiya 24 + RT Documentary + RTL Croatia World + RTL Deutschland + RTL Gold + RTL Hrvatska + RTL II + RTL Klub + RTL Kockica + RTL + + RT News + RTP + RTR Planeta + RTRS TV + RTS 1 + RTS 2 + RTS 3 + RTS Drama + RTS Klasika + RTS Kolo + RTS Muzika + RTS Nauka + RTS Poletarac + RTS Trezor + RTS Zivot + RTV 1 + RTV 2 + RTV Bap + RTV Bosphorus + RTV Melos + RTV SP + RTV Sreće + RTV Subotica + RTV Šumadija + Sandžačka TV Mreža + Sandžak TV + SAT TV + Scifi Srbija + Sorozat + + SOS Kanal Plus + Sremska TV + Story 4 + Studio B + Super D+ + Super Sat + Superstar + Superstar 2 + Superstar TV + Super TV 2 + T1 + Tanjug TV + Telebet + Televizija Fokus + Televizija Plus + TLC Balkan + TMS Televizija Telemark + Toxic Folk + Toxic Rap + Toxic TV + Travel Channel Europe + Turizam TV + TV 2 + TV 4S + TV5Monde Europe + TV 5 Uzice + TV 1000 Balkan + TV Apatin + TV AS + TV Bačka + TV Banat + TV Bečej + TV Belle Amie + TV Bor + TV Bujanovac + TV Caribrod + TVCG Sat + TV Cink + TV City + TV Delta + TV Diskos + TV DR + TV Duga + + TV Fruška Gora + TV Galaksija 32 + TV Gem + TV GM Plus + TV Hit Plus Batočina + TV Hram + TV Info 24 Plus + TV Istok + TV Jasenica + TV K-1 + TV K9 + TV Kanal 25 + TV Kanal M + TV Kikinda + TV Kladovo + TV Koreni + TV Kragujevac + TV Kraljevo + TV Kruševac + TV Lav + TV Lav Plus + TV Leskovac + TV Lotel Plus + TV Mag + TV Marš + TV Mix + TV Most + TV Nova + TV Novi Bečej + TV Novi Pazar + TV Palma Plus + TV Pančevo + TV Partizan + TV P Canal + TV Petrovec + TV Pirot + TV Podrinje + TV Požega + TV Priboj + TV Q + TV Rača + TV Ras + TV Ritam + TV Šabac + TV Santos + TV Skay + TV Sunce + TV Trans + TV Trstenik + TV Vranje + TV Vrnjačka Banja + TV Vujic + TV YU Eco + TV Zlatar + TV Zona Plus + VA Plus + Vesti + Viasat Explore East + Viasat History + Viasat Nature East + Vranjska Plus + World Wild Muzzik + Zadruga 1 + Zadruga 2 + Zadruga 3 + Zadruga 4 + Zdravlje TV + Zvezda TV + + \ No newline at end of file