fix winplay.co

This commit is contained in:
theofficialomega
2026-02-19 22:22:51 +01:00
parent 13306580c2
commit 26cfe626e2
4 changed files with 2348 additions and 671 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<channels>
<channel site="winplay.co" site_id="529cff6f6bd2ea6b610000e0" lang="es" xmltv_id="WinPlusFutbol.co@SD">Win+ Fútbol</channel>
<channel site="winplay.co" site_id="5265a8f3af1ecb9d320000ee" lang="es" xmltv_id="WinSports.co@SD">Win Sports</channel>
<channel site="winplay.co" site_id="winsports" lang="es" xmltv_id="">Win Sports</channel>
<channel site="winplay.co" site_id="winsportsplus" lang="es" xmltv_id="">Win+Fútbol</channel>
<channel site="winplay.co" site_id="winsportsplusaudio" lang="es" xmltv_id="">Win Lite</channel>
</channels>

View File

@@ -1,45 +1,105 @@
const dayjs = require('dayjs')
const axios = require('axios')
const API_BASE = 'https://unity.tbxapis.com/v0'
const CLIENT_ID = '6a561d048728db7c786b53b0941d0dd9'
let cachedToken = null
module.exports = {
site: 'winplay.co',
days: 2,
url: 'https://next.platform.mediastre.am/graphql',
async url({ date }) {
const epgLink = await fetchEpgItemsURL()
const from = dayjs(date).startOf('day').toISOString()
const to = dayjs(date).add(1, 'day').endOf('day').toISOString()
return epgLink + `?pageSize=25&page=1&fromEpg=${from}&toEpg=${to}`
},
request: {
method: 'POST',
headers: {
accept: 'application/json',
'x-client-id': 'a084524ea449c15dfe5e75636fb55ce6a9d0d7601aac946daa',
'x-ott-language': 'es'
},
data() {
async headers() {
await getToken()
return {
operationName: 'getLivesEpg',
variables: { page: 1, hours: 48 },
query:
'query getLivesEpg($page: Int = 1, $hours: Int, $ids: [String]) {\n getLives(ids: $ids) {\n _id\n logo\n name\n schedules(hours: $hours, page: {limit: 0, page: $page}) {\n _id\n name\n date_start\n date_end\n current\n match {\n matchDay\n __typename\n }\n show {\n _id\n title\n __typename\n }\n live {\n _id\n dvr\n type\n purchased\n __typename\n }\n __typename\n }\n __typename\n }\n}\n'
Authorization: `JWT ${cachedToken}`,
'Content-Type': 'application/json'
}
}
},
parser({ content, channel, date }) {
let programs = []
const programs = []
const items = parseItems(content, channel, date)
for (let item of items) {
for (const item of items) {
programs.push({
title: item.name,
start: dayjs(item.date_start),
stop: dayjs(item.date_end)
title: item.programName || item.title,
description: item.description || null,
start: dayjs(item.startTime),
stop: dayjs(item.endTime),
episode: item.episode || null,
season: item.season || null,
icon: item.images?.[0]?.url || null
})
}
return programs
},
async channels() {
await getToken()
const epgLink = await fetchEpgItemsURL()
const response = await axios.get(epgLink + '?pageSize=50&page=1', {
headers: { Authorization: `JWT ${cachedToken}` }
})
const data = response.data
if (!data?.result) return []
return data.result.map(item => ({
site_id: item.content.signalId,
name: item.content.title,
lang: 'es'
}))
}
}
async function getToken() {
if (cachedToken) return cachedToken
const response = await axios.post(`${API_BASE}/auth/public`, {
auth: {
sub: CLIENT_ID,
country: null,
currentProfile: null,
device: null,
language: null
}
}, { headers: { 'Content-Type': 'application/json' } })
cachedToken = response.data?.token?.access_token || null
return cachedToken
}
let cachedEpgItemsURL = null
async function fetchEpgItemsURL() {
if (cachedEpgItemsURL) return cachedEpgItemsURL
const sectionsResp = await axios.get(`${API_BASE}/sections?page=1&pageSize=400`, {
headers: { Authorization: `JWT ${cachedToken}` }
})
const programacionID = sectionsResp.data?.result?.find(s => s.name === 'Programación')?.id
if (!programacionID) throw new Error('Programación section not found')
const componentsResp = await axios.get(`${API_BASE}/sections/${programacionID}/components`, {
headers: { Authorization: `JWT ${cachedToken}` }
})
const epgLink = componentsResp.data?.result?.find(
c => c.active && c.componentType === 'epg_grid'
)?.itemsURL
if (!epgLink) throw new Error('EPG grid component not found')
cachedEpgItemsURL = epgLink
return cachedEpgItemsURL
}
function parseItems(content, channel, date) {
const data = JSON.parse(content)
if (!data || !data.data || !data.data.getLives) return []
const channelData = data.data.getLives.find(i => i._id === channel.site_id)
if (!Array.isArray(channelData.schedules)) return []
if (!data?.result) return []
const channelData = data.result.find(i => i.content?.signalId === channel.site_id)
if (!channelData?.content?.epg) return []
return channelData.schedules.filter(i => date.isSame(dayjs(i.date_start), 'd'))
return channelData.content.epg.filter(i => dayjs(date).isSame(dayjs(i.startTime), 'd'))
}

View File

@@ -7,35 +7,18 @@ const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
dayjs.extend(utc)
const date = dayjs.utc('2024-12-24', 'YYYY-MM-DD').startOf('d')
const date = dayjs.utc('2026-02-19', 'YYYY-MM-DD').startOf('d')
const channel = {
site_id: '529cff6f6bd2ea6b610000e0',
site_id: 'winsportsplus',
xmltv_id: 'WinPlusFutbol.co'
}
it('can generate valid url', () => {
expect(url).toBe('https://next.platform.mediastre.am/graphql')
})
it('can generate valid request method', () => {
expect(request.method).toBe('POST')
expect(typeof url).toBe('function')
})
it('can generate valid request headers', () => {
expect(request.headers).toMatchObject({
accept: 'application/json',
'x-client-id': 'a084524ea449c15dfe5e75636fb55ce6a9d0d7601aac946daa',
'x-ott-language': 'es'
})
})
it('can generate valid request data', () => {
expect(request.data()).toMatchObject({
operationName: 'getLivesEpg',
variables: { page: 1, hours: 48 },
query:
'query getLivesEpg($page: Int = 1, $hours: Int, $ids: [String]) {\n getLives(ids: $ids) {\n _id\n logo\n name\n schedules(hours: $hours, page: {limit: 0, page: $page}) {\n _id\n name\n date_start\n date_end\n current\n match {\n matchDay\n __typename\n }\n show {\n _id\n title\n __typename\n }\n live {\n _id\n dvr\n type\n purchased\n __typename\n }\n __typename\n }\n __typename\n }\n}\n'
})
expect(typeof request.headers).toBe('function')
})
it('can parse response', () => {
@@ -48,20 +31,26 @@ it('can parse response', () => {
})
expect(results[0]).toMatchObject({
start: '2024-12-24T00:30:00.000Z',
stop: '2024-12-24T02:30:00.000Z',
title: 'Los Disruptivos de Win'
start: '2026-02-19T00:20:00.000Z',
stop: '2026-02-19T02:45:00.000Z',
title: 'Liga BetPlay Dimayor 2026 - I: Junior vs. América (Fecha 7)'
})
expect(results[1]).toMatchObject({
start: '2024-12-24T02:30:00.000Z',
stop: '2024-12-24T03:30:00.000Z',
title: 'WIn Noticias'
start: '2026-02-19T02:45:00.000Z',
stop: '2026-02-19T03:30:00.000Z',
title: 'Win Noticias',
})
expect(results[9]).toMatchObject({
start: '2026-02-19T23:00:00.000Z',
stop: '2026-02-20T00:30:00.000Z',
title: 'Win Noticias'
})
})
it('can handle empty guide', () => {
const content = '{"status":"ERROR","error":"UNAUTHORIZED_REQUEST"}'
const content = '{"count":0,"result":[]}'
const results = parser({ content, channel, date })
expect(results).toMatchObject([])