Merge pull request #2605 from iptv-org/add-jiotv.com

Add jiotv.com
This commit is contained in:
PopeyeTheSai10r 2025-01-17 20:41:27 -08:00 committed by GitHub
commit 9a4fe43729
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1292 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,87 @@
const axios = require('axios')
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)
dayjs.extend(customParseFormat)
module.exports = {
site: 'jiotv.com',
days: 2,
url({ date, channel }) {
const offset = date.diff(dayjs.utc().startOf('d'), 'd')
return `https://jiotvapi.cdn.jio.com/apis/v1.3/getepg/get?channel_id=${channel.site_id}&offset=${offset}`
},
parser({ content }) {
let programs = []
let items = parseItems(content)
items.forEach(item => {
programs.push({
title: item.showname,
description: item.episode_desc || item.description,
directors: parseList(item.director),
actors: parseList(item.starCast),
categories: item.showGenre,
episode: parseEpisode(item),
keywords: item.keywords,
icon: parseIcon(item),
image: parseImage(item),
start: dayjs(item.startEpoch),
stop: dayjs(item.endEpoch)
})
})
return programs
},
async channels() {
const data = await axios
.get(
'https://jiotvapi.cdn.jio.com/apis/v3.0/getMobileChannelList/get/?langId=6&devicetype=phone&os=android&usertype=JIO&version=343'
)
.then(r => r.data)
.catch(console.error)
return data.result.map(c => {
return {
lang: 'en',
site_id: c.channel_id,
name: c.channel_name
}
})
}
}
function parseEpisode(item) {
return item.episode_num > 0 ? item.episode_num : null
}
function parseList(string) {
return string.split(', ').filter(Boolean)
}
function parseIcon(item) {
return item.episodeThumbnail
? `https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/${item.episodeThumbnail}`
: null
}
function parseImage(item) {
return item.episodePoster
? `https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/${item.episodePoster}`
: null
}
function parseItems(content) {
try {
const data = JSON.parse(content)
if (!data || !Array.isArray(data.epg)) return []
return data.epg
} catch {
return []
}
}

View file

@ -0,0 +1,86 @@
const { parser, url } = require('./jiotv.com.config.js')
const fs = require('fs')
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)
jest.useFakeTimers().setSystemTime(new Date('2025-01-15'))
const date = dayjs.utc('2025-01-17', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '146',
xmltv_id: 'HistoryTV18HD.in'
}
it('can generate valid url', () => {
expect(url({ date, channel })).toBe(
'https://jiotvapi.cdn.jio.com/apis/v1.3/getepg/get?channel_id=146&offset=2'
)
})
it('can parse response', () => {
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.json'), 'utf8')
let results = parser({ content })
results = results.map(p => {
p.start = p.start.toJSON()
p.stop = p.stop.toJSON()
return p
})
expect(results.length).toBe(46)
expect(results[1]).toMatchObject({
start: '2025-01-16T19:13:00.000Z',
stop: '2025-01-16T19:57:00.000Z',
title: "History's Greatest Heists With Pierce Brosnan",
description:
"Daring criminals burrow beneath London's streets to infiltrate a Lloyds Bank vault. However, their heist takes an unexpected turn when a radio hobbyist stumbles upon their communications.",
categories: ['History'],
directors: ['Brendan G Murphy'],
actors: ['Brent Picha', 'William Sibley', 'Bobby Williams'],
episode: 3,
keywords: [
'Heist',
'Criminal mastermind',
'Consequences',
'Historical account',
'Historical significance',
'Criminal offence'
],
icon: 'https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/2025-01-17/250117146001_s.jpg',
image: 'https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/2025-01-17/250117146001.jpg'
})
expect(results[45]).toMatchObject({
start: '2025-01-17T18:29:00.000Z',
stop: '2025-01-17T18:29:59.000Z',
title: "History's Greatest Escapes with Morgan Freeman",
description:
'In French Guiana, when petty thief Rene Belbenoit faces harsh imprisonment, determined to break free, he endures years of gruelling conditions and attempts numerous daring escapes.',
categories: ['Crime'],
directors: ['Mitch Marcus'],
actors: [],
episode: 5,
keywords: [
'Imprisoned',
'Prison',
'Prison Break',
'Prison film',
'Set in a prison',
'Escape',
'Survival',
'Survival Instinct'
],
icon: 'https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/2025-01-17/250117146045_s.jpg',
image: 'https://jiotvimages.cdn.jio.com/dare_images/shows/700/-/2025-01-17/250117146045.jpg'
})
})
it('can handle empty guide', () => {
const results = parser({
content: ''
})
expect(results).toMatchObject([])
})

21
sites/jiotv.com/readme.md Normal file
View file

@ -0,0 +1,21 @@
# jiotv.com
https://www.jiotv.com/tv-guide
### Download the guide
```sh
npm run grab --- --site=jiotv.com
```
### Update channel list
```sh
npm run channels:parse --- --config=./sites/jiotv.com/jiotv.com.config.js --output=./sites/jiotv.com/jiotv.com.channels.xml
```
### Test
```sh
npm test --- jiotv.com
```