fix: download from homepage failing

This commit is contained in:
edde746
2026-02-26 03:41:27 +01:00
parent 98776b40f5
commit 5740d93a35
2 changed files with 20 additions and 13 deletions
+10 -11
View File
@@ -656,19 +656,18 @@ class DownloadProvider extends ChangeNotifier {
}
}
// Fetch full metadata to get year, summary, clearLogo
// The metadata from getChildren() is summarized and missing these fields.
// If metadata already has summary, it's already full (e.g., from detail screen).
// Always fetch full metadata before downloading.
// Hub items may have summary but the cache at /library/metadata/$ratingKey
// won't have the full API response (with Media/Part data needed for video URL)
// unless getMetadataWithImages has been called.
PlexMetadata metadataToStore = metadata;
if (metadata.summary == null) {
try {
final fullMetadata = await client.getMetadataWithImages(metadata.ratingKey);
if (fullMetadata != null) {
metadataToStore = fullMetadata.copyWith(serverId: metadata.serverId, serverName: metadata.serverName);
}
} catch (e) {
appLogger.w('Failed to fetch full metadata for ${metadata.ratingKey}, using partial', error: e);
try {
final fullMetadata = await client.getMetadataWithImages(metadata.ratingKey);
if (fullMetadata != null) {
metadataToStore = fullMetadata.copyWith(serverId: metadata.serverId, serverName: metadata.serverName);
}
} catch (e) {
appLogger.w('Failed to fetch full metadata for ${metadata.ratingKey}, using partial', error: e);
}
// For episodes, also fetch and store show and season metadata for offline display
+10 -2
View File
@@ -522,8 +522,16 @@ class DownloadManagerService {
}
}
final playbackData = await client.getVideoPlaybackData(metadata.ratingKey);
if (playbackData.videoUrl == null) throw Exception('Could not get video URL');
var playbackData = await client.getVideoPlaybackData(metadata.ratingKey);
if (playbackData.videoUrl == null) {
// Cache may contain a synthetic entry (from _cacheMetadataForOffline) without
// Media/Part data. Force a fresh network fetch to populate the cache properly.
appLogger.w('No video URL from cache for $globalKey, retrying via network');
final fetched = await client.getMetadataWithImages(ratingKey);
if (fetched != null) metadata = fetched.copyWith(serverId: serverId);
playbackData = await client.getVideoPlaybackData(metadata.ratingKey);
if (playbackData.videoUrl == null) throw Exception('Could not get video URL for $globalKey');
}
final ext = _getExtensionFromUrl(playbackData.videoUrl!) ?? 'mp4';