mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
fixed local subtitles
This commit is contained in:
parent
3a577a4c9e
commit
a7b9231eda
2 changed files with 19 additions and 10 deletions
|
|
@ -1151,7 +1151,7 @@ mp.register_script_message('call_button_${button.id}_long', button${button.id}lo
|
|||
.toList();
|
||||
|
||||
List<String> subs = [];
|
||||
if (widget.videos.isNotEmpty && !widget.isLocal) {
|
||||
if (widget.videos.isNotEmpty) {
|
||||
for (var video in widget.videos) {
|
||||
for (var sub in video.subtitles ?? []) {
|
||||
if (!subs.contains(sub.file)) {
|
||||
|
|
@ -1159,8 +1159,8 @@ mp.register_script_message('call_button_${button.id}_long', button${button.id}lo
|
|||
final label = sub.label;
|
||||
videoSubtitle.add(
|
||||
VideoPrefs(
|
||||
isLocal: false,
|
||||
subtitle: file.startsWith("http")
|
||||
isLocal: widget.isLocal,
|
||||
subtitle: (file.startsWith("http") || file.startsWith("file"))
|
||||
? SubtitleTrack.uri(file, title: label, language: label)
|
||||
: SubtitleTrack.data(file, title: label, language: label),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -152,15 +152,24 @@ class M3u8Downloader {
|
|||
}
|
||||
_log('Downloading subtitle file: ${element.label}');
|
||||
subtitleFile.createSync(recursive: true);
|
||||
final response = await _withRetry(
|
||||
() => httpClient.get(Uri.parse(element.file ?? ''), headers: headers),
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
_log('Warning: Failed to download subtitle file: ${element.label}');
|
||||
if (element.file == null || element.file!.trim().isEmpty) {
|
||||
_log('Warning: No subtitle file: ${element.label}');
|
||||
continue;
|
||||
}
|
||||
_log('Subtitle file downloaded: ${element.label}');
|
||||
await subtitleFile.writeAsBytes(response.bodyBytes);
|
||||
if (element.file!.startsWith("http")) {
|
||||
final response = await _withRetry(
|
||||
() =>
|
||||
httpClient.get(Uri.parse(element.file ?? ''), headers: headers),
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
_log('Warning: Failed to download subtitle file: ${element.label}');
|
||||
continue;
|
||||
}
|
||||
_log('Subtitle file downloaded: ${element.label}');
|
||||
await subtitleFile.writeAsBytes(response.bodyBytes);
|
||||
} else {
|
||||
await subtitleFile.writeAsString(element.file!);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
throw M3u8DownloaderException('Download failed', e);
|
||||
|
|
|
|||
Loading…
Reference in a new issue