MCPcopy
hub / github.com/iptv-org/iptv / main

Function main

scripts/commands/report/create.ts:23–177  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21}
22
23async function main() {
24 const logger = new Logger()
25 let report = new Collection()
26
27 logger.info('loading issues...')
28 const issues = await loadIssues()
29
30 logger.info('loading discussions...')
31 const discussions = await loadDiscussions()
32
33 logger.info('loading data from api...')
34 await loadData()
35
36 logger.info('loading streams...')
37 const streamsStorage = new Storage(STREAMS_DIR)
38 const parser = new PlaylistParser({
39 storage: streamsStorage
40 })
41 const files = await streamsStorage.list('**/*.m3u')
42 const streams = await parser.parse(files)
43 const streamsGroupedByUrl = streams.groupBy((stream: Stream) => stream.url)
44 const streamsGroupedByChannel = streams.groupBy((stream: Stream) => stream.channel)
45 const streamsGroupedById = streams.groupBy((stream: Stream) => stream.getId())
46
47 logger.info('checking streams:remove requests...')
48 const removeRequests = issues.filter(issue =>
49 issue.labels.find((label: string) => label === 'streams:remove')
50 )
51 removeRequests.forEach((issue: Issue) => {
52 const streamUrls = issue.data.getArray('stream_url') || []
53
54 if (!streamUrls.length) {
55 const result = {
56 issueNumber: issue.number,
57 type: 'streams:remove',
58 streamId: undefined,
59 streamUrl: undefined,
60 status: status.NONEXISTENT_LINK
61 }
62
63 report.add(result)
64 } else {
65 for (const streamUrl of streamUrls) {
66 const result = {
67 issueNumber: issue.number,
68 type: 'streams:remove',
69 streamId: undefined,
70 streamUrl: truncate(streamUrl),
71 status: status.PENDING
72 }
73
74 if (streamsGroupedByUrl.missing(streamUrl)) {
75 result.status = status.NONEXISTENT_LINK
76 }
77
78 report.add(result)
79 }
80 }

Callers 1

create.tsFile · 0.70

Calls 11

parseMethod · 0.95
loadIssuesFunction · 0.90
loadDiscussionsFunction · 0.90
loadDataFunction · 0.90
truncateFunction · 0.90
isURIFunction · 0.90
infoMethod · 0.80
getArrayMethod · 0.80
missingMethod · 0.80
getStringMethod · 0.80
hasMethod · 0.80

Tested by

no test coverage detected