refactor: remove unused

This commit is contained in:
antebrl
2024-12-15 21:03:07 +00:00
parent 65375b585a
commit f931e93355
3 changed files with 7 additions and 55 deletions

View File

@@ -40,39 +40,4 @@ module.exports = {
res.status(500).json({ error: error.message });
}
},
addPlaylist(req, res) {
try {
const { playlistUrl } = req.body;
const playlistContent = fs.readFileSync(playlistUrl, 'utf8');
const parser = new m3uParser.Parser();
parser.push(playlistContent);
parser.end();
const parsedPlaylist = parser.manifest;
const channels = parsedPlaylist.segments.map(segment => ({
name: segment.title,
url: segment.uri,
avatar: '',
restream: false,
headersJson: '[]'
}));
channels.forEach(channel => {
ChannelService.addChannel(channel.name, channel.url, channel.avatar, channel.restream, channel.headersJson);
});
res.status(201).json({ message: 'Playlist added successfully' });
} catch (error) {
res.status(500).json({ error: error.message });
}
}
};
const express = require('express');
const router = express.Router();
const ChannelController = require('../controllers/ChannelController');
router.post('/playlist', ChannelController.addPlaylist);
module.exports = router;
};

View File

@@ -12,6 +12,12 @@ class ChannelService {
{ "key": "Referer", "value": "https://cookiewebplay.xyz/" }
];
const streamedSuHeaders = [
{ "key": "Origin", "value": "https://embedme.top" },
{ "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" },
{ "key": "Referer", "value": "https://embedme.top/" }
];
this.channels = [
//Some Test-channels to get started
new Channel('Das Erste', process.env.DEFAULT_CHANNEL_URL, "https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Das_Erste-Logo_klein.svg/768px-Das_Erste-Logo_klein.svg.png", false, []),

View File

@@ -36,25 +36,6 @@ const apiService = {
throw error;
}
},
async uploadPlaylist(data: FormData | { playlistUrl: string }): Promise<void> {
try {
const options: RequestInit = {
method: 'POST',
body: data instanceof FormData ? data : JSON.stringify(data),
headers: data instanceof FormData ? {} : { 'Content-Type': 'application/json' },
};
const response = await fetch(`${API_BASE_URL}/api/playlist`, options);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
} catch (error) {
console.error('Error uploading playlist:', error);
throw error;
}
},
};
export default apiService;