mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
Fix linter issues
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
* const users = [{name: 'john', age: 30}, {name: 'jane', age: 25}];
|
||||
* 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.
|
||||
@@ -26,9 +27,18 @@ export const sortBy = <T>(arr: T[], fn: (item: T) => number | string): T[] => [.
|
||||
* orderBy(users, [x => x.age, x => x.name], ['desc', 'asc']);
|
||||
* // [{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) =>
|
||||
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)
|
||||
export const orderBy = (
|
||||
arr: Array<unknown>,
|
||||
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
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -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'}];
|
||||
* 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).
|
||||
@@ -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"
|
||||
*/
|
||||
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(/[_-]/g, ' ') // Replace underscores and hyphens with spaces
|
||||
.replace(/\b\w/g, c => c.toUpperCase()) // Capitalize first letter of each word
|
||||
@@ -110,7 +110,9 @@ module.exports = {
|
||||
// Look inside each .tvlogo container
|
||||
$('.tvlogo').each((i, el) => {
|
||||
// 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 href = $(subEl).attr('href')
|
||||
if (href && alt && alt.trim() !== '') {
|
||||
@@ -218,7 +220,10 @@ function parseItemDetails(itemDetails) {
|
||||
function parseCategoryText(text) {
|
||||
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 category = parts[0] || null
|
||||
@@ -263,7 +268,7 @@ function parseCategoryText(text) {
|
||||
|
||||
// Country: second to last
|
||||
const countryIndex = len - 2
|
||||
let country = (durationIndex === countryIndex) ? null : parts[countryIndex]
|
||||
let country = durationIndex === countryIndex ? null : parts[countryIndex]
|
||||
|
||||
return {
|
||||
category,
|
||||
|
||||
@@ -32,7 +32,8 @@ it('can parse response', async () => {
|
||||
expect(results.length).toBe(29)
|
||||
expect(results[0]).toMatchObject({
|
||||
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',
|
||||
stop: '2025-06-30T23:45:00.000Z',
|
||||
title: 'Camping Paradis'
|
||||
@@ -46,10 +47,11 @@ it('can parse response', async () => {
|
||||
})
|
||||
expect(results[15]).toMatchObject({
|
||||
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',
|
||||
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.stop = p.stop.toJSON()
|
||||
return p
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
expect(results.length).toBe(29)
|
||||
expect(results[0]).toMatchObject({
|
||||
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',
|
||||
stop: '2025-06-30T23:45:00.000Z',
|
||||
title: 'Camping Paradis'
|
||||
|
||||
@@ -5,19 +5,22 @@ module.exports = {
|
||||
days: 1,
|
||||
|
||||
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: {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Origin': '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',
|
||||
Accept: '*/*',
|
||||
Origin: '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',
|
||||
'content-type': 'application/json',
|
||||
'locale': 'ENG',
|
||||
'platform': 'web'
|
||||
locale: 'ENG',
|
||||
platform: 'web'
|
||||
},
|
||||
data({ channel }) {
|
||||
return { id: channel.site_id }
|
||||
@@ -46,13 +49,14 @@ module.exports = {
|
||||
|
||||
async channels() {
|
||||
const headers = {
|
||||
'Accept': '*/*',
|
||||
'Origin': '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',
|
||||
Accept: '*/*',
|
||||
Origin: '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',
|
||||
'content-type': 'application/json',
|
||||
'locale': 'ENG',
|
||||
'platform': 'web'
|
||||
locale: 'ENG',
|
||||
platform: 'web'
|
||||
}
|
||||
|
||||
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' }
|
||||
|
||||
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', () => {
|
||||
|
||||
Reference in New Issue
Block a user