Merge pull request #8035 from iptv-org/fix-export-js

Fix export.js
This commit is contained in:
Aleksandr Statciuk 2022-08-13 20:44:52 +03:00 committed by GitHub
commit 18e83b4a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 10 deletions

View File

@ -13,7 +13,7 @@ async function main() {
let streams = await db.streams.find({})
streams = _.sortBy(streams, 'channel')
streams = streams.map(stream => {
const data = {
let data = {
channel: stream.channel,
url: stream.url,
http_referrer: stream.http_referrer,
@ -29,6 +29,7 @@ async function main() {
let updatedAt = now
let found = api.streams.find({ url: stream.url })
if (found) {
data = JSON.parse(JSON.stringify(data))
normalized = _.omit(found, ['added_at', 'updated_at', 'checked_at'])
if (_.isEqual(data, normalized)) {
addedAt = found.added_at || now

View File

@ -1 +1 @@
[{"channel":"LDPRTV.ru","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","http_referrer":null,"user_agent":null,"status":"online","width":1920,"height":1080,"bitrate":6542556,"frame_rate":50,"added_at":"2022-07-07T00:00:00Z","checked_at":"2022-08-07T00:00:00Z","updated_at":"2022-08-07T00:00:00Z"},{"channel":"LibyasChannel.ly","url":"https://master.starmena-cloud.com/hls/libyas.m3u8","http_referrer":null,"user_agent":null,"status":"online","width":1024,"height":576,"bitrate":0,"frame_rate":25,"added_at":"2022-07-07T00:00:00Z","checked_at":"2022-07-07T00:00:00Z","updated_at":"2022-07-07T00:00:00Z"}]
[{"channel":"AndorraTV.ad","url":"https://iptv-all.lanesh4d0w.repl.co/andorra/atv","http_referrer":"http://imn.iq","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148","status":"error","added_at":"2022-07-07T00:00:00Z","updated_at":"2022-08-07T00:00:00Z","checked_at":"2022-08-07T00:00:00Z"},{"channel":"LDPRTV.ru","url":"http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8","http_referrer":null,"user_agent":null,"status":"online","width":1920,"height":1080,"bitrate":6542556,"frame_rate":50,"added_at":"2022-07-07T00:00:00Z","checked_at":"2022-08-07T00:00:00Z","updated_at":"2022-08-07T00:00:00Z"},{"channel":"LibyasChannel.ly","url":"https://master.starmena-cloud.com/hls/libyas.m3u8","http_referrer":null,"user_agent":null,"status":"online","width":1024,"height":576,"bitrate":0,"frame_rate":25,"added_at":"2022-07-07T00:00:00Z","checked_at":"2022-07-07T00:00:00Z","updated_at":"2022-07-07T00:00:00Z"}]

View File

@ -21,22 +21,34 @@ it('can create streams.json', () => {
let output = content(`output/.api/streams.json`)
let expected = content(`expected/.api/streams.json`)
const updatedUrl = 'https://master.starmena-cloud.com/hls/libyas.m3u8'
let outputData = output.find(i => i.url === updatedUrl)
let savedData = api.find(i => i.url === updatedUrl)
const samples = {
unchanged_online: 'https://master.starmena-cloud.com/hls/libyas.m3u8',
unchanged_error: 'https://iptv-all.lanesh4d0w.repl.co/andorra/atv',
updated_error: 'http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8',
added_online: 'https://master.starmena-cloud.com/hls/bbc.m3u8'
}
let outputData, savedData
outputData = output.find(i => i.url === samples['unchanged_online'])
savedData = api.find(i => i.url === samples['unchanged_online'])
expect(outputData.added_at).toBe(savedData.added_at)
expect(outputData.updated_at).toBe(savedData.updated_at)
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
const sameUrl = 'http://46.46.143.222:1935/live/mp4:ldpr.stream/playlist.m3u8'
outputData = output.find(i => i.url === sameUrl)
savedData = api.find(i => i.url === sameUrl)
outputData = output.find(i => i.url === samples['unchanged_error'])
savedData = api.find(i => i.url === samples['unchanged_error'])
expect(outputData.added_at).toBe(savedData.added_at)
expect(outputData.updated_at).toBe(savedData.updated_at)
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
outputData = output.find(i => i.url === samples['updated_error'])
savedData = api.find(i => i.url === samples['unchanged_error'])
expect(outputData.added_at).toBe(savedData.added_at)
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
const addedUrl = 'https://master.starmena-cloud.com/hls/bbc.m3u8'
outputData = output.find(i => i.url === addedUrl)
outputData = output.find(i => i.url === samples['added_online'])
expect(dayjs().diff(outputData.added_at, 'h')).toBe(0)
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)