Spaces:
Sleeping
Sleeping
aladhefafalquran Claude Sonnet 4.6 commited on
Commit ·
1fe8fb5
1
Parent(s): 35007d7
Add /api/subtitles/debug endpoint to diagnose XML-RPC connectivity
Browse filesHits XML-RPC login + Interstellar search and returns token prefix,
result count, and found languages. Helps diagnose why search returns [].
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
apps/server/src/routes/subtitles.ts
CHANGED
|
@@ -74,6 +74,25 @@ function extractField(xml: string, field: string): string[] {
|
|
| 74 |
// No-op: kept so old client builds don't 404 on /config
|
| 75 |
router.get('/config', (_req, res) => res.json({ provider: 'xmlrpc' }))
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
router.get('/search', async (req, res) => {
|
| 78 |
const { imdb_id, type, languages, season, episode } = req.query as Record<string, string>
|
| 79 |
if (!imdb_id) { res.status(400).json({ error: 'Missing imdb_id' }); return }
|
|
|
|
| 74 |
// No-op: kept so old client builds don't 404 on /config
|
| 75 |
router.get('/config', (_req, res) => res.json({ provider: 'xmlrpc' }))
|
| 76 |
|
| 77 |
+
// Diagnostic endpoint — hit this to check if XML-RPC login works from this server
|
| 78 |
+
router.get('/debug', async (_req, res) => {
|
| 79 |
+
try {
|
| 80 |
+
const tok = await getToken()
|
| 81 |
+
// Quick search for a well-known title
|
| 82 |
+
const resp = await xmlCall('SearchSubtitles',
|
| 83 |
+
`<param><value><string>${tok}</string></value></param>` +
|
| 84 |
+
`<param><value><array><data><value><struct>` +
|
| 85 |
+
`<member><name>sublanguageid</name><value><string>all</string></value></member>` +
|
| 86 |
+
`<member><name>imdbid</name><value><string>0816692</string></value></member>` +
|
| 87 |
+
`</struct></value></data></array></value></param>`)
|
| 88 |
+
const ids = extractField(resp, 'IDSubtitleFile')
|
| 89 |
+
const langs = extractField(resp, 'SubLanguageID')
|
| 90 |
+
res.json({ ok: true, token: tok.slice(0, 8) + '...', resultCount: ids.length, languages: [...new Set(langs)] })
|
| 91 |
+
} catch (err: any) {
|
| 92 |
+
res.status(502).json({ ok: false, error: err?.message })
|
| 93 |
+
}
|
| 94 |
+
})
|
| 95 |
+
|
| 96 |
router.get('/search', async (req, res) => {
|
| 97 |
const { imdb_id, type, languages, season, episode } = req.query as Record<string, string>
|
| 98 |
if (!imdb_id) { res.status(400).json({ error: 'Missing imdb_id' }); return }
|