fixed match epg, centralized to api

This commit is contained in:
dekzter 2025-03-19 07:15:31 -04:00
parent 8d20fb8fe0
commit 8ca91bd897
2 changed files with 19 additions and 14 deletions

View file

@ -856,4 +856,17 @@ export default class API {
const retval = await response.json();
return retval;
}
static async matchEpg() {
const response = await fetch(`${host}/api/channels/channels/match-epg/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${await API.getAuthToken()}`,
},
});
const retval = await response.json();
return retval;
}
}

View file

@ -376,22 +376,14 @@ const ChannelsTable = ({}) => {
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()}`,
},
});
await API.matchEpg();
if (resp.ok) {
showAlert('EPG matching task started!');
} else {
const text = await resp.text();
showAlert(`Failed to start EPG matching: ${text}`);
}
notifications.show({
title: 'EPG matching task started!',
// style: { width: '200px', left: '200px' },
});
} catch (err) {
showAlert(`Error: ${err.message}`);
notifications.show(`Error: ${err.message}`);
}
};