commit
18e83b4a86
|
@ -13,7 +13,7 @@ async function main() {
|
||||||
let streams = await db.streams.find({})
|
let streams = await db.streams.find({})
|
||||||
streams = _.sortBy(streams, 'channel')
|
streams = _.sortBy(streams, 'channel')
|
||||||
streams = streams.map(stream => {
|
streams = streams.map(stream => {
|
||||||
const data = {
|
let data = {
|
||||||
channel: stream.channel,
|
channel: stream.channel,
|
||||||
url: stream.url,
|
url: stream.url,
|
||||||
http_referrer: stream.http_referrer,
|
http_referrer: stream.http_referrer,
|
||||||
|
@ -29,6 +29,7 @@ async function main() {
|
||||||
let updatedAt = now
|
let updatedAt = now
|
||||||
let found = api.streams.find({ url: stream.url })
|
let found = api.streams.find({ url: stream.url })
|
||||||
if (found) {
|
if (found) {
|
||||||
|
data = JSON.parse(JSON.stringify(data))
|
||||||
normalized = _.omit(found, ['added_at', 'updated_at', 'checked_at'])
|
normalized = _.omit(found, ['added_at', 'updated_at', 'checked_at'])
|
||||||
if (_.isEqual(data, normalized)) {
|
if (_.isEqual(data, normalized)) {
|
||||||
addedAt = found.added_at || now
|
addedAt = found.added_at || now
|
||||||
|
|
|
@ -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"}]
|
|
@ -21,22 +21,34 @@ it('can create streams.json', () => {
|
||||||
let output = content(`output/.api/streams.json`)
|
let output = content(`output/.api/streams.json`)
|
||||||
let expected = content(`expected/.api/streams.json`)
|
let expected = content(`expected/.api/streams.json`)
|
||||||
|
|
||||||
const updatedUrl = 'https://master.starmena-cloud.com/hls/libyas.m3u8'
|
const samples = {
|
||||||
let outputData = output.find(i => i.url === updatedUrl)
|
unchanged_online: 'https://master.starmena-cloud.com/hls/libyas.m3u8',
|
||||||
let savedData = api.find(i => i.url === updatedUrl)
|
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.added_at).toBe(savedData.added_at)
|
||||||
expect(outputData.updated_at).toBe(savedData.updated_at)
|
expect(outputData.updated_at).toBe(savedData.updated_at)
|
||||||
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
|
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 === samples['unchanged_error'])
|
||||||
outputData = output.find(i => i.url === sameUrl)
|
savedData = api.find(i => i.url === samples['unchanged_error'])
|
||||||
savedData = api.find(i => i.url === sameUrl)
|
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(outputData.added_at).toBe(savedData.added_at)
|
||||||
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
|
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
|
||||||
expect(dayjs().diff(outputData.checked_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 === samples['added_online'])
|
||||||
outputData = output.find(i => i.url === addedUrl)
|
|
||||||
expect(dayjs().diff(outputData.added_at, 'h')).toBe(0)
|
expect(dayjs().diff(outputData.added_at, 'h')).toBe(0)
|
||||||
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
|
expect(dayjs().diff(outputData.updated_at, 'h')).toBe(0)
|
||||||
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
|
expect(dayjs().diff(outputData.checked_at, 'h')).toBe(0)
|
||||||
|
|
Loading…
Reference in New Issue