Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Keep the next books in a playlist or collection downloaded

Barnabasb1065042a1f3
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 41961be3..a52ff55f 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -671,6 +671,10 @@
"queueModeBooks": "Books",
"queueModePodcasts": "Podcasts",
"autoDownloadQueue": "Auto-download queue",
+ "autoDownloadThisSeriesLabel": "Auto-download this series",
+ "autoDownloadThisShowLabel": "Auto-download this podcast",
+ "autoDownloadThisPlaylistLabel": "Auto-download this playlist",
+ "autoDownloadThisCollectionLabel": "Auto-download this collection",
"autoDownloadQueueOnSubtitle": "Keep next {count} items downloaded",
"@autoDownloadQueueOnSubtitle": {
"placeholders": {
@@ -850,10 +854,10 @@
"autoDownloadOnWifiOffSubtitle": "Off",
"concurrentDownloads": "Concurrent downloads",
"autoDownload": "Auto-download",
- "autoDownloadSubtitle": "Enable per series or podcast from their detail pages",
+ "autoDownloadSubtitle": "Enable per series, podcast, playlist or collection from their detail pages",
"keepNext": "Keep next",
"keepNextInfoTitle": "Keep Next",
- "keepNextInfoContent": "The number of items to keep downloaded, including the one you're currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.",
+ "keepNextInfoContent": "The number of items to keep downloaded, including the one you're currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.",
"deleteAbsorbedDownloads": "Delete absorbed downloads",
"deleteAbsorbedDownloadsInfoTitle": "Delete Absorbed Downloads",
"deleteAbsorbedDownloadsInfoContent": "When enabled, downloaded books or episodes are automatically deleted from this device after you finish them in Absorb. Finishing an item on the web or another device won’t delete its download here.",
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index d8fca852..85309a6b 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -2716,6 +2716,30 @@ abstract class AppLocalizations {
/// **'Auto-download queue'**
String get autoDownloadQueue;
+ /// No description provided for @autoDownloadThisSeriesLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Auto-download this series'**
+ String get autoDownloadThisSeriesLabel;
+
+ /// No description provided for @autoDownloadThisShowLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Auto-download this podcast'**
+ String get autoDownloadThisShowLabel;
+
+ /// No description provided for @autoDownloadThisPlaylistLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Auto-download this playlist'**
+ String get autoDownloadThisPlaylistLabel;
+
+ /// No description provided for @autoDownloadThisCollectionLabel.
+ ///
+ /// In en, this message translates to:
+ /// **'Auto-download this collection'**
+ String get autoDownloadThisCollectionLabel;
+
/// No description provided for @autoDownloadQueueOnSubtitle.
///
/// In en, this message translates to:
@@ -3283,7 +3307,7 @@ abstract class AppLocalizations {
/// No description provided for @autoDownloadSubtitle.
///
/// In en, this message translates to:
- /// **'Enable per series or podcast from their detail pages'**
+ /// **'Enable per series, podcast, playlist or collection from their detail pages'**
String get autoDownloadSubtitle;
/// No description provided for @keepNext.
@@ -3301,7 +3325,7 @@ abstract class AppLocalizations {
/// No description provided for @keepNextInfoContent.
///
/// In en, this message translates to:
- /// **'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.'**
+ /// **'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.'**
String get keepNextInfoContent;
/// No description provided for @deleteAbsorbedDownloads.
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index 627f8f37..770c3aad 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -1445,6 +1445,18 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-Download-Warteschlange';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Die nächsten $count Inhalte heruntergeladen halten';
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index d5491894..32ce6d20 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsEl extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsEl extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsEl extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 5db0d290..dac02eed 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index 7cdd38e9..69b4b7fa 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -1435,6 +1435,18 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1763,7 +1775,7 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1773,7 +1785,7 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index d9ac2240..9958d610 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -1445,6 +1445,18 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1773,7 +1785,7 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index 733ed2a2..cbc9ebe8 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index 19d69e20..b917e95f 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index 09e8db55..2fc284e3 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsNo extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsNo extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsNo extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index 51d3278c..6de7c974 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index 63ee7609..69cc519a 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -1433,6 +1433,18 @@ class AppLocalizationsRo extends AppLocalizations {
@override
String get autoDownloadQueue => 'Auto-download queue';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Keep next $count items downloaded';
@@ -1761,7 +1773,7 @@ class AppLocalizationsRo extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1771,7 +1783,7 @@ class AppLocalizationsRo extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index 4b0b98cc..1b957dd3 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -1435,6 +1435,18 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get autoDownloadQueue => 'Автозагрузка очереди';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return 'Оставить следующие $count загруженных элементов';
@@ -1765,7 +1777,7 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get autoDownloadSubtitle =>
- 'Enable per series or podcast from their detail pages';
+ 'Enable per series, podcast, playlist or collection from their detail pages';
@override
String get keepNext => 'Keep next';
@@ -1775,7 +1787,7 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get keepNextInfoContent =>
- 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in the series or podcast will stay downloaded.';
+ 'The number of items to keep downloaded, including the one you\'re currently listening to. For example, \"Keep next 3\" means the current book plus the next 2 in that series, podcast, playlist or collection will stay downloaded. This applies to every auto-download you turn on.';
@override
String get deleteAbsorbedDownloads => 'Delete absorbed downloads';
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index 461313a1..3cd4a000 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -1409,6 +1409,18 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get autoDownloadQueue => '自动下载队列';
+ @override
+ String get autoDownloadThisSeriesLabel => 'Auto-download this series';
+
+ @override
+ String get autoDownloadThisShowLabel => 'Auto-download this podcast';
+
+ @override
+ String get autoDownloadThisPlaylistLabel => 'Auto-download this playlist';
+
+ @override
+ String get autoDownloadThisCollectionLabel => 'Auto-download this collection';
+
@override
String autoDownloadQueueOnSubtitle(int count) {
return '保留接下来 $count 个项目的下载';
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index d3899133..f86530e0 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -2252,6 +2252,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
await PlayerSettings.getQueueAutoDownload();
if (_rollingDownloadSeries.isEmpty && !autoSeriesDefault) return;
final count = await PlayerSettings.getRollingDownloadCount();
+ _checkListRollingDownloads(playingKey, count);
if (playingKey.length > 36) {
final showId = playingKey.substring(0, 36);
@@ -2318,11 +2319,108 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
}
+ /// Per-playlist and per-collection auto-download. Mirrors how series behave:
+ /// it runs off whatever is playing and needs only the list's own toggle, so
+ /// the auto-play queue does not have to be in playlist or collection mode.
+ /// A list whose window the active queue already covers is skipped so the two
+ /// paths don't plan the same downloads twice.
+ Future<void> _checkListRollingDownloads(String playingKey, int count) async {
+ final api = _api;
+ if (api == null || isOffline || count <= 0) return;
+ if (_rollingDownloadSeries.isEmpty) return;
+ final self = this as LibraryProvider;
+
+ final sources =
+ <({String id, String kind, List<Map<String, dynamic>> items})>[];
+ for (final raw in _playlists) {
+ if (raw is! Map<String, dynamic>) continue;
+ final id = raw['id'] as String?;
+ if (id == null || !_rollingDownloadSeries.contains(id)) continue;
+ final items = (raw['items'] as List<dynamic>? ?? const [])
+ .whereType<Map<String, dynamic>>()
+ .toList();
+ if (items.isNotEmpty) {
+ sources.add((id: id, kind: 'playlist', items: items));
+ }
+ }
+ for (final raw in _collections) {
+ if (raw is! Map<String, dynamic>) continue;
+ final id = raw['id'] as String?;
+ if (id == null || !_rollingDownloadSeries.contains(id)) continue;
+ final items = self._collectionItems(raw);
+ if (items.isNotEmpty) {
+ sources.add((id: id, kind: 'collection', items: items));
+ }
+ }
+ if (sources.isEmpty) return;
+
+ final activeQueueMode = playingKey.length > 36
+ ? await PlayerSettings.getPodcastQueueMode()
+ : await PlayerSettings.getBookQueueMode();
+ final globalAutoDownload = await PlayerSettings.getQueueAutoDownload();
+ final activePlaylistId = await PlayerSettings.getQueuePlaylistId();
+ final activeCollectionId = await PlayerSettings.getQueueCollectionId();
+
+ String? playingNow() {
+ final player = AudioPlayerService();
+ final itemId = player.currentItemId;
+ if (itemId == null) return null;
+ final episodeId = player.currentEpisodeId;
+ return episodeId == null ? itemId : '$itemId-$episodeId';
+ }
+
+ bool isStale() =>
+ _api == null || isOffline || playingNow() != playingKey;
+ Future<bool> settingsStillMatch() async =>
+ !isStale() && await PlayerSettings.getRollingDownloadCount() == count;
+
+ for (final source in sources) {
+ if (isStale()) return;
+ final activeId =
+ source.kind == 'playlist' ? activePlaylistId : activeCollectionId;
+ final queueOwnsWindow = activeQueueMode == source.kind &&
+ activeId == source.id &&
+ resolveQueueAutoDownloadEnabled(
+ queueMode: activeQueueMode,
+ globalEnabled: globalAutoDownload,
+ activeSourceId: activeId,
+ activeSourceEnabled: _rollingDownloadSeries.contains(activeId),
+ );
+ if (queueOwnsWindow) {
+ debugPrint(
+ '[QueueDL] ${source.kind} ${source.id}: active queue already covers this window');
+ continue;
+ }
+ final window = queueTailFrom(
+ items: source.items,
+ currentKey: playingKey,
+ keyOf: self._playlistItemKey,
+ );
+ if (window.isEmpty) continue;
+ debugPrint(
+ '[QueueDL] ${source.kind} ${source.id}: ${source.items.length} items, window=${window.length} from $playingKey');
+ await _downloadQueueWindow(
+ items: window,
+ count: count,
+ api: api,
+ isStale: isStale,
+ settingsStillMatch: settingsStillMatch,
+ logLabel: '${source.kind}=${source.id}',
+ );
+ }
+ }
+
Future<String?> _queueAutoDownloadSourceId(
String playingKey,
String queueMode,
ApiService api,
) async {
+ if (queueMode == 'playlist') {
+ return PlayerSettings.getQueuePlaylistId();
+ }
+ if (queueMode == 'collection') {
+ return PlayerSettings.getQueueCollectionId();
+ }
if (queueMode != 'auto_next') return null;
if (playingKey.length > 36) return playingKey.substring(0, 36);
@@ -2528,102 +2626,126 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
return;
}
- final downloads = DownloadService();
- var newDownloads = 0;
- String keyOf(Map<String, dynamic> item) {
- final libraryItemId = item['libraryItemId'] as String? ?? '';
- final episodeId = item['episodeId'] as String?;
- return queueItemKey(
- libraryItemId: libraryItemId,
- episodeId: episodeId,
- );
- }
- final pendingItems = queueItemsNeedingDownload(
- items: items.where((item) => keyOf(item).isNotEmpty),
+ await _downloadQueueWindow(
+ items: items,
count: count,
- keyOf: keyOf,
- isFinished: (item) => self.isItemFinishedByKey(keyOf(item)),
- isAvailable: (item) {
- final key = keyOf(item);
- return downloads.isDownloaded(key) || downloads.isDownloading(key);
- },
+ api: api,
+ isStale: isStale,
+ settingsStillMatch: settingsStillMatch,
+ logLabel: 'mode=$queueMode',
);
- debugPrint(
- '[QueueDL] plan: ${items.length} in tail, keep-next=$count, ${pendingItems.length} need downloading -> ${pendingItems.map(keyOf).join(', ')}');
- if (pendingItems.isEmpty) {
- debugPrint(
- '[QueueDL] nothing to do - the next $count are already downloaded or finished');
- }
+ } catch (error, stackTrace) {
+ debugPrint('[QueueDownload] Check failed: $error\n$stackTrace');
+ }
+ }
- for (final item in pendingItems) {
- if (stop('download loop')) return;
- final libraryItemId = item['libraryItemId'] as String? ?? '';
- if (libraryItemId.isEmpty) continue;
- final episodeId = item['episodeId'] as String?;
+ /// Download the first [count] not-yet-available entries of an already-ordered
+ /// queue window. Shared by the active-queue check and the per-playlist /
+ /// per-collection check so both keep the same "keep next N" behaviour.
+ Future<void> _downloadQueueWindow({
+ required List<Map<String, dynamic>> items,
+ required int count,
+ required ApiService api,
+ required bool Function() isStale,
+ required Future<bool> Function() settingsStillMatch,
+ required String logLabel,
+ }) async {
+ final self = this as LibraryProvider;
+ final downloads = DownloadService();
+ var newDownloads = 0;
+ String keyOf(Map<String, dynamic> item) {
+ final libraryItemId = item['libraryItemId'] as String? ?? '';
+ final episodeId = item['episodeId'] as String?;
+ return queueItemKey(
+ libraryItemId: libraryItemId,
+ episodeId: episodeId,
+ );
+ }
+
+ final pendingItems = queueItemsNeedingDownload(
+ items: items.where((item) => keyOf(item).isNotEmpty),
+ count: count,
+ keyOf: keyOf,
+ isFinished: (item) => self.isItemFinishedByKey(keyOf(item)),
+ isAvailable: (item) {
final key = keyOf(item);
- if (downloads.isDownloaded(key) || downloads.isDownloading(key)) {
- continue;
- }
+ return downloads.isDownloaded(key) || downloads.isDownloading(key);
+ },
+ );
+ debugPrint(
+ '[QueueDL] plan ($logLabel): ${items.length} in window, keep-next=$count, ${pendingItems.length} need downloading -> ${pendingItems.map(keyOf).join(', ')}');
+ if (pendingItems.isEmpty) {
+ debugPrint(
+ '[QueueDL] nothing to do ($logLabel) - the next $count are already downloaded or finished');
+ }
- var libraryItem =
- item['libraryItem'] as Map<String, dynamic>? ?? const {};
- if (libraryItem['media'] == null) {
- final fetched = await api.getLibraryItem(libraryItemId);
- if (fetched != null) libraryItem = fetched;
- }
- if (!await settingsStillMatch()) return;
- final media =
- libraryItem['media'] as Map<String, dynamic>? ?? const {};
- final metadata =
- media['metadata'] as Map<String, dynamic>? ?? const {};
- var episode = item['episode'] as Map<String, dynamic>?;
- if (episode == null && episodeId != null) {
- for (final candidate
- in (media['episodes'] as List<dynamic>? ?? const [])) {
- if (candidate is Map<String, dynamic> &&
- candidate['id'] == episodeId) {
- episode = candidate;
- break;
- }
- }
- }
+ for (final item in pendingItems) {
+ if (isStale()) {
+ debugPrint('[QueueDL] stop during download loop ($logLabel)');
+ return;
+ }
+ final libraryItemId = item['libraryItemId'] as String? ?? '';
+ if (libraryItemId.isEmpty) continue;
+ final episodeId = item['episodeId'] as String?;
+ final key = keyOf(item);
+ if (downloads.isDownloaded(key) || downloads.isDownloading(key)) {
+ continue;
+ }
- final title = episodeId == null
- ? metadata['title'] as String? ?? ''
- : episode?['title'] as String? ?? 'Episode';
- final author = episodeId == null
- ? metadata['authorName'] as String? ?? ''
- : metadata['title'] as String? ?? '';
- if (downloads.isDownloaded(key) || downloads.isDownloading(key)) {
- continue;
- }
- final error = await downloads.downloadItem(
- api: api,
- itemId: key,
- title: title,
- author: author,
- coverUrl: getCoverUrl(libraryItemId),
- episodeId: episodeId,
- libraryId:
- libraryItem['libraryId'] as String? ?? _selectedLibraryId,
- shouldStart: () => !isStale(),
- );
- if (isStale()) return;
- if (error == null &&
- (downloads.isDownloaded(key) || downloads.isDownloading(key))) {
- newDownloads++;
+ var libraryItem =
+ item['libraryItem'] as Map<String, dynamic>? ?? const {};
+ if (libraryItem['media'] == null) {
+ final fetched = await api.getLibraryItem(libraryItemId);
+ if (fetched != null) libraryItem = fetched;
+ }
+ if (!await settingsStillMatch()) return;
+ final media = libraryItem['media'] as Map<String, dynamic>? ?? const {};
+ final metadata =
+ media['metadata'] as Map<String, dynamic>? ?? const {};
+ var episode = item['episode'] as Map<String, dynamic>?;
+ if (episode == null && episodeId != null) {
+ for (final candidate
+ in (media['episodes'] as List<dynamic>? ?? const [])) {
+ if (candidate is Map<String, dynamic> &&
+ candidate['id'] == episodeId) {
+ episode = candidate;
+ break;
+ }
}
}
- if (newDownloads > 0) {
- final l = _l();
- _showRollingToast(
- l?.lpQueueDownloadingItems(newDownloads) ??
- 'Queue: downloading $newDownloads item${newDownloads == 1 ? '' : 's'}',
- icon: Icons.download_rounded);
+ final title = episodeId == null
+ ? metadata['title'] as String? ?? ''
+ : episode?['title'] as String? ?? 'Episode';
+ final author = episodeId == null
+ ? metadata['authorName'] as String? ?? ''
+ : metadata['title'] as String? ?? '';
+ if (downloads.isDownloaded(key) || downloads.isDownloading(key)) {
+ continue;
}
- } catch (error, stackTrace) {
- debugPrint('[QueueDownload] Check failed: $error\n$stackTrace');
+ final error = await downloads.downloadItem(
+ api: api,
+ itemId: key,
+ title: title,
+ author: author,
+ coverUrl: getCoverUrl(libraryItemId),
+ episodeId: episodeId,
+ libraryId: libraryItem['libraryId'] as String? ?? _selectedLibraryId,
+ shouldStart: () => !isStale(),
+ );
+ if (isStale()) return;
+ if (error == null &&
+ (downloads.isDownloaded(key) || downloads.isDownloading(key))) {
+ newDownloads++;
+ }
+ }
+
+ if (newDownloads > 0) {
+ final l = _l();
+ _showRollingToast(
+ l?.lpQueueDownloadingItems(newDownloads) ??
+ 'Queue: downloading $newDownloads item${newDownloads == 1 ? '' : 's'}',
+ icon: Icons.download_rounded);
}
}
diff --git a/lib/screens/absorbing_screen.dart b/lib/screens/absorbing_screen.dart
index 676489a0..d050875b 100644
--- a/lib/screens/absorbing_screen.dart
+++ b/lib/screens/absorbing_screen.dart
@@ -1174,9 +1174,15 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
_currentPodcastShowId != null ||
(_currentItemId == null && widget.isPodcast);
+ /// The source whose own auto-download toggle governs this queue. Playlists
+ /// and collections own theirs the same way a series does; the manual queue
+ /// has no source, so it falls back to the global setting.
String? get _activeAutoDownloadSourceId {
- if (_queueMode != 'auto_next') return null;
- return _currentPodcastShowId ?? _seriesId;
+ if (_queueMode == 'auto_next') return _currentPodcastShowId ?? _seriesId;
+ if (_queueMode == 'playlist' || _queueMode == 'collection') {
+ return _activeQueueSourceId;
+ }
+ return null;
}
Future<void> _refreshQueueDownloadSettings() async {
@@ -1200,10 +1206,27 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
});
}
+ /// Name the thing the switch actually acts on, so it's clear the toggle is
+ /// scoped to this series/playlist/collection and not to every queue.
+ String _autoDownloadLabel(AppLocalizations l) {
+ switch (_queueMode) {
+ case 'auto_next':
+ return _currentPodcastShowId != null
+ ? l.autoDownloadThisShowLabel
+ : l.autoDownloadThisSeriesLabel;
+ case 'playlist':
+ return l.autoDownloadThisPlaylistLabel;
+ case 'collection':
+ return l.autoDownloadThisCollectionLabel;
+ default:
+ return l.autoDownloadQueue;
+ }
+ }
+
Future<void> _setQueueAutoDownload(bool value) async {
final sourceId = _activeAutoDownloadSourceId;
setState(() => _queueAutoDownload = value);
- if (_queueMode == 'auto_next' && sourceId != null) {
+ if (sourceId != null) {
if (value) {
await widget.lib.enableRollingDownload(sourceId);
} else {
@@ -1495,7 +1518,7 @@ class _ReorderAbsorbingSheetState extends State<_ReorderAbsorbingSheet> {
Expanded(child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Text(l.autoDownloadQueue,
+ Text(_autoDownloadLabel(l),
style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
Text(
_queueAutoDownload
diff --git a/lib/services/queue_download_policy.dart b/lib/services/queue_download_policy.dart
index 5ab48b9e..b35c8d23 100644
--- a/lib/services/queue_download_policy.dart
+++ b/lib/services/queue_download_policy.dart
@@ -1,10 +1,14 @@
+/// Modes that play through a named source - a series/show, a playlist, or a
+/// collection - use that source's own auto-download toggle. The manual queue
+/// has no source of its own, so it falls back to the global setting.
bool resolveQueueAutoDownloadEnabled({
required String queueMode,
required bool globalEnabled,
required String? activeSourceId,
required bool activeSourceEnabled,
}) {
- if (queueMode == 'auto_next' && activeSourceId != null) {
+ const sourceModes = {'auto_next', 'playlist', 'collection'};
+ if (sourceModes.contains(queueMode) && activeSourceId != null) {
return activeSourceEnabled;
}
return globalEnabled;
diff --git a/lib/widgets/collection_detail_sheet.dart b/lib/widgets/collection_detail_sheet.dart
index 4b04c274..e364b086 100644
--- a/lib/widgets/collection_detail_sheet.dart
+++ b/lib/widgets/collection_detail_sheet.dart
@@ -260,6 +260,14 @@ class _CollectionDetailSheetState extends State<CollectionDetailSheet> {
if (canEditCollection)
_headerIconButton(cs, Icons.library_add_rounded,
() => _openAddBooks(lib, collection, name, books)),
+ _headerIconButton(cs,
+ lib.isRollingDownloadEnabled(widget.collectionId)
+ ? Icons.downloading_rounded
+ : Icons.download_outlined,
+ () => lib.toggleRollingDownload(widget.collectionId),
+ tooltip: lib.isRollingDownloadEnabled(widget.collectionId)
+ ? l.turnAutoDownloadOff
+ : l.turnAutoDownloadOn),
_headerIconButton(cs,
_gridView ? Icons.view_list_rounded : Icons.grid_view_rounded,
() => setState(() => _gridView = !_gridView)),
diff --git a/lib/widgets/playlist_detail_sheet.dart b/lib/widgets/playlist_detail_sheet.dart
index c8ed389f..f482e0bf 100644
--- a/lib/widgets/playlist_detail_sheet.dart
+++ b/lib/widgets/playlist_detail_sheet.dart
@@ -391,6 +391,14 @@ class _PlaylistDetailSheetState extends State<PlaylistDetailSheet> {
if (!isPodcastPlaylist)
_headerIconButton(cs, Icons.library_add_rounded,
() => _openAddBooks(lib, playlist, name, items)),
+ _headerIconButton(cs,
+ lib.isRollingDownloadEnabled(widget.playlistId)
+ ? Icons.downloading_rounded
+ : Icons.download_outlined,
+ () => lib.toggleRollingDownload(widget.playlistId),
+ tooltip: lib.isRollingDownloadEnabled(widget.playlistId)
+ ? l.turnAutoDownloadOff
+ : l.turnAutoDownloadOn),
_headerIconButton(cs,
_gridView ? Icons.view_list_rounded : Icons.grid_view_rounded,
() => setState(() => _gridView = !_gridView)),