mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
Update tvplus.com.tr guide.
Test: ```sh npm test -- tvplus.com.tr > test > run-script-os tvplus.com.tr > test:win32 > SET "TZ=Pacific/Nauru" && npx jest --runInBand tvplus.com.tr PASS sites/tvplus.com.tr/tvplus.com.tr.test.js √ can generate valid url (4 ms) √ can parse response (15 ms) √ can handle empty guide Test Suites: 1 passed, 1 total Tests: 3 passed, 3 total Snapshots: 0 total Time: 3.648 s, estimated 4 s Ran all test suites matching /tvplus.com.tr/i. ``` Grab: ```sh npm run grab -- --site=tvplus.com.tr > grab > npx tsx scripts/commands/epg/grab.ts --site=tvplus.com.tr starting... config: output: guide.xml maxConnections: 1 gzip: false site: tvplus.com.tr loading channels... found 10 channel(s) run #1: [1/20] tvplus.com.tr (tr) - 24TV.tr - Dec 15, 2024 (22 programs) [2/20] tvplus.com.tr (tr) - 24TV.tr - Dec 16, 2024 (19 programs) [3/20] tvplus.com.tr (tr) - BabyTV.uk - Dec 16, 2024 (48 programs) [4/20] tvplus.com.tr (tr) - BabyTV.uk - Dec 15, 2024 (48 programs) [5/20] tvplus.com.tr (tr) - ASpor.tr - Dec 16, 2024 (13 programs) [6/20] tvplus.com.tr (tr) - ASpor.tr - Dec 15, 2024 (14 programs) [7/20] tvplus.com.tr (tr) - APara.tr - Dec 16, 2024 (31 programs) [8/20] tvplus.com.tr (tr) - APara.tr - Dec 15, 2024 (25 programs) [9/20] tvplus.com.tr (tr) - AlJazeeraEnglish.qa - Dec 16, 2024 (32 programs) [10/20] tvplus.com.tr (tr) - AlJazeeraEnglish.qa - Dec 15, 2024 (32 programs) [11/20] tvplus.com.tr (tr) - AlJazeera.qa - Dec 16, 2024 (40 programs) [12/20] tvplus.com.tr (tr) - AlJazeera.qa - Dec 15, 2024 (41 programs) [13/20] tvplus.com.tr (tr) - AkitTV.tr - Dec 16, 2024 (15 programs) [14/20] tvplus.com.tr (tr) - AkitTV.tr - Dec 15, 2024 (12 programs) [15/20] tvplus.com.tr (tr) - AHaber.tr - Dec 16, 2024 (27 programs) [16/20] tvplus.com.tr (tr) - AHaber.tr - Dec 15, 2024 (19 programs) [17/20] tvplus.com.tr (tr) - A2TV.tr - Dec 16, 2024 (11 programs) [18/20] tvplus.com.tr (tr) - A2TV.tr - Dec 15, 2024 (11 programs) [19/20] tvplus.com.tr (tr) - 360.tr - Dec 16, 2024 (18 programs) [20/20] tvplus.com.tr (tr) - 360.tr - Dec 15, 2024 (18 programs) saving to "guide.xml"... done in 00h 02m 17s ``` Signed-off-by: Toha <tohenk@yahoo.com>
This commit is contained in:
parent
d50bc8ee2f
commit
f644583a65
2 changed files with 26 additions and 18 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
const cheerio = require('cheerio')
|
||||||
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
@ -16,11 +18,14 @@ module.exports = {
|
||||||
ttl: 24 * 60 * 60 * 1000 // 1 day
|
ttl: 24 * 60 * 60 * 1000 // 1 day
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
url({ channel }) {
|
async url({ channel }) {
|
||||||
const [buildId, slug, nr] = channel.site_id.split('/')
|
if (module.exports.buildId === undefined) {
|
||||||
const channelId = [slug, nr].join('--')
|
module.exports.buildId = await module.exports.fetchBuildId()
|
||||||
|
debug('Got build id', module.exports.buildId)
|
||||||
|
}
|
||||||
|
const channelId = channel.site_id.replace('/', '--')
|
||||||
return `https://tvplus.com.tr/_next/data/${
|
return `https://tvplus.com.tr/_next/data/${
|
||||||
buildId
|
module.exports.buildId
|
||||||
}/${
|
}/${
|
||||||
channel.lang
|
channel.lang
|
||||||
}/canli-tv/yayin-akisi/${
|
}/canli-tv/yayin-akisi/${
|
||||||
|
@ -57,8 +62,6 @@ module.exports = {
|
||||||
return programs
|
return programs
|
||||||
},
|
},
|
||||||
async channels() {
|
async channels() {
|
||||||
const cheerio = require('cheerio')
|
|
||||||
const axios = require('axios')
|
|
||||||
const channels = []
|
const channels = []
|
||||||
const data = await axios
|
const data = await axios
|
||||||
.get(channelsUrl)
|
.get(channelsUrl)
|
||||||
|
@ -66,19 +69,15 @@ module.exports = {
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
|
|
||||||
const $ = cheerio.load(data)
|
const $ = cheerio.load(data)
|
||||||
const nextData = JSON.parse($('#__NEXT_DATA__').text())
|
|
||||||
$('.channel-list-item a').toArray()
|
$('.channel-list-item a').toArray()
|
||||||
.forEach(el => {
|
.forEach(el => {
|
||||||
const a = $(el)
|
const a = $(el)
|
||||||
channels.push({
|
channels.push({
|
||||||
lang: 'tr',
|
lang: 'tr',
|
||||||
name: a.attr('title').replace(/Yayın Akışı/, '').trim(),
|
name: a.attr('title').replace(/Yayın Akışı/, '').trim(),
|
||||||
site_id: [
|
site_id: a.attr('href')
|
||||||
nextData.buildId,
|
|
||||||
...a.attr('href')
|
|
||||||
.replace(/\/canli\-tv\/yayin\-akisi\//, '')
|
.replace(/\/canli\-tv\/yayin\-akisi\//, '')
|
||||||
.split('--')
|
.replace('--', '/') // change -- to / as it used in xml comment
|
||||||
].join('/')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -98,6 +97,4 @@ module.exports = {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const { parser, url } = require('./tvplus.com.tr.config.js')
|
const { parser, url } = require('./tvplus.com.tr.config.js')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const axios = require('axios')
|
||||||
const dayjs = require('dayjs')
|
const dayjs = require('dayjs')
|
||||||
const utc = require('dayjs/plugin/utc')
|
const utc = require('dayjs/plugin/utc')
|
||||||
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
|
@ -8,15 +9,25 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
|
|
||||||
|
jest.mock('axios')
|
||||||
|
|
||||||
const date = dayjs.utc('2024-12-15', 'YYYY-MM-DD').startOf('d')
|
const date = dayjs.utc('2024-12-15', 'YYYY-MM-DD').startOf('d')
|
||||||
const channel = {
|
const channel = {
|
||||||
lang: 'tr',
|
lang: 'tr',
|
||||||
site_id: 'wOhzpck_jO2kKrDfRHmHs/nick-jr/4353',
|
site_id: 'nick-jr/4353',
|
||||||
xmltv_id: 'NickJr.tr'
|
xmltv_id: 'NickJr.tr'
|
||||||
}
|
}
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
axios.get.mockImplementation((url, opts) => {
|
||||||
expect(url({ channel })).toBe('https://tvplus.com.tr/_next/data/wOhzpck_jO2kKrDfRHmHs/tr/canli-tv/yayin-akisi/nick-jr--4353.json?title=nick-jr--4353')
|
if (url === 'https://tvplus.com.tr/canli-tv/yayin-akisi') {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: fs.readFileSync(path.join(__dirname, '__data__', 'build.html')).toString()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can generate valid url', async () => {
|
||||||
|
expect(await url({ channel })).toBe('https://tvplus.com.tr/_next/data/kUzvz_bbQJNaShlFUkrR3/tr/canli-tv/yayin-akisi/nick-jr--4353.json?title=nick-jr--4353')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue