mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-25 19:14:00 +00:00
Error handling for m3u profile.
This commit is contained in:
parent
88c27ac8ae
commit
72ed1ff4f4
1 changed files with 31 additions and 16 deletions
|
|
@ -28,26 +28,41 @@ const RegexFormAndView = ({ profile = null, m3u, isOpen, onClose }) => {
|
|||
|
||||
useEffect(() => {
|
||||
async function fetchStreamUrl() {
|
||||
const params = new URLSearchParams();
|
||||
params.append('page', 1);
|
||||
params.append('page_size', 1);
|
||||
params.append('m3u_account', m3u.id);
|
||||
const response = await API.queryStreams(params);
|
||||
setStreamUrl(response.results[0].url);
|
||||
try {
|
||||
if (!m3u?.id) return;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('page', 1);
|
||||
params.append('page_size', 1);
|
||||
params.append('m3u_account', m3u.id);
|
||||
const response = await API.queryStreams(params);
|
||||
|
||||
if (response?.results?.length > 0) {
|
||||
setStreamUrl(response.results[0].url);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching stream URL:', error);
|
||||
}
|
||||
}
|
||||
fetchStreamUrl();
|
||||
}, []);
|
||||
}, [m3u]);
|
||||
|
||||
useEffect(() => {
|
||||
sendMessage(
|
||||
JSON.stringify({
|
||||
type: 'm3u_profile_test',
|
||||
url: streamUrl,
|
||||
search: debouncedPatterns['search'] || '',
|
||||
replace: debouncedPatterns['replace'] || '',
|
||||
})
|
||||
);
|
||||
}, [m3u, debouncedPatterns, streamUrl]);
|
||||
if (!websocketReady || !streamUrl) return;
|
||||
|
||||
try {
|
||||
sendMessage(
|
||||
JSON.stringify({
|
||||
type: 'm3u_profile_test',
|
||||
url: streamUrl,
|
||||
search: debouncedPatterns['search'] || '',
|
||||
replace: debouncedPatterns['replace'] || '',
|
||||
})
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error sending WebSocket message:', error);
|
||||
}
|
||||
}, [websocketReady, m3u, debouncedPatterns, streamUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
const handler = setTimeout(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue