diff --git a/.github/ISSUE_TEMPLATE/--broken-stream.yml b/.github/ISSUE_TEMPLATE/--broken-stream.yml index bbfde78b8..12ed63a5b 100644 --- a/.github/ISSUE_TEMPLATE/--broken-stream.yml +++ b/.github/ISSUE_TEMPLATE/--broken-stream.yml @@ -9,10 +9,10 @@ body: value: | Please fill out the issue template as much as you can so we could efficiently process your request - - type: input + - type: textarea attributes: - label: Broken Link - description: Please specify the broken link from a playlist + label: Broken Links + description: Please specify the broken links from the playlist (one per line) placeholder: 'https://lnc-kdfw-fox-aws.tubi.video/index.m3u8' validations: required: true diff --git a/scripts/commands/playlist/update.ts b/scripts/commands/playlist/update.ts index 97e461ee7..4a869f33b 100644 --- a/scripts/commands/playlist/update.ts +++ b/scripts/commands/playlist/update.ts @@ -54,13 +54,20 @@ async function removeStreams(loader: IssueLoader) { const issues = await loader.load({ labels: ['streams:remove', 'approved'] }) issues.forEach((issue: Issue) => { const data = issue.data - if (data.missing('stream_url')) return + if (data.missing('broken_links')) return - const found: Stream = streams.first((_stream: Stream) => _stream.url === data.get('stream_url')) - if (found) { - found.removed = true - processedIssues.add(issue.number) - } + const brokenLinks = data.get('broken_links').split(/\r?\n/).filter(Boolean) + + let changed = false + brokenLinks.forEach(link => { + const found: Stream = streams.first((_stream: Stream) => _stream.url === link.trim()) + if (found) { + found.removed = true + changed = true + } + }) + + if (changed) processedIssues.add(issue.number) }) } diff --git a/scripts/commands/report/create.ts b/scripts/commands/report/create.ts index 030a10d60..74b73f610 100644 --- a/scripts/commands/report/create.ts +++ b/scripts/commands/report/create.ts @@ -82,7 +82,7 @@ async function main() { logger.info('checking broken streams reports...') const brokenStreamReports = await loader.load({ labels: ['broken stream'] }) brokenStreamReports.forEach((issue: Issue) => { - const streamUrl = issue.data.get('stream_url') || undefined + const brokenLinks = issue.data.get('broken_links') || undefined const result = new Dictionary({ issueNumber: issue.number, @@ -91,8 +91,8 @@ async function main() { status: undefined }) - if (!streamUrl) result.set('status', 'missing_link') - else if (groupedStreams.missing(streamUrl)) result.set('status', 'invalid_link') + if (!brokenLinks) result.set('status', 'missing_link') + else if (groupedStreams.missing(brokenLinks)) result.set('status', 'invalid_link') else result.set('status', 'pending') report.add(result.data()) diff --git a/scripts/core/issueParser.ts b/scripts/core/issueParser.ts index def939cd2..6d4658985 100644 --- a/scripts/core/issueParser.ts +++ b/scripts/core/issueParser.ts @@ -7,7 +7,8 @@ const FIELDS = new Dictionary({ 'Stream URL': 'stream_url', 'Stream URL (optional)': 'stream_url', 'Stream URL (required)': 'stream_url', - 'Broken Link': 'stream_url', + 'Broken Link': 'broken_links', + 'Broken Links': 'broken_links', Label: 'label', Quality: 'quality', Timeshift: 'timeshift', @@ -27,8 +28,10 @@ export class IssueParser { const data = new Dictionary() fields.forEach((field: string) => { - let [_label, , _value] = field.split(/\r?\n/) + let parsed = field.split(/\r?\n/).filter(Boolean) + let _label = parsed.shift() _label = _label ? _label.trim() : '' + let _value = parsed.join('\r\n') _value = _value ? _value.trim() : '' if (!_label || !_value) return data diff --git a/tests/__data__/input/issues/streams_remove_approved.js b/tests/__data__/input/issues/streams_remove_approved.js index c65d76b68..72b09aeaa 100644 --- a/tests/__data__/input/issues/streams_remove_approved.js +++ b/tests/__data__/input/issues/streams_remove_approved.js @@ -70,7 +70,7 @@ module.exports = [ closed_at: null, author_association: 'CONTRIBUTOR', active_lock_reason: null, - body: '### Stream URL\n\nhttps://ythls.onrender.com/channel/UC40TUSUx490U5uR1lZt3Ajg.m3u8\n\n### Reason\n\nNot loading\n\n### Notes (optional)\n\nOne link (VTV.br) is misspelled.\n\n### Contributing Guide\n\n- [x] I have read [Contributing Guide](https://github.com/iptv-org/iptv/blob/master/CONTRIBUTING.md)', + body: '### Broken Link\n\nhttps://ythls.onrender.com/channel/UC40TUSUx490U5uR1lZt3Ajg.m3u8\n\n### Reason\n\nNot loading\n\n### Notes (optional)\n\nOne link (VTV.br) is misspelled.\n\n### Contributing Guide\n\n- [x] I have read [Contributing Guide](https://github.com/iptv-org/iptv/blob/master/CONTRIBUTING.md)', reactions: { url: 'https://api.github.com/repos/iptv-org/iptv/issues/14151/reactions', total_count: 0, @@ -97,7 +97,7 @@ module.exports = [ id: 1881649602, node_id: 'I_kwDOCWUK8M5wJ7HC', number: 14140, - title: 'Broken: RIK HD Cyprus', + title: 'Broken: Cyprus Channels', user: { login: 'ROBGagn', id: 124619576, @@ -176,7 +176,7 @@ module.exports = [ closed_at: null, author_association: 'NONE', active_lock_reason: null, - body: '### Broken Link\n\nhttp://l6.cloudskep.com/rikcy/rikhd/playlist.m3u8\n\n### What happened to the stream?\n\nNot loading\n\n### Possible Replacement (optional)\n\nhttp://l6.cloudskep.com/rikcy/rikhd/playlist2.m3u8\n\n### Notes (optional)\n\nToken needed...\r\nSame issue with RIK 1 and 2. May happen in the future with ANT1 Cyprus, Sigma and Omega.\n\n### Contributing Guide\n\n- [X] I have read [Contributing Guide](https://github.com/iptv-org/iptv/blob/master/CONTRIBUTING.md)', + body: '### Broken Links\n\nhttp://l6.cloudskep.com/rikcy/rikhd/playlist.m3u8\r\n\r\nhttp://l6.cloudskep.com/rikcy/rik2/playlist.m3u8\n\n### What happened to the stream?\n\nNot loading\n\n### Possible Replacement (optional)\n\nhttp://l6.cloudskep.com/rikcy/rikhd/playlist2.m3u8\n\n### Notes (optional)\n\nToken needed...\r\nSame issue with RIK 1 and 2. May happen in the future with ANT1 Cyprus, Sigma and Omega.\n\n### Contributing Guide\n\n- [X] I have read [Contributing Guide](https://github.com/iptv-org/iptv/blob/master/CONTRIBUTING.md)', reactions: { url: 'https://api.github.com/repos/iptv-org/iptv/issues/14140/reactions', total_count: 0, @@ -193,103 +193,6 @@ module.exports = [ performed_via_github_app: null, state_reason: null }, - { - url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139', - repository_url: 'https://api.github.com/repos/iptv-org/iptv', - labels_url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139/labels{/name}', - comments_url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139/comments', - events_url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139/events', - html_url: 'https://github.com/iptv-org/iptv/issues/14139', - id: 1881648047, - node_id: 'I_kwDOCWUK8M5wJ6uv', - number: 14139, - title: 'Broken: RIK2 Cyprus', - user: { - login: 'ROBGagn', - id: 124619576, - node_id: 'U_kgDOB22LOA', - avatar_url: 'https://avatars.githubusercontent.com/u/124619576?v=4', - gravatar_id: '', - url: 'https://api.github.com/users/ROBGagn', - html_url: 'https://github.com/ROBGagn', - followers_url: 'https://api.github.com/users/ROBGagn/followers', - following_url: 'https://api.github.com/users/ROBGagn/following{/other_user}', - gists_url: 'https://api.github.com/users/ROBGagn/gists{/gist_id}', - starred_url: 'https://api.github.com/users/ROBGagn/starred{/owner}{/repo}', - subscriptions_url: 'https://api.github.com/users/ROBGagn/subscriptions', - organizations_url: 'https://api.github.com/users/ROBGagn/orgs', - repos_url: 'https://api.github.com/users/ROBGagn/repos', - events_url: 'https://api.github.com/users/ROBGagn/events{/privacy}', - received_events_url: 'https://api.github.com/users/ROBGagn/received_events', - type: 'User', - site_admin: false - }, - labels: [ - { - id: 1707513547, - node_id: 'MDU6TGFiZWwxNzA3NTEzNTQ3', - url: 'https://api.github.com/repos/iptv-org/iptv/labels/broken%20stream', - name: 'broken stream', - color: 'FBCA04', - default: false, - description: 'Stream is not working properly' - }, - { - id: 3241837512, - node_id: 'MDU6TGFiZWwzMjQxODM3NTEy', - url: 'https://api.github.com/repos/iptv-org/iptv/labels/CY', - name: 'CY', - color: '90FA7B', - default: false, - description: 'Cyprus' - }, - { - id: 5923498886, - node_id: 'LA_kwDOCWUK8M8AAAABYRFrhg', - url: 'https://api.github.com/repos/iptv-org/iptv/labels/approved', - name: 'approved', - color: '85ddde', - default: false, - description: '' - }, - { - id: 5932506810, - node_id: 'LA_kwDOCWUK8M8AAAABYZreug', - url: 'https://api.github.com/repos/iptv-org/iptv/labels/streams:remove', - name: 'streams:remove', - color: '5373a2', - default: false, - description: '' - } - ], - state: 'open', - locked: false, - assignee: null, - assignees: [], - milestone: null, - comments: 0, - created_at: '2023-09-05T10:08:08Z', - updated_at: '2023-09-07T00:50:06Z', - closed_at: null, - author_association: 'NONE', - active_lock_reason: null, - body: '### Broken Link\n\nhttp://l6.cloudskep.com/rikcy/rik2/playlist.m3u8\n\n### What happened to the stream?\n\nNot loading\n\n### Possible Replacement (optional)\n\n_No response_\n\n### Notes (optional)\n\nToken needed...\r\nSame issue with RIK 1 and HD. May happen in the future with ANT1 Cyprus, Sigma and Omega.\n\n### Contributing Guide\n\n- [X] I have read [Contributing Guide](https://github.com/iptv-org/iptv/blob/master/CONTRIBUTING.md)', - reactions: { - url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139/reactions', - total_count: 0, - '+1': 0, - '-1': 0, - laugh: 0, - hooray: 0, - confused: 0, - heart: 0, - rocket: 0, - eyes: 0 - }, - timeline_url: 'https://api.github.com/repos/iptv-org/iptv/issues/14139/timeline', - performed_via_github_app: null, - state_reason: null - }, { url: 'https://api.github.com/repos/iptv-org/iptv/issues/14138', repository_url: 'https://api.github.com/repos/iptv-org/iptv', diff --git a/tests/commands/playlist/update.test.ts b/tests/commands/playlist/update.test.ts index d607e7458..14bd8a119 100644 --- a/tests/commands/playlist/update.test.ts +++ b/tests/commands/playlist/update.test.ts @@ -25,9 +25,7 @@ it('can format playlists', () => { ) }) - expect(stdout).toBe( - 'OUTPUT=closes #14151, closes #14140, closes #14139, closes #14110, closes #14178\n' - ) + expect(stdout).toBe('OUTPUT=closes #14151, closes #14140, closes #14110, closes #14178\n') }) function content(filepath: string) {