Skip to content

Commit 809b75e

Browse files
committed
chore: update extractors
1 parent 53d3611 commit 809b75e

18 files changed

+605
-439
lines changed

lib/Api/Anilist/ListEditor.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
8383
fontSize: 16,
8484
fontWeight: FontWeight.w700,
8585
);
86-
const fieldPadding = EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0);
86+
const fieldPadding = EdgeInsets.symmetric(horizontal: 24.0, vertical: 8.0);
8787
var theme = Theme.of(context).colorScheme;
8888
return CustomBottomDialog(
8989
title: "List Editor",
@@ -158,9 +158,7 @@ class _ListEditorDialogState extends State<ListEditorDialog> {
158158
controller: repeatController,
159159
keyboardType: const TextInputType.numberWithOptions(decimal: false),
160160
style: labelStyle,
161-
inputFormatters: [
162-
FilteringTextInputFormatter.allow(RegExp(r'^[0-9]*$')),
163-
],
161+
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
164162
decoration: InputDecoration(
165163
labelText: "Total Repeats",
166164
labelStyle: labelStyle,

lib/Api/Sources/anime_extractors/dood_extractor.dart

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import '../http/m_client.dart';
88

99
class DoodExtractor {
1010
Future<List<Video>> videosFromUrl(
11-
String url, {
12-
String? quality,
13-
bool redirect = true,
14-
}) async {
15-
final InterceptedClient client =
16-
MClient.init(reqcopyWith: {'useDartHttpClient': true});
11+
String url, {
12+
String? quality,
13+
bool redirect = true,
14+
}) async {
15+
final InterceptedClient client = MClient.init(
16+
reqcopyWith: {'useDartHttpClient': true},
17+
);
1718
final newQuality = quality ?? ('Doodstream ${redirect ? ' mirror' : ''}');
1819

1920
try {
@@ -35,10 +36,12 @@ class DoodExtractor {
3536
final videoUrl =
3637
'${videoUrlStart.body}$randomString?token=$token&expiry=$expiry';
3738
return [
38-
Video(newUrl, newQuality, videoUrl, headers: {
39-
'User-Agent': 'Mangayomi',
40-
'Referer': 'https://$doodHost/',
41-
})
39+
Video(
40+
newUrl,
41+
newQuality,
42+
videoUrl,
43+
headers: {'User-Agent': 'Mangayomi', 'Referer': 'https://$doodHost/'},
44+
),
4245
];
4346
} catch (_) {
4447
return [];
@@ -49,8 +52,9 @@ class DoodExtractor {
4952
const allowedChars =
5053
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
5154
return List.generate(
52-
length,
53-
(index) => allowedChars.runes
54-
.elementAt(Random().nextInt(allowedChars.length))).join();
55+
length,
56+
(index) =>
57+
allowedChars.runes.elementAt(Random().nextInt(allowedChars.length)),
58+
).join();
5559
}
5660
}

lib/Api/Sources/anime_extractors/filemoon.dart

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import '../http/m_client.dart';
99
import '../xpath_selector.dart';
1010

1111
class FilemoonExtractor {
12-
final InterceptedClient client =
13-
MClient.init(reqcopyWith: {'useDartHttpClient': true});
12+
final InterceptedClient client = MClient.init(
13+
reqcopyWith: {'useDartHttpClient': true},
14+
);
1415

1516
Future<List<Video>> videosFromUrl(
16-
String url, String prefix, String suffix) async {
17+
String url,
18+
String prefix,
19+
String suffix,
20+
) async {
1721
prefix = prefix.isEmpty ? "Filemoon " : prefix;
1822
try {
1923
final videoHeaders = {
@@ -22,26 +26,31 @@ class FilemoonExtractor {
2226
};
2327
final response = await client.get(Uri.parse(url));
2428

25-
final jsEval = xpathSelector(response.body)
26-
.queryXPath('//script[contains(text(), "eval")]/text()')
27-
.attr;
29+
final jsEval =
30+
xpathSelector(
31+
response.body,
32+
).queryXPath('//script[contains(text(), "eval")]/text()').attr;
2833

2934
final unpacked = JSPacker(jsEval!).unpack() ?? "";
3035

31-
final masterUrl = unpacked.isNotEmpty
36+
final masterUrl =
37+
unpacked.isNotEmpty
3238
? unpacked.substringAfter('{file:"').substringBefore('"}')
3339
: '';
3440

3541
if (masterUrl.isEmpty) {
3642
return [];
3743
}
3844
List<Track> subtitleTracks = [];
39-
final subUrl = Uri.parse(url).queryParameters["sub.info"] ??
40-
unpacked.substringAfter("""fetch('", """).substringBefore("""').""");
45+
final subUrl =
46+
Uri.parse(url).queryParameters["sub.info"] ??
47+
unpacked.substringAfter("""fetch('", """).substringBefore("""').""");
4148
if (subUrl.isNotEmpty) {
4249
try {
43-
final subResponse =
44-
await client.get(Uri.parse(subUrl), headers: videoHeaders);
50+
final subResponse = await client.get(
51+
Uri.parse(subUrl),
52+
headers: videoHeaders,
53+
);
4554
final subList = jsonDecode(subResponse.body) as List;
4655
for (var item in subList) {
4756
subtitleTracks.add(Track(file: item["file"], label: item["label"]));
@@ -60,8 +69,13 @@ class FilemoonExtractor {
6069
'${playlist.substringAfter('RESOLUTION=').substringAfter('x').substringBefore(',').trim()}p';
6170
final videoUrl = playlist.split('\n')[1].trim();
6271

63-
return Video(videoUrl, "$prefix - $resolution $suffix", videoUrl,
64-
headers: videoHeaders, subtitles: subtitleTracks);
72+
return Video(
73+
videoUrl,
74+
"$prefix - $resolution $suffix",
75+
videoUrl,
76+
headers: videoHeaders,
77+
subtitles: subtitleTracks,
78+
);
6579
}).toList();
6680
} catch (_) {
6781
return [];

lib/Api/Sources/anime_extractors/gogocdn_extractor.dart

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import '../Eval/dart/model/video.dart';
1010
import '../http/m_client.dart';
1111

1212
class GogoCdnExtractor {
13-
final InterceptedClient client =
14-
MClient.init(reqcopyWith: {'useDartHttpClient': true});
13+
final InterceptedClient client = MClient.init(
14+
reqcopyWith: {'useDartHttpClient': true},
15+
);
1516
final JsonCodec json = const JsonCodec();
1617

1718
Future<List<Video>> videosFromUrl(String serverUrl) async {
@@ -20,20 +21,23 @@ class GogoCdnExtractor {
2021
final document = response.body;
2122

2223
Document parsedResponse = parser.parse(response.body);
23-
final iv = parsedResponse
24-
.querySelector('div.wrapper')!
25-
.attributes["class"]!
26-
.split('container-')
27-
.last;
24+
final iv =
25+
parsedResponse
26+
.querySelector('div.wrapper')!
27+
.attributes["class"]!
28+
.split('container-')
29+
.last;
2830

29-
final secretKey = parsedResponse
30-
.querySelector('body[class]')!
31-
.attributes["class"]!
32-
.split('container-')
33-
.last;
31+
final secretKey =
32+
parsedResponse
33+
.querySelector('body[class]')!
34+
.attributes["class"]!
35+
.split('container-')
36+
.last;
3437
RegExp(r'container-(\d+)').firstMatch(document)?.group(1);
35-
final decryptionKey =
36-
RegExp(r'videocontent-(\d+)').firstMatch(document)?.group(1);
38+
final decryptionKey = RegExp(
39+
r'videocontent-(\d+)',
40+
).firstMatch(document)?.group(1);
3741
final encryptAjaxParams = MBridge.cryptoHandler(
3842
RegExp(r'data-value="([^"]+)').firstMatch(document)?.group(1) ?? "",
3943
iv,
@@ -52,12 +56,18 @@ class GogoCdnExtractor {
5256
final encryptAjaxUrl =
5357
"${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id";
5458

55-
final encryptAjaxResponse = await client.get(Uri.parse(encryptAjaxUrl),
56-
headers: {"X-Requested-With": "XMLHttpRequest"});
59+
final encryptAjaxResponse = await client.get(
60+
Uri.parse(encryptAjaxUrl),
61+
headers: {"X-Requested-With": "XMLHttpRequest"},
62+
);
5763
final jsonResponse = encryptAjaxResponse.body;
5864
final data = json.decode(jsonResponse)["data"];
59-
final decryptedData =
60-
MBridge.cryptoHandler(data ?? "", iv, decryptionKey!, false);
65+
final decryptedData = MBridge.cryptoHandler(
66+
data ?? "",
67+
iv,
68+
decryptionKey!,
69+
false,
70+
);
6171
final videoList = <Video>[];
6272
final autoList = <Video>[];
6373
final array = json.decode(decryptedData)["source"];
@@ -70,16 +80,17 @@ class GogoCdnExtractor {
7080
final masterPlaylistResponse = await client.get(Uri.parse(fileURL));
7181
final masterPlaylist = masterPlaylistResponse.body;
7282
if (masterPlaylist.contains(separator)) {
73-
for (var it
74-
in masterPlaylist.substringAfter(separator).split(separator)) {
83+
for (var it in masterPlaylist
84+
.substringAfter(separator)
85+
.split(separator)) {
7586
final quality =
7687
"${it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",").substringBefore("\n")}p";
7788

7889
var videoUrl = it.substringAfter("\n").substringBefore("\n");
7990

8091
if (!videoUrl.startsWith("http")) {
8192
videoUrl =
82-
"${fileURL.split("/").sublist(0, fileURL.split("/").length - 1).join("/")}/$videoUrl";
93+
"${fileURL.split("/").sublist(0, fileURL.split("/").length - 1).join("/")}/$videoUrl";
8394
}
8495
videoList.add(Video(videoUrl, "$qualityPrefix$quality", videoUrl));
8596
}
@@ -88,16 +99,30 @@ class GogoCdnExtractor {
8899
}
89100
} else if (array != null && array is List) {
90101
for (var it in array) {
91-
final label =
92-
it["label"].toString().toLowerCase().trim().replaceAll(" ", "");
102+
final label = it["label"].toString().toLowerCase().trim().replaceAll(
103+
" ",
104+
"",
105+
);
93106
final fileURL = it["file"].toString().trim();
94107
final videoHeaders = {"Referer": serverUrl};
95108
if (label == "auto") {
96-
autoList.add(Video(fileURL, "$qualityPrefix$label", fileURL,
97-
headers: videoHeaders));
109+
autoList.add(
110+
Video(
111+
fileURL,
112+
"$qualityPrefix$label",
113+
fileURL,
114+
headers: videoHeaders,
115+
),
116+
);
98117
} else {
99-
videoList.add(Video(fileURL, "$qualityPrefix$label", fileURL,
100-
headers: videoHeaders));
118+
videoList.add(
119+
Video(
120+
fileURL,
121+
"$qualityPrefix$label",
122+
fileURL,
123+
headers: videoHeaders,
124+
),
125+
);
101126
}
102127
}
103128
}

lib/Api/Sources/anime_extractors/mp4upload_extractor.dart

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,35 @@ import '../xpath_selector.dart';
99
class Mp4uploadExtractor {
1010
static final RegExp qualityRegex = RegExp(r'\WHEIGHT=(\d+)');
1111
static const String referer = "https://mp4upload.com/";
12-
final InterceptedClient client =
13-
MClient.init(reqcopyWith: {'useDartHttpClient': true});
14-
15-
Future<List<Video>> videosFromUrl(String url, Map<String, String> headers,
16-
{String prefix = '', String suffix = ''}) async {
12+
final InterceptedClient client = MClient.init(
13+
reqcopyWith: {'useDartHttpClient': true},
14+
);
15+
Future<List<Video>> videosFromUrl(
16+
String url,
17+
Map<String, String> headers, {
18+
String prefix = '',
19+
String suffix = '',
20+
}) async {
1721
final newHeaders = Map<String, String>.from(headers)
1822
..addAll({'referer': referer});
1923
try {
2024
final response = await client.get(Uri.parse(url), headers: newHeaders);
2125
String script = "";
2226

23-
final scriptElementWithEval = xpathSelector(response.body)
24-
.queryXPath(
25-
'//script[contains(text(), "eval") and contains(text(), "p,a,c,k,e,d")]/text()')
26-
.attrs;
27+
final scriptElementWithEval =
28+
xpathSelector(response.body)
29+
.queryXPath(
30+
'//script[contains(text(), "eval") and contains(text(), "p,a,c,k,e,d")]/text()',
31+
)
32+
.attrs;
2733

2834
if (scriptElementWithEval.isNotEmpty) {
2935
script = JSPacker(script).unpack() ?? "";
3036
} else {
31-
final scriptElementWithSrc = xpathSelector(response.body)
32-
.queryXPath('//script[contains(text(), "player.src")]/text()')
33-
.attrs;
37+
final scriptElementWithSrc =
38+
xpathSelector(response.body)
39+
.queryXPath('//script[contains(text(), "player.src")]/text()')
40+
.attrs;
3441
if (scriptElementWithSrc.isNotEmpty) {
3542
script = scriptElementWithSrc.first!;
3643
} else {
@@ -48,11 +55,10 @@ class Mp4uploadExtractor {
4855
final resolution = resolutionMatch?.group(1) ?? 'Unknown resolution';
4956
final quality = '$prefix Mp4Upload - ${resolution}p $suffix';
5057

51-
return [
52-
Video(videoUrl, quality, videoUrl, headers: newHeaders),
53-
];
58+
return [Video(videoUrl, quality, videoUrl, headers: newHeaders)];
5459
} catch (_) {
5560
return [];
5661
}
5762
}
5863
}
64+

lib/Api/Sources/anime_extractors/mystream_extractor.dart

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import '../http/m_client.dart';
88

99
class MyStreamExtractor {
1010
Future<List<Video>> videosFromUrl(
11-
String url, Map<String, String> headers) async {
11+
String url,
12+
Map<String, String> headers,
13+
) async {
1214
final host = url.substringBefore("/watch");
1315

14-
final InterceptedClient client =
15-
MClient.init(reqcopyWith: {'useDartHttpClient': true});
16+
final InterceptedClient client = MClient.init(
17+
reqcopyWith: {'useDartHttpClient': true},
18+
);
1619

1720
try {
1821
final response = await client.get(Uri.parse(url), headers: headers);
@@ -23,28 +26,30 @@ class MyStreamExtractor {
2326
.substringBefore("\",null,null");
2427
final streamUrl = "$host/m3u8/$streamCode/master.txt?s=1&cache=1";
2528

26-
final cookie = response.headers.entries
27-
.firstWhere(
28-
(entry) =>
29-
entry.key.toLowerCase() == "set-cookie" &&
29+
final cookie =
30+
response.headers.entries
31+
.firstWhere(
32+
(entry) =>
33+
entry.key.toLowerCase() == "set-cookie" &&
3034
entry.value.startsWith("PHPSESSID", 0),
3135
orElse: () => const MapEntry("set-cookie", ""),
3236
)
33-
.value
34-
.split(";")
35-
.first;
37+
.value
38+
.split(";")
39+
.first;
3640

3741
final newHeaders = {...headers, "cookie": cookie, "accept": "*/*"};
3842

39-
final masterPlaylistResponse =
40-
await client.get(Uri.parse(streamUrl), headers: newHeaders);
43+
final masterPlaylistResponse = await client.get(
44+
Uri.parse(streamUrl),
45+
headers: newHeaders,
46+
);
4147
final masterPlaylist = masterPlaylistResponse.body;
4248

4349
const separator = "#EXT-X-STREAM-INF";
44-
return masterPlaylist
45-
.substringAfter(separator)
46-
.split(separator)
47-
.map((it) {
50+
return masterPlaylist.substringAfter(separator).split(separator).map((
51+
it,
52+
) {
4853
final resolution =
4954
"${it.substringAfter("RESOLUTION=").substringBefore("\n").substringAfter("x").substringBefore(",")}p";
5055
final quality = "MyStream - $resolution";

0 commit comments

Comments
 (0)