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

Function editStream

scripts/commands/playlist/update.ts:144–186  ·  view source on GitHub ↗
(issue: Issue)

Source from the content-addressed store, hash-verified

142}
143
144async function editStream(issue: Issue) {
145 const log = createThread(issue, 'streams/edit')
146 log.start()
147
148 const data = issue.data
149
150 const streamUrl = data.getString('stream_url')
151
152 if (!streamUrl) {
153 log.error('The request is missing the "Stream URL"')
154 skippedIssues.add(issue)
155 return
156 }
157
158 const stream: Stream = streams.first((_stream: Stream) => _stream.url === streamUrl)
159 if (!stream) {
160 log.error(`The stream with the URL "${streamUrl}" is already in the playlists`)
161 skippedIssues.add(issue)
162 return
163 }
164
165 cacheData()
166
167 stream.updateWithIssue(data)
168
169 stream.setGuides(apiData.guidesGroupedByStreamId.get(stream.getId()))
170
171 const errors = new Collection<Error>()
172 errors.concat(stream.validate())
173 if (errors.isNotEmpty()) {
174 errors.forEach((err: Error) => {
175 log.error(err.message)
176 })
177 skippedIssues.add(issue)
178 resetData()
179 log.info('All changes have been reverted')
180 return
181 }
182
183 log.info('The stream description has been updated')
184
185 processedIssues.add(issue)
186}
187
188async function addStream(issue: Issue) {
189 const log = createThread(issue, 'streams/add')

Callers 1

processIssuesFunction · 0.85

Calls 10

createThreadFunction · 0.90
cacheDataFunction · 0.85
resetDataFunction · 0.85
startMethod · 0.80
getStringMethod · 0.80
errorMethod · 0.80
updateWithIssueMethod · 0.80
setGuidesMethod · 0.80
validateMethod · 0.80
infoMethod · 0.80

Tested by

no test coverage detected