From b1fcd25508b0a5279012bc64e346c639ffd86851 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 18 Nov 2023 20:04:32 +0300 Subject: [PATCH] Update dens.tv --- sites/dens.tv/dens.tv.channels.xml | 126 ++++++++++++++++------------- sites/dens.tv/dens.tv.config.js | 42 +++++++++- sites/dens.tv/dens.tv.test.js | 7 +- 3 files changed, 112 insertions(+), 63 deletions(-) diff --git a/sites/dens.tv/dens.tv.channels.xml b/sites/dens.tv/dens.tv.channels.xml index 78567442..4b39d675 100644 --- a/sites/dens.tv/dens.tv.channels.xml +++ b/sites/dens.tv/dens.tv.channels.xml @@ -1,58 +1,68 @@ - - - Al Jazeera English - Quran TV - Sunna TV - Aniplus HD - ANTV - BTV - CCM (Celestial Classic MV) - CCTV-4 - Celestial Movies HD - Cinema World - CNA - CGTN Documentary - DAAI TV - DensFood Channel - DensLife & Style - DensLearning & Knowledge - DensPlay - DensShowBiz - DW-TV - Elshinta TV - FIGHT SPORTS HD - France 24 - HITS HD - HITS MOVIES - HorizonSports - JAK TV - Kompas TV - KIX HD - K-PLUS HD - Magna Channel - Metro TV - Motorvision+ - My Cinema - My Cinema Asia - My Cinema Europe - My Family Channel - My Kidz HD - NaDoo Commerce - NaDooKorean - NET. - NHK WORLD-JAPAN - RTV - ROCK Action - ROCK Entertainment HD - RodjaTV - Thrill - TRT World - TV5MONDE ASIE - TV5MONDE Style HD - tvN HD - tvN Movies HD - tvOne - TVRI - TVRI Sport - WION - + + + Live Streaming 1 + RTV + TBN + FREEDOM + MotoRRacing TV + W-Sport + crema.tv + Dance TV + antv + Al Jazeera Arabic + Al Jazeera English + Quran TV + Sunna TV + ANIPLUS HD + BTV + CCM (Celestial Classic MV) + CCTV-4 + CGTN Documentary + CNA + Celestial Movies HD + CinemaWorld HD + DAAI TV + DW-TV + Deluxe Lounge HD + DensFood Channel + DensLearning & Knowledge + DensLife & Style + DensPlay + DensShowBiz + Elshinta TV + FIGHT SPORTS HD + France 24 + HITS HD + HITS MOVIES + HorizonSports + Jak tv + KIX HD + K-PLUS HD + Kompas TV + Magna Channel + Metro TV + Motorvision+ + My Cinema HD + My Cinema Asia + My Cinema Europe HD + My Family Channel + My Kidz HD + NET. + NHK WORLD-JAPAN + NaDoo Commerce + NaDooKorean + ROCK Action + ROCK Entertainment HD + RodjaTV + Stingray Classica + TRT World + TV5MONDE ASIE + TV5MONDE Style HD + TVRI + TVRI Sport + Thrill + WION + tvN HD + tvN Movies HD + tvOne + diff --git a/sites/dens.tv/dens.tv.config.js b/sites/dens.tv/dens.tv.config.js index 7c12880d..abf94251 100644 --- a/sites/dens.tv/dens.tv.config.js +++ b/sites/dens.tv/dens.tv.config.js @@ -11,23 +11,59 @@ module.exports = { site: 'dens.tv', days: 2, url: function ({ channel, date }) { - return `https://www.dens.tv/tvpage_octo/epgchannel2/${date.format('YYYY-MM-DD')}/${channel.site_id}` + return `https://www.dens.tv/tvpage_octo/epgchannel2/${date.format('YYYY-MM-DD')}/${ + channel.site_id + }` }, parser: function ({ content }) { // parsing const response = JSON.parse(content) const programs = [] - if(response.response !== undefined && response.response === 0 && response.data !== undefined && Array.isArray(response.data)){ + if ( + response.response !== undefined && + response.response === 0 && + response.data !== undefined && + Array.isArray(response.data) + ) { response.data.forEach(item => { programs.push({ title: item.title, start: dayjs.tz(item.starttime, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta'), - stop: dayjs.tz(item.endtime, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta'), + stop: dayjs.tz(item.endtime, 'YYYY-MM-DD HH:mm:ss', 'Asia/Jakarta') }) }) } return programs + }, + async channels() { + const axios = require('axios') + + const categories = { + local: 1, + premium: 2, + international: 3 + } + + let channels = [] + for (const id_category of Object.values(categories)) { + const data = await axios + .get(`https://www.dens.tv/api/dens3/tv/TvChannels/listByCategory`, { + params: { id_category } + }) + .then(r => r.data) + .catch(console.log) + + data.data.contents.forEach(item => { + channels.push({ + lang: 'id', + site_id: item.meta.id, + name: item.meta.title + }) + }) + } + + return channels } } diff --git a/sites/dens.tv/dens.tv.test.js b/sites/dens.tv/dens.tv.test.js index 8e80c392..c2f80910 100644 --- a/sites/dens.tv/dens.tv.test.js +++ b/sites/dens.tv/dens.tv.test.js @@ -1,3 +1,6 @@ +// npm run channels:parse -- --config=./sites/dens.tv/dens.tv.config.js --output=./sites/dens.tv/dens.tv.channels.xml +// npm run grab -- --site=dens.tv + const { url, parser } = require('./dens.tv.config.js') const fs = require('fs') const path = require('path') @@ -25,13 +28,13 @@ it('can parse response', () => { expect(results[0]).toMatchObject({ start: '2023-11-09T17:00:00.000Z', - stop : '2023-11-09T17:05:00.000Z', + stop: '2023-11-09T17:05:00.000Z', title: 'Follow Up' }) expect(results[12]).toMatchObject({ start: '2023-11-10T04:05:00.000Z', - stop : '2023-11-10T06:05:00.000Z', + stop: '2023-11-10T06:05:00.000Z', title: 'Metro Siang' }) })