mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-28 12:36:42 +00:00
Moved EPG Matching to API
This commit is contained in:
parent
106999d32d
commit
c1ece8ef7d
2 changed files with 24 additions and 19 deletions
|
|
@ -856,4 +856,24 @@ export default class API {
|
|||
const retval = await response.json();
|
||||
return retval;
|
||||
}
|
||||
|
||||
static async matchEpg() {
|
||||
try {
|
||||
const response = await fetch(`${host}/api/channels/channels/match-epg/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${await API.getAuthToken()}`,
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Failed to start EPG matching: ${errorText}`);
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
throw new Error(`Error starting EPG matching: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,31 +370,16 @@ const ChannelsTable = ({}) => {
|
|||
}
|
||||
};
|
||||
|
||||
// ─────────────────────────────────────────────────────────
|
||||
// The new "Match EPG" button logic
|
||||
// ─────────────────────────────────────────────────────────
|
||||
const matchEpg = async () => {
|
||||
try {
|
||||
// Hit our new endpoint that triggers the fuzzy matching Celery task
|
||||
const resp = await fetch('/api/channels/channels/match-epg/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${await API.getAuthToken()}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (resp.ok) {
|
||||
showAlert('EPG matching task started!');
|
||||
} else {
|
||||
const text = await resp.text();
|
||||
showAlert(`Failed to start EPG matching: ${text}`);
|
||||
}
|
||||
await API.matchEpg();
|
||||
showAlert('EPG matching task started!');
|
||||
} catch (err) {
|
||||
showAlert(`Error: ${err.message}`);
|
||||
showAlert(err.message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const closeChannelForm = () => {
|
||||
setChannel(null);
|
||||
setChannelModalOpen(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue