mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
feat: Implement Xtream IPTV API service, including data fetching, caching, and proxy integration.
This commit is contained in:
1 parent
f5b3457390
commit
8c65e48bbe
3 files changed
+11
-24
No files matched your search
@@ -123,6 +123,7 @@ class ProxyHandler {
|
||||
'User-Agent': 'VLC/3.0.18 LibVLC/3.0.18',
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'identity',
|
||||
'Connection': 'close', // Forced close for better IPTV server compatibility
|
||||
};
|
||||
|
||||
// Forward Range header if present
|
||||
@@ -158,21 +159,7 @@ class ProxyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// Special case for API requests (JSON list of channels etc.)
|
||||
// If it's not a Range request and looks like JSON, read it fully
|
||||
final isJson =
|
||||
response.headers['content-type']?.contains('json') == true;
|
||||
final isRange = request.headers.containsKey('range');
|
||||
|
||||
if (isJson && !isRange) {
|
||||
final bytes = await response.stream.toBytes();
|
||||
return Response(
|
||||
response.statusCode,
|
||||
body: bytes,
|
||||
headers: responseHeaders,
|
||||
);
|
||||
}
|
||||
|
||||
// ALWAYS stream the response for maximum performance and to avoid memory issues with large JSONs
|
||||
return Response(
|
||||
response.statusCode,
|
||||
body: response.stream,
|
||||
|
||||
@@ -19,9 +19,9 @@ enum BufferSize {
|
||||
|
||||
/// Connection timeout presets
|
||||
enum ConnectionTimeout {
|
||||
short, // 30 seconds
|
||||
medium, // 60 seconds
|
||||
long, // 120 seconds
|
||||
short, // 60 seconds
|
||||
medium, // 180 seconds
|
||||
long, // 300 seconds
|
||||
}
|
||||
|
||||
/// EPG cache duration presets
|
||||
@@ -205,11 +205,11 @@ class IptvSettings {
|
||||
int get timeoutSeconds {
|
||||
switch (connectionTimeout) {
|
||||
case ConnectionTimeout.short:
|
||||
return 30;
|
||||
case ConnectionTimeout.medium:
|
||||
return 60;
|
||||
case ConnectionTimeout.medium:
|
||||
return 180;
|
||||
case ConnectionTimeout.long:
|
||||
return 120;
|
||||
return 300;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ class XtreamService {
|
||||
XtreamService() {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
connectTimeout: const Duration(seconds: 60),
|
||||
receiveTimeout: const Duration(seconds: 60),
|
||||
sendTimeout: const Duration(seconds: 60),
|
||||
connectTimeout: const Duration(seconds: 300),
|
||||
receiveTimeout: const Duration(seconds: 300),
|
||||
sendTimeout: const Duration(seconds: 300),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user