Skip to main content

trim_video_proxy_server 0.1.0 copy "trim_video_proxy_server: ^0.1.0" to clipboard
trim_video_proxy_server: ^0.1.0 copied to clipboard

A lightweight HTTP proxy server for Dart applications. Automatically adds authentication headers to video requests (m3u8 playlists and TS segments). Ideal for video playback scenarios requiring authentication.

example/main.dart

import 'package:trim_video_proxy_server/trim_video_proxy_server.dart';

/// Simple example demonstrating how to use TrimVideoProxyServer
///
/// Run this example:
/// ```bash
/// dart example/main.dart
/// ```

void main() async {
  // Create proxy server instance
  final proxy = TrimVideoProxyServer();

  // Optional: Inject custom logger
  proxy.logger = (message) {
    final timestamp = DateTime.now().toIso8601String();
    print('[$timestamp] $message');
  };

  // Start the server
  print('🚀 Starting proxy server...');
  final port = await proxy.start(port: 3999);
  print('✅ Proxy server started on port $port');
  print('📡 Proxy URL: http://localhost:$port');
  print('');

  // Set proxy configuration
  print('⚙️  Configuring proxy...');
  proxy.setProxyInfo(
    'https://video.example.com',
    'session=abc123; auth_token=xyz789',
  );
  print('✅ Proxy configured');
  print('   Target URL: https://video.example.com');
  print('   Cookie: session=abc123; auth_token=xyz789');
  print('');

  print('📝 Example usage:');
  print('   Original: https://video.example.com/video.m3u8');
  print('   Proxied:  http://localhost:$port/video.m3u8');
  print('');
  print('💡 You can test with curl:');
  print('   curl -X POST http://localhost:$port/proxy/info \\');
  print('     -H "Content-Type: application/json" \\');
  print('     -d \'{"url":"https://new-target.com","cookie":"new=value"}\'');
  print('');
  print('Press Ctrl+C to stop the server');

  // Keep the server running
  // In a real application, you would handle shutdown signals
  // For this example, just wait indefinitely

  // To stop the server gracefully:
  // await proxy.stop();
  // print('🛑 Proxy server stopped');
}
0
likes
150
points
13
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

A lightweight HTTP proxy server for Dart applications. Automatically adds authentication headers to video requests (m3u8 playlists and TS segments). Ideal for video playback scenarios requiring authentication.

Repository (GitHub)
View/report issues
Contributing

Topics

#http #proxy #video #streaming #authentication

License

MIT (license)

More

Packages that depend on trim_video_proxy_server