SRF Sport Recordings
-Browse upcoming sport livestreams and schedule recordings.
+ - - + if (active.length === 0) { + container.innerHTML = 'No scheduled or active recordings.
'; + return; + } + + var stateMap = { + 'Scheduled': {label: 'Scheduled', cls: 'status-scheduled'}, + 'WaitingForStream': {label: 'Waiting', cls: 'status-waiting'}, + 'Recording': {label: 'Recording', cls: 'status-recording'}, + 0: {label: 'Scheduled', cls: 'status-scheduled'}, + 1: {label: 'Waiting', cls: 'status-waiting'}, + 2: {label: 'Recording', cls: 'status-recording'} + }; + + var html = '| Title | Status | Start | Action |
|---|---|---|---|
| ' + (r.title || 'Unknown') + ' | '; + html += '' + st.label + ' | '; + html += '' + SRFRec.formatDate(r.validFrom) + ' | '; + html += ''; + if (r.state === 2 || r.state === 'Recording') { + html += ''; + } else { + html += ''; + } + html += ' |
Error: ' + err.message + '
'; + }); + }, + + loadCompletedRecordings: function() { + var container = document.getElementById('srfrecCompletedRecordingsContainer'); + container.innerHTML = 'Loading...
'; + + fetch(this.serverUrl + '/Plugins/SRFPlay/Recording/Completed', { headers: this.getHeaders() }) + .then(function(r) { return r.json(); }) + .then(function(recordings) { + if (!recordings || recordings.length === 0) { + container.innerHTML = 'No completed recordings.
'; + return; + } + + var html = '| Title | Recorded | Size | Action |
|---|---|---|---|
| ' + (r.title || 'Unknown') + ' | '; + html += '' + SRFRec.formatDate(r.recordingStartedAt) + ' | '; + html += '' + SRFRec.formatSize(r.fileSizeBytes) + ' | '; + html += ''; + html += ' |
Error: ' + err.message + '
'; + }); + }, + + stopRecording: function(id) { + var self = this; + fetch(this.serverUrl + '/Plugins/SRFPlay/Recording/Active/' + id + '/Stop', { + method: 'POST', + headers: this.getHeaders() + }).then(function() { self.loadRecordings(); }); + }, + + cancelRecording: function(id) { + var self = this; + fetch(this.serverUrl + '/Plugins/SRFPlay/Recording/Schedule/' + id, { + method: 'DELETE', + headers: this.getHeaders() + }).then(function() { self.loadRecordings(); }); + }, + + deleteRecording: function(id) { + if (!confirm('Delete this recording and its file?')) return; + var self = this; + fetch(this.serverUrl + '/Plugins/SRFPlay/Recording/Completed/' + id + '?deleteFile=true', { + method: 'DELETE', + headers: this.getHeaders() + }).then(function() { self.loadRecordings(); }); + } + }; + + (function() { + var page = document.querySelector('#SRFPlayRecordingsPage'); + if (page && typeof page.addEventListener === 'function' && typeof ApiClient !== 'undefined') { + // Inside the Jellyfin dashboard: defer to the page lifecycle so we + // never run during the config page's view and never hijack routing. + page.addEventListener('pageshow', function() { SRFRec.init(); }); + } else { + // Standalone (e.g. TV/browser): initialise immediately. + SRFRec.init(); + } + })(); + +