42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
const express = require('express');
|
|
const axios = require('axios');
|
|
const router = express.Router();
|
|
|
|
const SABNZBD_URL = process.env.SABNZBD_URL;
|
|
const SABNZBD_API_KEY = process.env.SABNZBD_API_KEY;
|
|
|
|
// Get current queue
|
|
router.get('/queue', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SABNZBD_URL}/api`, {
|
|
params: {
|
|
mode: 'queue',
|
|
apikey: SABNZBD_API_KEY,
|
|
output: 'json'
|
|
}
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch SABnzbd queue', details: error.message });
|
|
}
|
|
});
|
|
|
|
// Get history
|
|
router.get('/history', async (req, res) => {
|
|
try {
|
|
const response = await axios.get(`${SABNZBD_URL}/api`, {
|
|
params: {
|
|
mode: 'history',
|
|
apikey: SABNZBD_API_KEY,
|
|
output: 'json',
|
|
limit: req.query.limit || 50
|
|
}
|
|
});
|
|
res.json(response.data);
|
|
} catch (error) {
|
|
res.status(500).json({ error: 'Failed to fetch SABnzbd history', details: error.message });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|