refactor: use Xtream API endpoints for M3U in Manage Content

This commit is contained in:
Trevor Mears
2026-01-12 00:07:46 -08:00
parent 04fcabda84
commit c589b00e57
+8 -13
View File
@@ -507,8 +507,8 @@ class SourceManager {
let categoryMap = {}; let categoryMap = {};
if (source.type === 'xtream') { if (source.type === 'xtream' || source.type === 'm3u') {
// Run sequentially to avoid overwhelming the provider // Use unified Xtream API endpoints - backend supports both source types
// Use includeHidden to show ALL items in the content manager // Use includeHidden to show ALL items in the content manager
const categories = await API.proxy.xtream.liveCategories(sourceId, { includeHidden: true }); const categories = await API.proxy.xtream.liveCategories(sourceId, { includeHidden: true });
const streams = await API.proxy.xtream.liveStreams(sourceId, null, { includeHidden: true }); const streams = await API.proxy.xtream.liveStreams(sourceId, null, { includeHidden: true });
@@ -517,9 +517,6 @@ class SourceManager {
categories.forEach(cat => { categories.forEach(cat => {
categoryMap[cat.category_id] = cat.category_name; categoryMap[cat.category_id] = cat.category_name;
}); });
} else if (source.type === 'm3u') {
const m3uData = await API.proxy.m3u.get(sourceId, { includeHidden: true });
channels = m3uData.channels || [];
} }
// Get currently hidden items // Get currently hidden items
@@ -531,16 +528,14 @@ class SourceManager {
const groupMap = {}; // key: categoryId, value: { name, categoryId, items } const groupMap = {}; // key: categoryId, value: { name, categoryId, items }
channels.forEach(ch => { channels.forEach(ch => {
let groupName = 'Uncategorized'; let groupName = 'Uncategorized';
let categoryId = null; let categoryId = ch.category_id;
if (source.type === 'xtream') {
categoryId = ch.category_id; // Look up category name from map (works for both Xtream and M3U now)
if (categoryId && categoryMap[categoryId]) { if (categoryId && categoryMap[categoryId]) {
groupName = categoryMap[categoryId]; groupName = categoryMap[categoryId];
} } else if (categoryId) {
} else { // M3U uses category_id as the name itself
// For M3U, category_id might be the group name itself groupName = categoryId;
groupName = ch.category_name || ch.groupTitle || 'Uncategorized';
categoryId = groupName; // M3U uses name as ID
} }
const groupKey = categoryId || groupName; const groupKey = categoryId || groupName;