Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-01-29 13:35:51 +08:00
parent bcbfe5c849
commit 5979ddb60c
46 changed files with 3266 additions and 3293 deletions

View File

@@ -536,11 +536,9 @@ class HeaderControlState extends State<HeaderControl>
Get.back();
final result = await showDialog<CDNService>(
context: context,
builder: (context) {
return CdnSelectDialog(
sample: videoInfo.dash?.video?.firstOrNull,
);
},
builder: (context) => CdnSelectDialog(
sample: videoInfo.dash?.video?.firstOrNull,
),
);
if (result != null) {
VideoUtils.cdnService = result;
@@ -1230,68 +1228,66 @@ class HeaderControlState extends State<HeaderControl>
void onExportSubtitle() {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
clipBehavior: Clip.hardEdge,
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
title: const Text('保存字幕'),
content: SingleChildScrollView(
child: Column(
children: videoDetailCtr.subtitles
.map(
(item) => ListTile(
dense: true,
onTap: () async {
Get.back();
final url = item.subtitleUrl;
if (url == null || url.isEmpty) return;
try {
final res = await Request.dio.get<Uint8List>(
url.http2https,
options: Options(
responseType: ResponseType.bytes,
headers: Constants.baseHeaders,
extra: {'account': const NoAccount()},
builder: (context) => AlertDialog(
clipBehavior: Clip.hardEdge,
contentPadding: const EdgeInsets.fromLTRB(0, 12, 0, 12),
title: const Text('保存字幕'),
content: SingleChildScrollView(
child: Column(
children: videoDetailCtr.subtitles
.map(
(item) => ListTile(
dense: true,
onTap: () async {
Get.back();
final url = item.subtitleUrl;
if (url == null || url.isEmpty) return;
try {
final res = await Request.dio.get<Uint8List>(
url.http2https,
options: Options(
responseType: ResponseType.bytes,
headers: Constants.baseHeaders,
extra: {'account': const NoAccount()},
),
);
if (res.statusCode == 200) {
final bytes = Uint8List.fromList(
Request.responseBytesDecoder(
res.data!,
res.headers.map,
),
);
if (res.statusCode == 200) {
final bytes = Uint8List.fromList(
Request.responseBytesDecoder(
res.data!,
res.headers.map,
),
);
String name =
'${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json';
if (Platform.isWindows) {
// Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
name = name.replaceAll(
RegExp(r'[<>:/\\|?*"]'),
'',
);
}
Utils.saveBytes2File(
name: name,
bytes: bytes,
allowedExtensions: const ['json'],
String name =
'${introController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json';
if (Platform.isWindows) {
// Reserved characters may not be used in file names. See: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
name = name.replaceAll(
RegExp(r'[<>:/\\|?*"]'),
'',
);
}
} catch (e, s) {
Utils.reportError(e, s);
SmartDialog.showToast(e.toString());
Utils.saveBytes2File(
name: name,
bytes: bytes,
allowedExtensions: const ['json'],
);
}
},
title: Text(
item.lanDoc!,
style: const TextStyle(fontSize: 14),
),
} catch (e, s) {
Utils.reportError(e, s);
SmartDialog.showToast(e.toString());
}
},
title: Text(
item.lanDoc!,
style: const TextStyle(fontSize: 14),
),
)
.toList(),
),
),
)
.toList(),
),
);
},
),
),
);
}