adapt tvprofil.com checksum impl

This commit is contained in:
GenericMale 2023-11-21 18:30:09 +01:00
parent 35272ea0a4
commit 7231180cf0
2 changed files with 7 additions and 6 deletions

View file

@ -77,19 +77,20 @@ function buildQuery(site_id, date) {
callback: 'cb' callback: 'cb'
} }
const a = query.datum + query.kanal let c = 3
const a = query.datum + query.kanal + c
const ua = query.kanal + query.datum const ua = query.kanal + query.datum
let i = a.length, let i = a.length,
b = 2, b = 2
c = 2
for (var j = 0; j < ua.length; j++) c += ua.charCodeAt(j) for (let j = 0; j < ua.length; j++) c += ua.charCodeAt(j)
while (i--) { while (i--) {
b += (a.charCodeAt(i) + c * 2) * i b += (a.charCodeAt(i) + c * 2) * i
} }
const key = 'b' + b.toString().charCodeAt(2) b = b.toString()
const key = 'b' + b.charCodeAt(b.length-1)
query[key] = b query[key] = b

View file

@ -17,7 +17,7 @@ const channel = {
it('can generate valid url', () => { it('can generate valid url', () => {
expect(url({ channel, date })).toBe( expect(url({ channel, date })).toBe(
'https://tvprofil.com/bg/tv-programa/program/?datum=2023-01-12&kanal=24kitchen-bg&callback=cb&b55=747917' 'https://tvprofil.com/bg/tv-programa/program/?datum=2023-01-12&kanal=24kitchen-bg&callback=cb&b51=818933'
) )
}) })