|
|
@@ -697,9 +697,14 @@ async function setVideoUrlForSong(song: VideoItem, options?: MetadataExtractionO
|
|
|
if (fileExists) {
|
|
|
const fileSize = await FileManager.getFileSize(cachedPath.cachePath);
|
|
|
if (fileSize > 0) {
|
|
|
- Logger.info(TAG, `百度网盘文件已缓存: ${cachedPath.cachePath}`);
|
|
|
- void scheduleMetadataExtractionFromCache(song, cachedPath.cachePath, metadataOptions, song.videoSize);
|
|
|
- return cachedPath.cachePath;
|
|
|
+ if (song.videoSize > 0 && fileSize < song.videoSize * 0.9) {
|
|
|
+ Logger.warn(TAG, `百度网盘缓存文件不完整,准备删除重试: ${cachedPath.cachePath}, size=${fileSize}, expect=${song.videoSize}`);
|
|
|
+ await FileManager.deleteFile(cachedPath.cachePath);
|
|
|
+ } else {
|
|
|
+ Logger.info(TAG, `百度网盘文件已缓存: ${cachedPath.cachePath}`);
|
|
|
+ void scheduleMetadataExtractionFromCache(song, cachedPath.cachePath, metadataOptions, song.videoSize);
|
|
|
+ return cachedPath.cachePath;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -13672,7 +13677,9 @@ export struct LocalMusic {
|
|
|
expectDataType: http.HttpDataType.STRING,
|
|
|
header: {
|
|
|
'User-Agent': BaiduConstants.STREAMING_USER_AGENT,
|
|
|
- 'Host': 'pan.baidu.com'
|
|
|
+ 'Host': 'pan.baidu.com',
|
|
|
+ 'Referer': 'https://pan.baidu.com/disk/home',
|
|
|
+ 'Accept-Encoding': 'identity'
|
|
|
}
|
|
|
});
|
|
|
if (response.responseCode !== 200 || typeof response.result !== 'string') {
|
|
|
@@ -13725,6 +13732,13 @@ export struct LocalMusic {
|
|
|
console.info("onecold preparedDuration--" + preparedDuration)
|
|
|
if (preparedDuration > 0) {
|
|
|
applyDuration(preparedDuration);
|
|
|
+ if (this.videoUrl.includes('method=streaming') && isBaiduType(this.currentSong?.type ?? -1)) {
|
|
|
+ const durationMs = await fetchBaiduM3u8Duration(this.videoUrl);
|
|
|
+ if (durationMs > 0 && Math.abs(durationMs - preparedDuration) > 1000) {
|
|
|
+ Logger.info(TAG, `heanup 使用M3U8时长覆盖播放器时长: ${preparedDuration}ms -> ${durationMs}ms`);
|
|
|
+ applyDuration(durationMs);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
fetchDurationFallback();
|
|
|
}
|