refactor: remove unused
This commit is contained in:
@@ -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;
|
||||
};
|
||||
@@ -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, []),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user