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/others.dart'; import 'package:mangayomi/utils/extensions/string_extensions.dart'; class StreamlareExtractor { final InterceptedClient client = MClient.init(reqcopyWith: {'useDartHttpClient': true}); Future> videosFromUrl(String url, {String prefix = "", String suffix = ""}) async { try { final id = url.split('/').last; final playlistResponse = await client.post( Uri.parse('https://slwatch.co/api/video/stream/get'), headers: {'Content-Type': 'application/json'}, body: '{"id":"$id"}', ); final playlist = playlistResponse.body; final type = playlist.substringAfter('"type":"').substringBefore('"'); if (type == 'hls') { final masterPlaylistUrl = playlist.substringAfter('"file":"').substringBefore('"').replaceAll(r'\/', '/'); final masterPlaylistResponse = await client.get(Uri.parse(masterPlaylistUrl)); final masterPlaylist = masterPlaylistResponse.body; const separator = '#EXT-X-STREAM-INF'; return masterPlaylist.substringAfter(separator).split(separator).map((value) { final quality = '${value.substringAfter('RESOLUTION=').substringAfter('x').substringBefore(',')}p'; final videoUrl = value.substringAfter('\n').substringBefore('\n').let((urlPart) { return !urlPart.startsWith('http') ? masterPlaylistUrl.substringBefore('master.m3u8') + urlPart : urlPart; }); return Video(videoUrl, _buildQuality(quality, prefix, suffix), videoUrl); }).toList(); } else { const separator = '"label":"'; List