git.iko.soy/maciek134/podphoenix
on main help sign in
feat: Auto-mark episodes as listened on playlist end. (#18)

feat: Setting to auto-clean listened episodes. Note that since the app isn't running in privileged mode, it may or may not catch events about track change when it is out of focus. However, the end of playlist event should trigger when the app gets the focus back, thus this less-than-optimal choice.

commite205e3900cbef14563bee0a1d2e119eefdab6b6c authorSimon Poirier <simpoir@gmail.com> dateMon 27 Mar 2023, 01:54 (4 years ago) parentfc95fa6
3 files changed+29−1
app/podcasts.js+5−1 app/podphoenix.qml+7 app/ui/SettingsPage.qml+17
app/podcasts.js+5−1
@@ -401,7 +401,11 @@ function cleanUp(today, retentionDays) {
401401 var rs2 = tx.executeSql("SELECT rowid, * FROM Episode WHERE podcast=?", [rs.rows.item(i).rowid]);
402402 for (var j=0; j< rs2.rows.length; j++) {
403403 var diff = Math.floor((today - rs2.rows.item(j).published)/dayToMs)
404− if (rs2.rows.item(j).downloadedfile && diff > retentionDays) {
404+ var item = rs2.rows.item(j);
405+ if (!item.favourited && item.downloadedfile && (
406+ diff > retentionDays
407+ || (podphoenix.settings.deleteListened && item.listened)
408+ )) {
405409 fileManager.deleteFile(rs2.rows.item(j).downloadedfile)
406410 tx.executeSql("UPDATE Episode SET downloadedfile = NULL WHERE guid = ?", [rs2.rows.item(j).guid]);
407411 }
app/podphoenix.qml+7
@@ -122,6 +122,7 @@ MainView {
122122 property bool firstRun: true
123123 property int maxEpisodeDownload: -1
124124 property bool hideListened: false
125+ property bool deleteListened: false
125126 property bool showListView: true
126127 property int skipForward: 30
127128 property int skipBack: 10
@@ -387,6 +388,12 @@ MainView {
387388 console.log("[LOG]: End of Media. Stopping.")
388389 endOfMedia = true
389390 stop()
391+
392+ Podcasts.init().transaction(function(tx) {
393+ // Playlist finished, mark all playlist as played.
394+ tx.executeSql("UPDATE Episode SET listened=1 WHERE guid in (SELECT guid FROM Queue)");
395+ refreshModels();
396+ })
390397 }
391398 }
392399
app/ui/SettingsPage.qml+17
@@ -268,6 +268,23 @@ Page {
268268 onClicked: mainStack.push(Qt.resolvedUrl("../settings/DownloadSetting.qml"))
269269 }
270270
271+ ListItem {
272+ ListItemLayout {
273+ id: deleteListened
274+ title.text: i18n.tr("Automatically delete listened episodes")
275+ title.color: podphoenix.appTheme.baseText
276+ summary.text: i18n.tr("Automatically delete listened episodes on application start")
277+ summary.color: podphoenix.appTheme.baseSubText
278+ Switch {
279+ SlotsLayout.position: SlotsLayout.Last
280+ checked: podphoenix.settings.deleteListened
281+ onClicked: podphoenix.settings.deleteListened = checked
282+ }
283+ }
284+ divider.visible: false
285+ height: deleteListened.height
286+ }
287+
271288 ListItem {
272289 ListItemLayout {
273290 id: downloadWifiOnlyLayout