mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
@@ -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(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user