feat: add CoopCredits Solana media rewards ecosystem
Add complete token system with Plex/Tautulli/Overseer integration: - Anchor program for SPL token mint/burn/transfer - Express backend with OAuth, webhooks, Solana integration - Next.js frontend with dashboard, admin panel, wallet management - Docker deployment for 172.20.1.0/24 infrastructure - Production configs with SSL, Nginx, health monitoring Tautulli webhooks auto-mint on watch events. Overseer integration burns for content requests.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import { Router } from 'express';
|
||||
import axios from 'axios';
|
||||
import { authenticate, AuthenticatedRequest, requireAdmin } from '../middleware/auth';
|
||||
import { asyncHandler } from '../middleware/errorHandler';
|
||||
|
||||
const router = Router();
|
||||
|
||||
const TAUTULLI_URL = process.env.TAUTULLI_URL || '';
|
||||
const TAUTULLI_API_KEY = process.env.TAUTULLI_API_KEY || '';
|
||||
|
||||
// Get Tautulli connection status
|
||||
router.get('/status',
|
||||
authenticate,
|
||||
requireAdmin,
|
||||
asyncHandler(async (_req: AuthenticatedRequest, res) => {
|
||||
try {
|
||||
const response = await axios.get(`${TAUTULLI_URL}/api/v2`, {
|
||||
params: {
|
||||
apikey: TAUTULLI_API_KEY,
|
||||
cmd: 'get_server_info'
|
||||
}
|
||||
});
|
||||
|
||||
res.json({
|
||||
connected: true,
|
||||
data: response.data.response.data
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
connected: false,
|
||||
error: 'Failed to connect to Tautulli'
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Get watch statistics
|
||||
router.get('/stats',
|
||||
authenticate,
|
||||
requireAdmin,
|
||||
asyncHandler(async (_req: AuthenticatedRequest, res) => {
|
||||
try {
|
||||
const response = await axios.get(`${TAUTULLI_URL}/api/v2`, {
|
||||
params: {
|
||||
apikey: TAUTULLI_API_KEY,
|
||||
cmd: 'get_libraries'
|
||||
}
|
||||
});
|
||||
|
||||
res.json(response.data.response.data);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: 'Failed to fetch stats' });
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
// Get webhook configuration guide
|
||||
router.get('/webhook-config',
|
||||
authenticate,
|
||||
requireAdmin,
|
||||
asyncHandler(async (_req: AuthenticatedRequest, res) => {
|
||||
const webhookUrl = `${process.env.API_URL}/webhooks/tautulli`;
|
||||
|
||||
res.json({
|
||||
webhookUrl,
|
||||
instructions: [
|
||||
'1. Open Tautulli Settings',
|
||||
'2. Go to Notification Agents',
|
||||
'3. Add Webhook',
|
||||
'4. Set Webhook URL to the URL above',
|
||||
'5. Set Webhook Method to POST',
|
||||
'6. Configure triggers for "Watched" events',
|
||||
'7. Set payload to JSON format'
|
||||
],
|
||||
payloadTemplate: {
|
||||
action: 'watched',
|
||||
user_id: '{user_id}',
|
||||
username: '{username}',
|
||||
rating_key: '{rating_key}',
|
||||
session_key: '{session_key}',
|
||||
media_type: '{media_type}',
|
||||
title: '{title}',
|
||||
grandparent_title: '{grandparent_title}',
|
||||
started: '{started}',
|
||||
stopped: '{stopped}',
|
||||
percent_complete: '{percent_complete}',
|
||||
is_new: '{is_new}'
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
export { router as tautulliRouter };
|
||||
Reference in New Issue
Block a user