mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-24 07:28:05 +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',
|
'User-Agent': 'VLC/3.0.18 LibVLC/3.0.18',
|
||||||
'Accept': '*/*',
|
'Accept': '*/*',
|
||||||
'Accept-Encoding': 'identity',
|
'Accept-Encoding': 'identity',
|
||||||
|
'Connection': 'close', // Forced close for better IPTV server compatibility
|
||||||
};
|
};
|
||||||
|
|
||||||
// Forward Range header if present
|
// Forward Range header if present
|
||||||
@@ -158,21 +159,7 @@ class ProxyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case for API requests (JSON list of channels etc.)
|
// ALWAYS stream the response for maximum performance and to avoid memory issues with large JSONs
|
||||||
// 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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
response.statusCode,
|
response.statusCode,
|
||||||
body: response.stream,
|
body: response.stream,
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ enum BufferSize {
|
|||||||
|
|
||||||
/// Connection timeout presets
|
/// Connection timeout presets
|
||||||
enum ConnectionTimeout {
|
enum ConnectionTimeout {
|
||||||
short, // 30 seconds
|
short, // 60 seconds
|
||||||
medium, // 60 seconds
|
medium, // 180 seconds
|
||||||
long, // 120 seconds
|
long, // 300 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// EPG cache duration presets
|
/// EPG cache duration presets
|
||||||
@@ -205,11 +205,11 @@ class IptvSettings {
|
|||||||
int get timeoutSeconds {
|
int get timeoutSeconds {
|
||||||
switch (connectionTimeout) {
|
switch (connectionTimeout) {
|
||||||
case ConnectionTimeout.short:
|
case ConnectionTimeout.short:
|
||||||
return 30;
|
|
||||||
case ConnectionTimeout.medium:
|
|
||||||
return 60;
|
return 60;
|
||||||
|
case ConnectionTimeout.medium:
|
||||||
|
return 180;
|
||||||
case ConnectionTimeout.long:
|
case ConnectionTimeout.long:
|
||||||
return 120;
|
return 300;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class XtreamService {
|
|||||||
XtreamService() {
|
XtreamService() {
|
||||||
_dio = Dio(
|
_dio = Dio(
|
||||||
BaseOptions(
|
BaseOptions(
|
||||||
connectTimeout: const Duration(seconds: 60),
|
connectTimeout: const Duration(seconds: 300),
|
||||||
receiveTimeout: const Duration(seconds: 60),
|
receiveTimeout: const Duration(seconds: 300),
|
||||||
sendTimeout: const Duration(seconds: 60),
|
sendTimeout: const Duration(seconds: 300),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user