Moved EPG Matching to API

This commit is contained in:
Dispatcharr 2025-03-18 22:58:19 -05:00
parent 106999d32d
commit c1ece8ef7d
2 changed files with 24 additions and 19 deletions

View file

@ -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}`);
}
}
}

View file

@ -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);