mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 09:30:06 -04:00
Merge pull request #1146 from iptv-org/add-tivu.tv
Add guide from tivu.tv
This commit is contained in:
commit
3229e051ac
6 changed files with 690 additions and 0 deletions
17
.github/workflows/tivu.tv.yml
vendored
Normal file
17
.github/workflows/tivu.tv.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
name: tivu.tv
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 3 * * *'
|
||||
workflow_dispatch:
|
||||
workflow_run:
|
||||
workflows: [_trigger]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
load:
|
||||
uses: ./.github/workflows/_load.yml
|
||||
with:
|
||||
site: ${{github.workflow}}
|
||||
secrets:
|
||||
APP_ID: ${{ secrets.APP_ID }}
|
||||
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
|
476
sites/tivu.tv/__data__/content.html
Normal file
476
sites/tivu.tv/__data__/content.html
Normal file
File diff suppressed because one or more lines are too long
0
sites/tivu.tv/__data__/no_content.html
Normal file
0
sites/tivu.tv/__data__/no_content.html
Normal file
68
sites/tivu.tv/tivu.tv.config.js
Normal file
68
sites/tivu.tv/tivu.tv.config.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
const dayjs = require('dayjs')
|
||||
const cheerio = require('cheerio')
|
||||
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: 'tivu.tv',
|
||||
request: {
|
||||
cache: {
|
||||
ttl: 60 * 60 * 1000 // 1 hour
|
||||
}
|
||||
},
|
||||
url({ date }) {
|
||||
const diff = date.diff(dayjs.utc().startOf('d'), 'd')
|
||||
|
||||
return `https://www.tivu.tv/epg_ajax_sat.aspx?d=${diff}`
|
||||
},
|
||||
parser: function ({ content, channel, date }) {
|
||||
let programs = []
|
||||
const items = parseItems(content, channel, date)
|
||||
items.forEach(item => {
|
||||
const $item = cheerio.load(item)
|
||||
const prev = programs[programs.length - 1]
|
||||
let start = parseStart($item, date)
|
||||
if (!start) return
|
||||
if (prev) {
|
||||
if (start.isBefore(prev.start)) {
|
||||
start = start.add(1, 'd')
|
||||
date = date.add(1, 'd')
|
||||
}
|
||||
prev.stop = start
|
||||
}
|
||||
const stop = start.add(30, 'm')
|
||||
programs.push({
|
||||
title: parseTitle($item),
|
||||
start,
|
||||
stop
|
||||
})
|
||||
})
|
||||
|
||||
return programs
|
||||
}
|
||||
}
|
||||
|
||||
function parseTitle($item) {
|
||||
const [title, _, __] = $item('a').html().split('<br>')
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
function parseStart($item, date) {
|
||||
const [_, __, time] = $item('a').html().split('<br>')
|
||||
if (!time) return null
|
||||
|
||||
return dayjs.tz(`${date.format('YYYY-MM-DD')} ${time}`, 'YYYY-MM-DD HH:mm', 'Europe/Rome')
|
||||
}
|
||||
|
||||
function parseItems(content, channel, date) {
|
||||
if (!content) return []
|
||||
const $ = cheerio.load(content)
|
||||
|
||||
return $(`.q[id="${channel.site_id}"] > .p`).toArray()
|
||||
}
|
54
sites/tivu.tv/tivu.tv.test.js
Normal file
54
sites/tivu.tv/tivu.tv.test.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
// npx epg-grabber --config=sites/tivu.tv/tivu.tv.config.js --channels=sites/tivu.tv/tivu.tv_it.channels.xml --output=guide.xml --days=2
|
||||
|
||||
const { parser, url, request } = require('./tivu.tv.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)
|
||||
const axios = require('axios')
|
||||
jest.mock('axios')
|
||||
|
||||
const date = dayjs.utc('2022-10-04', 'YYYY-MM-DD').startOf('d')
|
||||
const channel = {
|
||||
site_id: '62',
|
||||
xmltv_id: 'Rai1HD.it'
|
||||
}
|
||||
|
||||
it('can generate valid url for today', () => {
|
||||
expect(url({ date })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=0')
|
||||
})
|
||||
|
||||
it('can generate valid url for tomorrow', () => {
|
||||
expect(url({ date: date.add(1, 'd') })).toBe('https://www.tivu.tv/epg_ajax_sat.aspx?d=1')
|
||||
})
|
||||
|
||||
it('can parse response', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/content.html'))
|
||||
|
||||
let results = parser({ content, channel, date }).map(p => {
|
||||
p.start = p.start.toJSON()
|
||||
p.stop = p.stop.toJSON()
|
||||
return p
|
||||
})
|
||||
|
||||
expect(results[0]).toMatchObject({
|
||||
start: '2022-10-03T22:02:00.000Z',
|
||||
stop: '2022-10-03T22:45:00.000Z',
|
||||
title: 'Cose Nostre - La figlia del boss'
|
||||
})
|
||||
|
||||
expect(results[43]).toMatchObject({
|
||||
start: '2022-10-05T04:58:00.000Z',
|
||||
stop: '2022-10-05T05:28:00.000Z',
|
||||
title: 'Tgunomattina - in collaborazione con day'
|
||||
})
|
||||
})
|
||||
|
||||
it('can handle empty guide', () => {
|
||||
const content = fs.readFileSync(path.resolve(__dirname, '__data__/no_content.html'))
|
||||
const result = parser({ content, channel, date })
|
||||
expect(result).toMatchObject([])
|
||||
})
|
75
sites/tivu.tv/tivu.tv_it.channels.xml
Normal file
75
sites/tivu.tv/tivu.tv_it.channels.xml
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="tivu.tv">
|
||||
<channels>
|
||||
<channel lang="it" xmltv_id="20Mediaset.it" site_id="104">20 Mediaset</channel>
|
||||
<channel lang="it" xmltv_id="27Twentyseven.it" site_id="226">27</channel>
|
||||
<channel lang="it" xmltv_id="AlJazeeraEnglish.qa" site_id="72">Al Jazeera</channel>
|
||||
<channel lang="it" xmltv_id="BBCWorldNewsEurope.uk" site_id="2">BBC World News</channel>
|
||||
<channel lang="it" xmltv_id="BloombergTVEMEA.uk" site_id="3">Bloomberg European TV</channel>
|
||||
<channel lang="it" xmltv_id="BoingItaly.it" site_id="202">Boing</channel>
|
||||
<channel lang="it" xmltv_id="Canale5HD.it" site_id="139">Canale 5</channel>
|
||||
<channel lang="it" xmltv_id="CartoonitoItaly.it" site_id="203">Cartoonito</channel>
|
||||
<channel lang="it" xmltv_id="Cielo.it" site_id="187">cielo</channel>
|
||||
<channel lang="it" xmltv_id="Cine34.it" site_id="177">Cine34</channel>
|
||||
<channel lang="it" xmltv_id="DMAXItaly.it" site_id="225">DMAX</channel>
|
||||
<channel lang="it" xmltv_id="EQUtv.it" site_id="185">UNIQtv HD</channel>
|
||||
<channel lang="it" xmltv_id="EuronewsItalian.fr" site_id="53">Euronews Italian</channel>
|
||||
<channel lang="it" xmltv_id="FashionTVEurope.fr" site_id="178">Fashion TV</channel>
|
||||
<channel lang="it" xmltv_id="Focus.it" site_id="204">Focus</channel>
|
||||
<channel lang="it" xmltv_id="FoodNetworkItaly.it" site_id="222">Food Network</channel>
|
||||
<channel lang="it" xmltv_id="France24English.fr" site_id="136">France 24 HD (in English)</channel>
|
||||
<channel lang="it" xmltv_id="France24French.fr" site_id="137">France 24 HD (en Français)</channel>
|
||||
<channel lang="it" xmltv_id="Frisbee.it" site_id="223">frisbee</channel>
|
||||
<channel lang="it" xmltv_id="Giallo.it" site_id="172">GIALLO</channel>
|
||||
<channel lang="it" xmltv_id="GoldTV.it" site_id="228">Gold TV</channel>
|
||||
<channel lang="it" xmltv_id="HGTVItaly.it" site_id="210">HGTV</channel>
|
||||
<channel lang="it" xmltv_id="HorseTV.it" site_id="213">Horse TV</channel>
|
||||
<channel lang="it" xmltv_id="Iris.it" site_id="106">Iris</channel>
|
||||
<channel lang="it" xmltv_id="Italia1HD.it" site_id="140">Italia 1</channel>
|
||||
<channel lang="it" xmltv_id="Italia2.it" site_id="207">Mediaset ITALIA DUE</channel>
|
||||
<channel lang="it" xmltv_id="K2.it" site_id="224">K2</channel>
|
||||
<channel lang="it" xmltv_id="KBSWorld.kr" site_id="138">KBS HD</channel>
|
||||
<channel lang="it" xmltv_id="La5.it" site_id="205">La 5</channel>
|
||||
<channel lang="it" xmltv_id="La7.it" site_id="211">LA7</channel>
|
||||
<channel lang="it" xmltv_id="La7d.it" site_id="206">LA7d</channel>
|
||||
<channel lang="it" xmltv_id="MediasetExtra.it" site_id="149">Mediaset EXTRA</channel>
|
||||
<channel lang="it" xmltv_id="Mezzo.fr" site_id="112">MEZZO</channel>
|
||||
<channel lang="it" xmltv_id="MotorTrend.it" site_id="173">Motor Trend</channel>
|
||||
<channel lang="it" xmltv_id="MuseumTV.fr" site_id="179">Museum</channel>
|
||||
<channel lang="it" xmltv_id="MyZenTV4K.fr" site_id="180">MyZen TV</channel>
|
||||
<channel lang="it" xmltv_id="NASATVUHD.us" site_id="181">NASA</channel>
|
||||
<channel lang="it" xmltv_id="NHKWorldJapan.jp" site_id="169">NHK WORLD-JAPAN</channel>
|
||||
<channel lang="it" xmltv_id="Nove.it" site_id="174">NOVE</channel>
|
||||
<channel lang="it" xmltv_id="QVCHDItaly.it" site_id="184">QVC</channel>
|
||||
<channel lang="it" xmltv_id="RadioItaliaTV.it" site_id="123">Radio Italia TV</channel>
|
||||
<channel lang="it" xmltv_id="RadioMonteCarloTV.it" site_id="186">RMC</channel>
|
||||
<channel lang="it" xmltv_id="Rai1HD.it" site_id="62">Rai 1</channel>
|
||||
<channel lang="it" xmltv_id="Rai2HD.it" site_id="114">Rai 2</channel>
|
||||
<channel lang="it" xmltv_id="Rai3HD.it" site_id="31">Rai 3</channel>
|
||||
<channel lang="it" xmltv_id="Rai4HD.it" site_id="119">Rai 4</channel>
|
||||
<channel lang="it" xmltv_id="Rai4K.it" site_id="176">Rai 4K</channel>
|
||||
<channel lang="it" xmltv_id="Rai5HD.it" site_id="99">Rai 5</channel>
|
||||
<channel lang="it" xmltv_id="RaiGulpHD.it" site_id="95">Rai Gulp</channel>
|
||||
<channel lang="it" xmltv_id="RaiMovieHD.it" site_id="120">Rai Movie</channel>
|
||||
<channel lang="it" xmltv_id="RaiNews24HD.it" site_id="105">Rai News 24</channel>
|
||||
<channel lang="it" xmltv_id="RaiPremiumHD.it" site_id="221">Rai Premium</channel>
|
||||
<channel lang="it" xmltv_id="RaiScuolaHD.it" site_id="97">Rai Scuola</channel>
|
||||
<channel lang="it" xmltv_id="RaiSportPlusHD.it" site_id="182">Rai Sport</channel>
|
||||
<channel lang="it" xmltv_id="RaiStoriaHD.it" site_id="200">Rai Storia</channel>
|
||||
<channel lang="it" xmltv_id="RaiYoyoHD.it" site_id="96">Rai yoyo</channel>
|
||||
<channel lang="it" xmltv_id="RDSSocialTV.it" site_id="150">RDS Social TV</channel>
|
||||
<channel lang="it" xmltv_id="RealTimeItaly.it" site_id="227">Real Time</channel>
|
||||
<channel lang="it" xmltv_id="Rete4HD.it" site_id="141">Rete 4</channel>
|
||||
<channel lang="it" xmltv_id="RTL1025Radiovisione.it" site_id="128">RTL 102.5</channel>
|
||||
<channel lang="it" xmltv_id="Super.it" site_id="214">Super!</channel>
|
||||
<channel lang="it" xmltv_id="TGCom24.it" site_id="208">TgCom24</channel>
|
||||
<channel lang="it" xmltv_id="TopCrime.it" site_id="209">Topcrime</channel>
|
||||
<channel lang="it" xmltv_id="Travelxp4KEurope.in" site_id="183">Travel XP</channel>
|
||||
<channel lang="it" xmltv_id="TRMh24.it" site_id="212">TRM h24</channel>
|
||||
<channel lang="it" xmltv_id="TRTWorld.tr" site_id="142">TRT World HD</channel>
|
||||
<channel lang="it" xmltv_id="TV2000.va" site_id="81">TV2000</channel>
|
||||
<channel lang="it" xmltv_id="TV8.it" site_id="188">TV8</channel>
|
||||
<channel lang="it" xmltv_id="VH1Italia.it" site_id="219">VH1</channel>
|
||||
<!-- <channel lang="it" xmltv_id="-" site_id="93">Arte HD</channel> -->
|
||||
</channels>
|
||||
</site>
|
Loading…
Add table
Add a link
Reference in a new issue