diff --git a/sites/digiturk.com.tr/__data__/content.html b/sites/digiturk.com.tr/__data__/content.html new file mode 100644 index 00000000..e65dc9c3 --- /dev/null +++ b/sites/digiturk.com.tr/__data__/content.html @@ -0,0 +1,570 @@ +
+
+
+
+
+
+
+ Bugün + 12.01.2025 +
+
+
+
+
+ Yarın + 13.01.2025 +
+
+
+
+
+ Salı + 14.01.2025 +
+
+
+
+
+ Çarşamba + 15.01.2025 +
+
+
+
+
+ Perşembe + 16.01.2025 +
+
+
+
+
+ Cuma + 17.01.2025 +
+
+
+
+
+ Cumartesi + 18.01.2025 +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/sites/digiturk.com.tr/__data__/content.json b/sites/digiturk.com.tr/__data__/content.json deleted file mode 100644 index ad4ebfff..00000000 --- a/sites/digiturk.com.tr/__data__/content.json +++ /dev/null @@ -1 +0,0 @@ -{"BChannels":[{"CID":453,"CName":"beIN MOVIES ACTION","CNo":14,"CTheme":1,"CPrograms":[{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"PARÇALANMIŞ","PPart":"","POName":"SPLIT (2016)","PUrlTitle":null,"PID":null,"BID":1657975910,"PDuration":6737,"PStartTime":"\/Date(1674074400000+0300)\/","PEndTime":"\/Date(1674081120000+0300)\/","PGenre":"E9","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976150,"PDuration":175,"PStartTime":"\/Date(1674081120000+0300)\/","PEndTime":"\/Date(1674081300000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"UYARI","PPart":"","POName":"CAVEAT (2020)","PUrlTitle":null,"PID":null,"BID":1657975911,"PDuration":5250,"PStartTime":"\/Date(1674081300000+0300)\/","PEndTime":"\/Date(1674086580000+0300)\/","PGenre":"E9","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976151,"PDuration":131,"PStartTime":"\/Date(1674086580000+0300)\/","PEndTime":"\/Date(1674086700000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"İKİ YÜZLÜ","PPart":"","POName":"IMPOSTOR (2001)","PUrlTitle":null,"PID":null,"BID":1657975912,"PDuration":5312,"PStartTime":"\/Date(1674086700000+0300)\/","PEndTime":"\/Date(1674092040000+0300)\/","PGenre":"E3","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976152,"PDuration":113,"PStartTime":"\/Date(1674092040000+0300)\/","PEndTime":"\/Date(1674092100000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"TUROK: TAŞIN OĞLU","PPart":"","POName":"TUROK: SON OF STONE","PUrlTitle":null,"PID":null,"BID":1657975922,"PDuration":4224,"PStartTime":"\/Date(1674092100000+0300)\/","PEndTime":"\/Date(1674096360000+0300)\/","PGenre":"E2","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976154,"PDuration":505,"PStartTime":"\/Date(1674096360000+0300)\/","PEndTime":"\/Date(1674096840000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"KAYIP DÜNYA: JURASSIC PARK","PPart":"","POName":"THE LOST WORLD, THE: JURASSIC","PUrlTitle":null,"PID":null,"BID":1657975913,"PDuration":7393,"PStartTime":"\/Date(1674096840000+0300)\/","PEndTime":"\/Date(1674104220000+0300)\/","PGenre":"E1","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976155,"PDuration":387,"PStartTime":"\/Date(1674104220000+0300)\/","PEndTime":"\/Date(1674104640000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"HIZLI VE ÖFKELİ: TOKYO YARIŞI","PPart":"","POName":"THE FAST AND THE FURIOUS: TOKYO DRIFT, THE (","PUrlTitle":null,"PID":null,"BID":1657975914,"PDuration":5857,"PStartTime":"\/Date(1674104640000+0300)\/","PEndTime":"\/Date(1674110520000+0300)\/","PGenre":"E1","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976156,"PDuration":749,"PStartTime":"\/Date(1674110520000+0300)\/","PEndTime":"\/Date(1674111240000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"ÖZNE","PPart":"","POName":"THE SUBJECT, THE (","PUrlTitle":null,"PID":null,"BID":1657975915,"PDuration":6815,"PStartTime":"\/Date(1674111240000+0300)\/","PEndTime":"\/Date(1674118080000+0300)\/","PGenre":"E5","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976157,"PDuration":753,"PStartTime":"\/Date(1674118080000+0300)\/","PEndTime":"\/Date(1674118800000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"Bilinmeze Doğru Star Trek","PPart":"","POName":"Star Trek Into Darkness","PUrlTitle":"bilinmeze-dogru-star-trek","PID":16519,"BID":1657975916,"PDuration":7304,"PStartTime":"\/Date(1674118800000+0300)\/","PEndTime":"\/Date(1674126120000+0300)\/","PGenre":"8","pSeasonName":null,"pEpisodeName":null,"PFileName":"star-tv.jpg"},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976158,"PDuration":875,"PStartTime":"\/Date(1674126120000+0300)\/","PEndTime":"\/Date(1674126960000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"MÜTTEFİK","PPart":"","POName":"ALLIED (2016)","PUrlTitle":null,"PID":null,"BID":1657975917,"PDuration":7016,"PStartTime":"\/Date(1674126960000+0300)\/","PEndTime":"\/Date(1674133980000+0300)\/","PGenre":"E1","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976159,"PDuration":804,"PStartTime":"\/Date(1674133980000+0300)\/","PEndTime":"\/Date(1674134820000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"BİLİM KURGU BÖLÜM 1: SON...","PPart":"","POName":"SFV1 - Science Fiction Volume One: The Osiris Child","PUrlTitle":null,"PID":null,"BID":1657975918,"PDuration":5205,"PStartTime":"\/Date(1674134820000+0300)\/","PEndTime":"\/Date(1674140040000+0300)\/","PGenre":"E4","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976160,"PDuration":757,"PStartTime":"\/Date(1674140040000+0300)\/","PEndTime":"\/Date(1674140760000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"GECE UÇUŞU","PPart":"","POName":"RED EYE (2005)","PUrlTitle":null,"PID":null,"BID":1657975919,"PDuration":4658,"PStartTime":"\/Date(1674140760000+0300)\/","PEndTime":"\/Date(1674145440000+0300)\/","PGenre":"E9","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976161,"PDuration":939,"PStartTime":"\/Date(1674145440000+0300)\/","PEndTime":"\/Date(1674146340000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"LABİRENT","PPart":"","POName":"MAZE (2017)","PUrlTitle":null,"PID":null,"BID":1657975920,"PDuration":5317,"PStartTime":"\/Date(1674146340000+0300)\/","PEndTime":"\/Date(1674151680000+0300)\/","PGenre":"E5","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976153,"PDuration":1331,"PStartTime":"\/Date(1674151680000+0300)\/","PEndTime":"\/Date(1674153000000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"ÖLÜM GÜNÜN KUTLU OLSUN","PPart":"","POName":"HAPPY DEATH DAY (2017)","PUrlTitle":null,"PID":null,"BID":1657975921,"PDuration":5528,"PStartTime":"\/Date(1674153000000+0300)\/","PEndTime":"\/Date(1674158520000+0300)\/","PGenre":"E9","pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"AZ SONRA...","PPart":"","POName":"","PUrlTitle":null,"PID":null,"BID":1657976162,"PDuration":848,"PStartTime":"\/Date(1674158520000+0300)\/","PEndTime":"\/Date(1674159360000+0300)\/","PGenre":null,"pSeasonName":null,"pEpisodeName":null,"PFileName":""},{"SDesc":null,"PChannelUrlTitle":"bein-movies-action","PTitle":"beIN MOVIES ACTION","PName":"DRACULA: BAŞLANGIÇ","PPart":"","POName":"DRACULA UNTOLD","PUrlTitle":null,"PID":null,"BID":1657975923,"PDuration":5301,"PStartTime":"\/Date(1674159360000+0300)\/","PEndTime":"\/Date(1674164700000+0300)\/","PGenre":"E1","pSeasonName":null,"pEpisodeName":null,"PFileName":""}],"PFilePath":"/channel/453/Image/bein_movies_action_60x36_2022.png"}],"ServerTime":"\/Date(1674079200000+0300)\/","ServerNow":"\/Date(1674068987399+0300)\/"} \ No newline at end of file diff --git a/sites/digiturk.com.tr/digiturk.com.tr.channels.xml b/sites/digiturk.com.tr/digiturk.com.tr.channels.xml index a0ebb2cd..227b12ea 100644 --- a/sites/digiturk.com.tr/digiturk.com.tr.channels.xml +++ b/sites/digiturk.com.tr/digiturk.com.tr.channels.xml @@ -1,142 +1,111 @@ - AL JAZEERA ENGLISH HD - Baby TV - BBC World News HD - BLOOMBERG HD - CGTN HD - CGTN DOCUMENTARY HD - CNN INTERNATIONAL - EURONEWS - Fashion TV HD - France 24 HD - TV5 Monde Europe - beIN - MTV Live HD - TARIH TV HD - Taraftar HD - Taraftar 2 HD - KANAL 24 HD - ALEM FM - KAFA RADYO - Kral Pop Radyo - Slow Türk - Show Radyo - Kral FM - Radyo Viva - Baba Radyo - Joy FM - 5+1 Concerts - SÖZCÜ TV HD - CADDE TV - beIN SERIES 2 - 360 HD - A2 HD - A Haber HD - Akıllı TV - Al Quran Al Kareem TV HD - Al Sunnah Al Nabawiyah TV HD - A News HD - A Para HD - A Spor HD - ATV - BBC EARTH HD - BBC First - beIN BOX OFFICE 1 - beIN GURME - beIN HOME & ENTERTAINMENT - beIN İZ - beIN İZ HD - beIN MOVIES PREMIERE 2 - beIN MOVIES TURK - beIN SERIES 1 - beIN MOVIES PREMIERE - beIN MOVIES STARS - beIN SPORTS 1 - beIN SPORTS 2 - beIN SPORTS 3 - beIN SPORTS 4 - beIN SPORTS 5 - beIN SPORTS HABER - beIN SPORTS MAX HD 1 - beIN SPORTS MAX HD 2 - BENGÜTÜRK TV - BEYAZ TV HD - Bloomberg TV - Cartoonito - Cartoon Network - CBEEBIES HD - CNN TÜRK HD - Da Vinci - Digiturk 4K - Discovery Channel HD - Discovery Science HD - Disney Junior - Diyanet TV HD - DMAX HD - EKOTÜRK TV HD - Eurosport 1 HD - Eurosport 2 HD - FB TV HD - Flash Haber TV - FOX HD - GS TV HD - HABER GLOBAL HD - HABERTURK HD - Halk TV - KANAL 7 HD - Kanal D HD - KRT TV HD - LIDER HABER TV HD - MCM Top HD - Mezzo HD - MinikaGO - MTV 00s - MTV Hits - MTV Live HD - Nat Geo Wild HD - National Geographic HD - Nickelodeon - Nickelodeon HD - Nickelodeon HD - Nick Jr. - NTV HD - Number1 TV - Power TV - RAI UNO - Show TV HD - Star TV HD - TELE 1 HD - Teve2 HD - TGRT Haber HD - TJK TV - TLC HD - TRT 1 HD - TRT1 HD - TRT 2 HD - TRT 3 - TRT Spor - TRT Arabi - TRT AVAZ - TRT Belgesel HD - TRT Çocuk - TRT EBATV İLKOKUL HD - TRT EBATV LİSE HD - TRT EBATV ORTAOKUL HD - TRT Haber HD - TRT Kurdi - TRT Müzik - TRT SPOR HD - TRT SPOR YILDIZ - TRT TURK - TRT World HD - TRT World HD - TURKHABER TV - TV 100 HD - TV8 HD - TV 8,5 - TVNET HD - Ülke TV HD - ULUSAL TV - VAV TV - Yaban TV + EKOL TV + 24 TV + 360 + A2 + AHABER + AL JAZEERA CHANNEL + A NEWS + A PARA + A SPOR + ATV + BABY TV + BBC EARTH + BBC FIRST + BBC WORLD NEWS + beIN GURME + beIN H&E + beIN İZ + beIN MOVIES PREMIERE + beIN MOVIES STARS + beIN MOVIES TURK + beIN SERIES 1 + beIN SERIES 2 + beIN SPORTS 1 + beIN SPORTS 2 + beIN SPORTS 3 + beIN SPORTS 4 + beIN SPORTS 5 + beIN SPORTS HABER + beIN SPORTS MAX 1 + beIN SPORTS MAX 2 + BENGÜTÜRK + BEYAZ TV + BLOOMBERG HT + BLOOMBERG + CARTOON NETWORK + CBeebies + CGTN + CGTN DOCUMENTARY + CNBC-e + CNN INTERNATIONAL + CNN TURK + Da Vinci + DIGI + DISCOVERY CHANNEL + DISNEY JUNIOR + DİYANET TV + EKOTURK + EURONEWS + EUROSPORT 1 + EUROSPORT 2 + FASHION TV + FB TV + FLASH HABER + FOX + FRANCE 24 + HABERGLOBAL + HABERTURK + TÜRKHABER TV + HALK TV + KANAL 7 + KANAL D + KRT TV + LİDER HABER TV + MCM TOP + MEZZO + MİNİKAGO + MTV 00s + MTV HITS + MTV LIVE + NATIONAL GEO. + NAT.GEO.WILD + NICKELODEON SD + NICKELODEON HD + NICK JR + NTV + RAI1 + SHOW TV + SÖZCÜ TV + STAR TV + TARİH TV + TELE 1 + TEVE2 + TGRT HABER + TJK TV + TRT 1 + TRT 2 + TRT 3 / TRT SPOR + TRT ARABI + TRT AVAZ + TRT BELGESEL + TRT ÇOCUK + TRT EBA TV ORTAOKUL + TRT HABER + TRT KURDI + TRT MÜZİK + TRT SPOR + TRT SPOR YILDIZ + TRT TURK + TRT WORLD + TV5 MONDE EUROPE + TV8 + TV8,5 + tv100 + TVNET + ÜLKE TV + ULUSAL TV + VAV TV + YABAN TV diff --git a/sites/digiturk.com.tr/digiturk.com.tr.config.js b/sites/digiturk.com.tr/digiturk.com.tr.config.js index 4dba0999..23d1b55e 100644 --- a/sites/digiturk.com.tr/digiturk.com.tr.config.js +++ b/sites/digiturk.com.tr/digiturk.com.tr.config.js @@ -1,107 +1,86 @@ -const _ = require('lodash') +const cheerio = require('cheerio') const dayjs = require('dayjs') const utc = require('dayjs/plugin/utc') const timezone = require('dayjs/plugin/timezone') +const customParseFormat = require('dayjs/plugin/customParseFormat') dayjs.extend(utc) dayjs.extend(timezone) -// category list is not complete -// const categories = { -// '00': 'Diğer', -// E0: 'Romantik Komedi', -// E1: 'Aksiyon', -// E4: 'Macera', -// E5: 'Dram', -// E6: 'Fantastik', -// E7: 'Komedi', -// E8: 'Korku', -// EB: 'Polisiye', -// EF: 'Western', -// FA: 'Macera', -// FB: 'Yarışma', -// FC: 'Eğlence', -// F0: 'Reality-Show', -// F2: 'Haberler', -// F4: 'Belgesel', -// F6: 'Eğitim', -// F7: 'Sanat ve Kültür', -// F9: 'Life Style' -// } +dayjs.extend(customParseFormat) + +const tz = 'Europe/Istanbul' module.exports = { site: 'digiturk.com.tr', days: 2, - delay: 1000, // NOTE: under heavy load the server starts blocking requests - url: function ({ date, channel }) { - return `https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=${ - channel.site_id - }&date=${date.format('DD.MM.YYYY')}&tomorrow=false&primetime=false` + url({ date }) { + return `https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=${ + encodeURIComponent(date.format('MM/DD/YYYY')) + }+00%3A00%3A00` }, request: { - method: 'GET', - headers: { - Referer: 'https://www.digiturk.com.tr/' + cache: { + ttl: 24 * 60 * 60 * 1000 // 1 day } }, - parser: function ({ content }) { - let programs = [] - const items = parseItems(content) - items.forEach(item => { - programs.push({ - title: item.PName, - // description: item.LongDescription, - // category: parseCategory(item), - start: parseTime(item.PStartTime), - stop: parseTime(item.PEndTime) - }) - }) - - programs = _.sortBy(programs, 'start') + parser({ content, channel, date }) { + const programs = [] + if (content) { + const $ = cheerio.load(content) + $('.channelDetail').toArray() + .forEach(item => { + const $item = $(item) + const title = $item.find('.tvGuideResult-box-wholeDates-title') + if (title.length) { + const channelId = title.attr('onclick') + if (channelId) { + const site_id = channelId.match(/\s(\d+)\)/)[1] + if (channel.site_id === site_id) { + const startTime = $item.find('.tvGuideResult-box-wholeDates-time-hour').text().trim() + const duration = $item.find('.tvGuideResult-box-wholeDates-time-totalMinute') + .text().trim().match(/\d+/)[0] + const start = dayjs.tz(`${date.format('YYYY-MM-DD')} ${startTime}`, 'YYYY-MM-DD HH:mm', tz) + const stop = start.add(parseInt(duration), 'm') + programs.push({ + title: title.text().trim(), + start, + stop + }) + } + } + } + }) + } return programs }, async channels() { + const channels = {} const axios = require('axios') - const cheerio = require('cheerio') - const data = await axios - .get('https://www.digiturk.com.tr/', { - headers: { - 'User-Agent': - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36' + .get(this.url({ date: dayjs() })) + .then(r => r.data) + .catch(console.error) + + const $ = cheerio.load(data) + $('.channelContent').toArray() + .forEach(el => { + const item = $(el) + const channelId = item.find('.channelDetail .tvGuideResult-box-wholeDates-title') + .first() + .attr('onclick') + if (channelId) { + const site_id = channelId.match(/\s(\d+)\)/)[1] + if (channels[site_id] === undefined) { + channels[site_id] = { + lang: 'tr', + site_id, + name: item.find('#channelID').val() + } + } } }) - .then(r => r.data) - .catch(console.log) - let channels = [] - const $ = cheerio.load(data) - $('#chosen-select-channel > option').each((i, el) => { - const site_id = $(el).attr('value') - const name = $(el).text().trim() - - channels.push({ - lang: 'tr', - site_id, - name - }) - }) - - return channels + return Object.values(channels) } } - -function parseTime(time) { - let timestamp = parseInt(time.replace('/Date(', '').replace('+0300)/', '')) - return dayjs(timestamp) -} - -// function parseCategory(item) { -// return (item.PGenre) ? categories[item.PGenre] : null -// } - -function parseItems(content) { - if (!content) return [] - const data = JSON.parse(content) - return data && data.BChannels && data.BChannels[0].CPrograms ? data.BChannels[0].CPrograms : [] -} diff --git a/sites/digiturk.com.tr/digiturk.com.tr.test.js b/sites/digiturk.com.tr/digiturk.com.tr.test.js index 92e7b806..9d0f0b22 100644 --- a/sites/digiturk.com.tr/digiturk.com.tr.test.js +++ b/sites/digiturk.com.tr/digiturk.com.tr.test.js @@ -4,44 +4,45 @@ 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('2023-01-19', 'YYYY-MM-DD').startOf('d') +const date = dayjs.utc('2025-01-12', 'YYYY-MM-DD').startOf('d') const channel = { - site_id: '14', - xmltv_id: 'beINMovies2Action.qa' + site_id: '351', + xmltv_id: 'Nickelodeon.tr' } it('can generate valid url', () => { const result = url({ date, channel }) expect(result).toBe( - 'https://www.digiturk.com.tr/_Ajax/getBroadcast.aspx?channelNo=14&date=19.01.2023&tomorrow=false&primetime=false' + 'https://www.digiturk.com.tr/Ajax/GetTvGuideFromDigiturk?Day=01%2F12%2F2025+00%3A00%3A00' ) }) it('can parse response', () => { - const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json')) - const results = parser({ content }).map(p => { + const content = fs.readFileSync(path.join(__dirname, '__data__', 'content.html')) + const results = parser({ content, channel, date }).map(p => { p.start = p.start.toJSON() p.stop = p.stop.toJSON() return p }) + expect(results.length).toBe(57) expect(results[0]).toMatchObject({ - start: '2023-01-18T20:40:00.000Z', - stop: '2023-01-18T22:32:00.000Z', - title: 'PARÇALANMIŞ' + start: '2025-01-11T21:00:00.000Z', + stop: '2025-01-11T21:25:00.000Z', + title: 'Sünger Bob Kare Pantolon' }) - - expect(results[10]).toMatchObject({ - start: '2023-01-19T05:04:00.000Z', - stop: '2023-01-19T06:42:00.000Z', - title: 'HIZLI VE ÖFKELİ: TOKYO YARIŞI' + expect(results[56]).toMatchObject({ + start: '2025-01-12T17:40:00.000Z', + stop: '2025-01-12T18:00:00.000Z', + title: 'Casagrande Ailesi' }) }) it('can handle empty guide', () => { - const result = parser({ content: '' }) + const result = parser({ content: '', channel, date }) expect(result).toMatchObject([]) })