podgrab
podgrab copied to clipboard
[Feature Request] Auto Delete after xxx days
Please consider adding an option to auto-delete downloads after a user-defined number of days. Perhaps selecting a figure between 10 - 100 days.
I've seen others request the addition of an option to auto-delete episodes after playback, but that does assume that you are listening via the Podcast GUI. Whereas with this approach everyone can keep things tidy and shipshape even if you're downloading the files or using the Podgrab Feed URLs to support podcast apps like AntennaPod or podcast plugins in local players like Squeezebox or Volumio.
I think this could be done with a simple bash or python script. It would be nice to include of course but since Podgrab just runs on a computer/server it is way easier to extend its features with scripts than a podcast app on Android/iOS
If you're on a Linux based system you could try the following:
find . -type f -daystart -mtime +7 -print
This searches the parent directory recursively for files modified more than 7 days ago based on the start of the current day. Replace -print
with -delete
once you've tried it out and it looks like it's finding the correct files.
You could run this once a day with a cron job but this isn't very sophisticated so if you wanted to setup certain podcasts to keep files for longer than the others you would have to do something like this:
find {/path/to/folder/A,/path/to/folder/B} -type f -daystart -mtime +1 -print
In a script you could add the file paths to a variable and make it easier to add or remove podcasts from.
#!/usr/bin/env bash
# podcasts to be deleted after 5 days
podcastA=/path/to/specific/podcast/directory
podcastB=/path/to/specific/podcast/directory
podcastC=/path/to/specific/podcast/directory
podcastD=/path/to/specific/podcast/directory
# podcasts to be delete after 7 days
podcastE=/path/to/specific/podcast/directory
podcastF=/path/to/specific/podcast/directory
find {$podcastA,$podcastB,$podcastC,$podcastD} -type f -daystart -mtime +5 -print
find {$podcastE,$podcastF} -type f -daystart -mtime +7 -print
Something like that. Remember replace -print
with -delete
once you verify it's working correctly. I'm no script genius so maybe there's a better way but this is what I could come up with in a few minutes.
You could probably format it like this:
find \
{$podcastA,\
$podcastB,\
$podcastC,\
$podcastD} \
-type f -daystart -mtime +5 -print
And then it's easier to look at it like a vertical list.
One thing to note is that this will find and delete the podcast image if you have Podgrab set to download that.
Please +1 for this functionality