Files
tmdb-addon/test-proxy.js
T
mrcanelas f1c1071d09 feat: add proxy support to bypass TMDB regional blocks (India)
- Add HTTP client with proxy support for TMDB API calls
- Create TMDBClient wrapper extending moviedb-promise with proxy integration
- Update all TMDB API modules to use new proxy-enabled client
- Add proxy configuration via environment variables:
  * TMDB_PROXY_ENABLED - Enable/disable proxy
  * TMDB_PROXY_HOST - Proxy host address
  * TMDB_PROXY_PORT - Proxy port
  * TMDB_PROXY_PROTOCOL - Proxy protocol (http, https, socks4, socks5)
  * TMDB_PROXY_AUTH - Enable proxy authentication
  * TMDB_PROXY_USERNAME - Proxy username
  * TMDB_PROXY_PASSWORD - Proxy password

- Add proxy status endpoint (/api/proxy/status) for monitoring
- Create test script (npm run test:proxy) for proxy verification
- Add comprehensive documentation:
  * PROXY_SETUP.md - User guide for proxy configuration
  * docs/proxy-implementation.md - Technical implementation details (English)
  * env.example - Environment variables template (English)
  * docker-compose.proxy.yml - Docker setup with Cloudflare WARP

- Update README.md with proxy support section
- Add logging when proxy is used for TMDB requests
- Support selective proxy usage (only TMDB domains use proxy)
- Maintain backward compatibility with existing configurations
- Translate all Portuguese text to English for international consistency

This resolves the issue where TMDB is blocked at network level in India,
allowing users to host the addon on Indian VPS providers while accessing
TMDB through a proxy. Based on similar implementation in AIOStreams.

Closes: Optional proxy for TMDB API calls (workaround for Indian VPS block) #1208
2025-08-13 15:38:30 -03:00

52 lines
1.6 KiB
JavaScript

#!/usr/bin/env node
/**
* Test script to verify proxy configuration
* Usage: node test-proxy.js
*/
require('dotenv').config();
const { testProxy, PROXY_CONFIG } = require('./addon/utils/httpClient');
async function runTests() {
console.log('🔍 Testing proxy configuration for TMDB Addon\n');
// Show current configuration
console.log('📋 Current configuration:');
console.log(` Enabled: ${PROXY_CONFIG.enabled}`);
console.log(` Host: ${PROXY_CONFIG.host}`);
console.log(` Port: ${PROXY_CONFIG.port}`);
console.log(` Protocol: ${PROXY_CONFIG.protocol}`);
console.log(` Authentication: ${PROXY_CONFIG.auth ? 'Yes' : 'No'}`);
console.log('');
if (!PROXY_CONFIG.enabled) {
console.log('⚠️ Proxy is not enabled');
console.log(' To enable, configure TMDB_PROXY_ENABLED=true');
return;
}
// Test connection
console.log('🧪 Testing proxy connection...');
try {
const isWorking = await testProxy();
if (isWorking) {
console.log('✅ Proxy working correctly!');
console.log(' The addon should be able to access TMDB through the proxy.');
} else {
console.log('❌ Proxy is not working');
console.log(' Check:');
console.log(' - If the proxy is running');
console.log(' - If the settings are correct');
console.log(' - If the proxy supports HTTPS');
}
} catch (error) {
console.log('❌ Error testing proxy:', error.message);
}
console.log('\n📖 For more information, see PROXY_SETUP.md');
}
// Run tests
runTests().catch(console.error);