- remove cronet_http & cupertino_http - use rhttp package as default http client - fix #198 #200 crashes on multiple downloads - fix #162 #102 unable to download with forbidden characters in the name (as it is fixed this can cause reading problems concerning chapters downloaded before this version) - now supports all features on all platforms such as VPNs and HTTP proxies thanks to rhttp package
41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import 'package:http_interceptor/http_interceptor.dart';
|
|
import 'package:mangayomi/models/video.dart';
|
|
import 'package:mangayomi/services/http/m_client.dart';
|
|
import 'package:mangayomi/utils/extensions/string_extensions.dart';
|
|
|
|
class SibnetExtractor {
|
|
final InterceptedClient client =
|
|
MClient.init(reqcopyWith: {'useDartHttpClient': true});
|
|
|
|
Future<List<Video>> videosFromUrl(String url, {String prefix = ""}) async {
|
|
List<Video> videoList = [];
|
|
try {
|
|
final response = await client.get(Uri.parse(url));
|
|
if (response.statusCode != 200) {
|
|
return [];
|
|
}
|
|
|
|
String script = response.body;
|
|
String slug = script
|
|
.substringAfter("player.src")
|
|
.substringAfter("src:")
|
|
.substringAfter("\"")
|
|
.substringBefore("\"");
|
|
|
|
String videoUrl =
|
|
slug.contains("http") ? slug : "https://${Uri.parse(url).host}$slug";
|
|
|
|
Map<String, String> videoHeaders = {
|
|
"Referer": url,
|
|
};
|
|
|
|
videoList.add(
|
|
Video(videoUrl, "$prefix - Sibnet", videoUrl, headers: videoHeaders),
|
|
);
|
|
|
|
return videoList;
|
|
} catch (_) {
|
|
return [];
|
|
}
|
|
}
|
|
}
|