mirror of
https://github.com/iptv-org/epg
synced 2025-12-19 11:56:58 -05:00
Fix linter issues
This commit is contained in:
@@ -10,7 +10,8 @@
|
|||||||
* const users = [{name: 'john', age: 30}, {name: 'jane', age: 25}];
|
* const users = [{name: 'john', age: 30}, {name: 'jane', age: 25}];
|
||||||
* sortBy(users, x => x.age); // [{name: 'jane', age: 25}, {name: 'john', age: 30}]
|
* sortBy(users, x => x.age); // [{name: 'jane', age: 25}, {name: 'john', age: 30}]
|
||||||
*/
|
*/
|
||||||
export const sortBy = <T>(arr: T[], fn: (item: T) => number | string): T[] => [...arr].sort((a, b) => fn(a) > fn(b) ? 1 : -1)
|
export const sortBy = <T>(arr: T[], fn: (item: T) => number | string): T[] =>
|
||||||
|
[...arr].sort((a, b) => (fn(a) > fn(b) ? 1 : -1))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array by multiple criteria with customizable sort orders.
|
* Sorts an array by multiple criteria with customizable sort orders.
|
||||||
@@ -26,10 +27,19 @@ export const sortBy = <T>(arr: T[], fn: (item: T) => number | string): T[] => [.
|
|||||||
* orderBy(users, [x => x.age, x => x.name], ['desc', 'asc']);
|
* orderBy(users, [x => x.age, x => x.name], ['desc', 'asc']);
|
||||||
* // [{name: 'bob', age: 30}, {name: 'john', age: 30}, {name: 'jane', age: 25}]
|
* // [{name: 'bob', age: 30}, {name: 'john', age: 30}, {name: 'jane', age: 25}]
|
||||||
*/
|
*/
|
||||||
export const orderBy = (arr: Array<unknown>, fns: Array<(item: unknown) => string | number>, orders: Array<string> = []): Array<unknown> => [...arr].sort((a, b) =>
|
export const orderBy = (
|
||||||
fns.reduce((acc, fn, i) =>
|
arr: Array<unknown>,
|
||||||
acc || ((orders[i] === 'desc' ? fn(b) > fn(a) : fn(a) > fn(b)) ? 1 : fn(a) === fn(b) ? 0 : -1), 0)
|
fns: Array<(item: unknown) => string | number>,
|
||||||
)
|
orders: Array<string> = []
|
||||||
|
): Array<unknown> =>
|
||||||
|
[...arr].sort((a, b) =>
|
||||||
|
fns.reduce(
|
||||||
|
(acc, fn, i) =>
|
||||||
|
acc ||
|
||||||
|
((orders[i] === 'desc' ? fn(b) > fn(a) : fn(a) > fn(b)) ? 1 : fn(a) === fn(b) ? 0 : -1),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a duplicate-free version of an array using an iteratee function to generate
|
* Creates a duplicate-free version of an array using an iteratee function to generate
|
||||||
@@ -44,7 +54,8 @@ export const orderBy = (arr: Array<unknown>, fns: Array<(item: unknown) => strin
|
|||||||
* const users = [{id: 1, name: 'john'}, {id: 2, name: 'jane'}, {id: 1, name: 'john'}];
|
* const users = [{id: 1, name: 'john'}, {id: 2, name: 'jane'}, {id: 1, name: 'john'}];
|
||||||
* uniqBy(users, x => x.id); // [{id: 1, name: 'john'}, {id: 2, name: 'jane'}]
|
* uniqBy(users, x => x.id); // [{id: 1, name: 'john'}, {id: 2, name: 'jane'}]
|
||||||
*/
|
*/
|
||||||
export const uniqBy = <T>(arr: T[], fn: (item: T) => unknown): T[] => arr.filter((item, index) => arr.findIndex(x => fn(x) === fn(item)) === index)
|
export const uniqBy = <T>(arr: T[], fn: (item: T) => unknown): T[] =>
|
||||||
|
arr.filter((item, index) => arr.findIndex(x => fn(x) === fn(item)) === index)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string to start case (capitalizes the first letter of each word).
|
* Converts a string to start case (capitalizes the first letter of each word).
|
||||||
@@ -59,7 +70,8 @@ export const uniqBy = <T>(arr: T[], fn: (item: T) => unknown): T[] => arr.filter
|
|||||||
* startCase('hello-world'); // "Hello World"
|
* startCase('hello-world'); // "Hello World"
|
||||||
* startCase('hello world'); // "Hello World"
|
* startCase('hello world'); // "Hello World"
|
||||||
*/
|
*/
|
||||||
export const startCase = (str: string): string => str
|
export const startCase = (str: string): string =>
|
||||||
|
str
|
||||||
.replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase
|
.replace(/([a-z])([A-Z])/g, '$1 $2') // Split camelCase
|
||||||
.replace(/[_-]/g, ' ') // Replace underscores and hyphens with spaces
|
.replace(/[_-]/g, ' ') // Replace underscores and hyphens with spaces
|
||||||
.replace(/\b\w/g, c => c.toUpperCase()) // Capitalize first letter of each word
|
.replace(/\b\w/g, c => c.toUpperCase()) // Capitalize first letter of each word
|
||||||
@@ -57,7 +57,7 @@ module.exports = {
|
|||||||
let category = parseCategory($item)
|
let category = parseCategory($item)
|
||||||
let description = parseDescription($item)
|
let description = parseDescription($item)
|
||||||
const itemDetailsURL = parseDescriptionURL($item)
|
const itemDetailsURL = parseDescriptionURL($item)
|
||||||
if(itemDetailsURL) {
|
if (itemDetailsURL) {
|
||||||
const url = 'https://www.guidetnt.com' + itemDetailsURL
|
const url = 'https://www.guidetnt.com' + itemDetailsURL
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url)
|
const response = await axios.get(url)
|
||||||
@@ -110,7 +110,9 @@ module.exports = {
|
|||||||
// Look inside each .tvlogo container
|
// Look inside each .tvlogo container
|
||||||
$('.tvlogo').each((i, el) => {
|
$('.tvlogo').each((i, el) => {
|
||||||
// Find all descendants that have an alt attribute
|
// Find all descendants that have an alt attribute
|
||||||
$(el).find('[alt]').each((j, subEl) => {
|
$(el)
|
||||||
|
.find('[alt]')
|
||||||
|
.each((j, subEl) => {
|
||||||
const alt = $(subEl).attr('alt')
|
const alt = $(subEl).attr('alt')
|
||||||
const href = $(subEl).attr('href')
|
const href = $(subEl).attr('href')
|
||||||
if (href && alt && alt.trim() !== '') {
|
if (href && alt && alt.trim() !== '') {
|
||||||
@@ -218,7 +220,10 @@ function parseItemDetails(itemDetails) {
|
|||||||
function parseCategoryText(text) {
|
function parseCategoryText(text) {
|
||||||
if (!text) return null
|
if (!text) return null
|
||||||
|
|
||||||
const parts = text.split(',').map(s => s.trim()).filter(Boolean)
|
const parts = text
|
||||||
|
.split(',')
|
||||||
|
.map(s => s.trim())
|
||||||
|
.filter(Boolean)
|
||||||
const len = parts.length
|
const len = parts.length
|
||||||
|
|
||||||
const category = parts[0] || null
|
const category = parts[0] || null
|
||||||
@@ -263,7 +268,7 @@ function parseCategoryText(text) {
|
|||||||
|
|
||||||
// Country: second to last
|
// Country: second to last
|
||||||
const countryIndex = len - 2
|
const countryIndex = len - 2
|
||||||
let country = (durationIndex === countryIndex) ? null : parts[countryIndex]
|
let country = durationIndex === countryIndex ? null : parts[countryIndex]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
category,
|
category,
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ it('can parse response', async () => {
|
|||||||
expect(results.length).toBe(29)
|
expect(results.length).toBe(29)
|
||||||
expect(results[0]).toMatchObject({
|
expect(results[0]).toMatchObject({
|
||||||
category: 'Série',
|
category: 'Série',
|
||||||
description: 'Grande effervescence pour toute l\'équipe du Camping Paradis, qui prépare les Olympiades. Côté arrivants, Hélène et sa fille Eva viennent passer quelques jours dans le but d\'optimiser les révisions d\'E...',
|
description:
|
||||||
|
"Grande effervescence pour toute l'équipe du Camping Paradis, qui prépare les Olympiades. Côté arrivants, Hélène et sa fille Eva viennent passer quelques jours dans le but d'optimiser les révisions d'E...",
|
||||||
start: '2025-06-30T22:55:00.000Z',
|
start: '2025-06-30T22:55:00.000Z',
|
||||||
stop: '2025-06-30T23:45:00.000Z',
|
stop: '2025-06-30T23:45:00.000Z',
|
||||||
title: 'Camping Paradis'
|
title: 'Camping Paradis'
|
||||||
@@ -46,10 +47,11 @@ it('can parse response', async () => {
|
|||||||
})
|
})
|
||||||
expect(results[15]).toMatchObject({
|
expect(results[15]).toMatchObject({
|
||||||
category: 'Téléfilm',
|
category: 'Téléfilm',
|
||||||
description: 'La vie quasi parfaite de Riley bascule brutalement lorsqu\'un accident de voiture lui coûte la vie, laissant derrière elle sa famille. Alors que l\'enquête débute, l\'affaire prend une tournure étrange l...',
|
description:
|
||||||
|
"La vie quasi parfaite de Riley bascule brutalement lorsqu'un accident de voiture lui coûte la vie, laissant derrière elle sa famille. Alors que l'enquête débute, l'affaire prend une tournure étrange l...",
|
||||||
start: '2025-07-01T12:25:00.000Z',
|
start: '2025-07-01T12:25:00.000Z',
|
||||||
stop: '2025-07-01T14:00:00.000Z',
|
stop: '2025-07-01T14:00:00.000Z',
|
||||||
title: 'Trahie par l\'amour'
|
title: "Trahie par l'amour"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -60,13 +62,13 @@ it('can parse response for current day', async () => {
|
|||||||
p.start = p.start.toJSON()
|
p.start = p.start.toJSON()
|
||||||
p.stop = p.stop.toJSON()
|
p.stop = p.stop.toJSON()
|
||||||
return p
|
return p
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
expect(results.length).toBe(29)
|
expect(results.length).toBe(29)
|
||||||
expect(results[0]).toMatchObject({
|
expect(results[0]).toMatchObject({
|
||||||
category: 'Série',
|
category: 'Série',
|
||||||
description: 'Grande effervescence pour toute l\'équipe du Camping Paradis, qui prépare les Olympiades. Côté arrivants, Hélène et sa fille Eva viennent passer quelques jours dans le but d\'optimiser les révisions d\'E...',
|
description:
|
||||||
|
"Grande effervescence pour toute l'équipe du Camping Paradis, qui prépare les Olympiades. Côté arrivants, Hélène et sa fille Eva viennent passer quelques jours dans le but d'optimiser les révisions d'E...",
|
||||||
start: '2025-06-30T22:55:00.000Z',
|
start: '2025-06-30T22:55:00.000Z',
|
||||||
stop: '2025-06-30T23:45:00.000Z',
|
stop: '2025-06-30T23:45:00.000Z',
|
||||||
title: 'Camping Paradis'
|
title: 'Camping Paradis'
|
||||||
|
|||||||
@@ -5,19 +5,22 @@ module.exports = {
|
|||||||
days: 1,
|
days: 1,
|
||||||
|
|
||||||
url({ date }) {
|
url({ date }) {
|
||||||
return `https://tm.tapi.videoready.tv/content-detail/pub/api/v2/channels/schedule?date=${date.format('DD-MM-YYYY')}`
|
return `https://tm.tapi.videoready.tv/content-detail/pub/api/v2/channels/schedule?date=${date.format(
|
||||||
|
'DD-MM-YYYY'
|
||||||
|
)}`
|
||||||
},
|
},
|
||||||
|
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': '*/*',
|
Accept: '*/*',
|
||||||
'Origin': 'https://watch.tataplay.com',
|
Origin: 'https://watch.tataplay.com',
|
||||||
'Referer': 'https://watch.tataplay.com/',
|
Referer: 'https://watch.tataplay.com/',
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
'locale': 'ENG',
|
locale: 'ENG',
|
||||||
'platform': 'web'
|
platform: 'web'
|
||||||
},
|
},
|
||||||
data({ channel }) {
|
data({ channel }) {
|
||||||
return { id: channel.site_id }
|
return { id: channel.site_id }
|
||||||
@@ -46,13 +49,14 @@ module.exports = {
|
|||||||
|
|
||||||
async channels() {
|
async channels() {
|
||||||
const headers = {
|
const headers = {
|
||||||
'Accept': '*/*',
|
Accept: '*/*',
|
||||||
'Origin': 'https://watch.tataplay.com',
|
Origin: 'https://watch.tataplay.com',
|
||||||
'Referer': 'https://watch.tataplay.com/',
|
Referer: 'https://watch.tataplay.com/',
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
'User-Agent':
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
'locale': 'ENG',
|
locale: 'ENG',
|
||||||
'platform': 'web'
|
platform: 'web'
|
||||||
}
|
}
|
||||||
|
|
||||||
const baseUrl = 'https://tm.tapi.videoready.tv/portal-search/pub/api/v1/channels/schedule'
|
const baseUrl = 'https://tm.tapi.videoready.tv/portal-search/pub/api/v1/channels/schedule'
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ const date = dayjs.utc('2025-06-09', 'YYYY-MM-DD').startOf('d')
|
|||||||
const channel = { site_id: '1001' }
|
const channel = { site_id: '1001' }
|
||||||
|
|
||||||
it('can generate valid url', () => {
|
it('can generate valid url', () => {
|
||||||
expect(url({ channel, date })).toBe('https://tm.tapi.videoready.tv/content-detail/pub/api/v2/channels/schedule?date=09-06-2025')
|
expect(url({ channel, date })).toBe(
|
||||||
|
'https://tm.tapi.videoready.tv/content-detail/pub/api/v2/channels/schedule?date=09-06-2025'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can parse response', () => {
|
it('can parse response', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user