![]() |
#1 | ||
Member
![]() Posts: 21
Karma: 10
Join Date: Jun 2015
Device: Kindle
|
Only keep x days of news downloads
I am making all of my news downloads work via script files and want an easy way to limit the amount of news downloads for a particular recipe to x number of days. Is there an easy way to do it? I could probably do it in a bash script but am not that familiar with it.
Also, I and using Quote:
Quote:
Last edited by BoundforPNG; 09-28-2015 at 04:49 AM. |
||
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The calibre gui has an option for that. If you dont want to use it, then you will have to script up your own solution for it using calibredb
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Enthusiast
![]() Posts: 40
Karma: 10
Join Date: Oct 2012
Device: Pocket Book Touch HD3
|
Hi,
I wrote a perl script for this problem. I am not really good at perl. I am quite sure that there are solutions more elegant than mine but it works for me. So here is my code. Take care to use YOUR tags in line 17 if you did not choose the german word for dailynews ("Tageszeitung") ![]() Code:
#!/usr/bin/perl -w # file: cal_ex_alt_zeit.pl # Author: Sebastian # Version: 1.2 # # This script deletes news from calibre database that are older than 2 days # Three steps to do this: # 1. collect a list of old newspapers # 2. extract the IDs of those old newspapers # 3. tell calibredb to delete those IDs # 1. Collect a list of old newspapers open(CALINDEX,">","old_newspapers.txt"); my @get_list = (" CALIBRE_OVERRIDE_LANG=en calibredb list --search 'date:<1daysago and tags:Tageszeitung' > old_newspapers.txt"); my @get_list_exec = system(@get_list); close (CALINDEX); # 2. extract the IDs of old newspapers # 2.1. extract IDs open(CALINDEX,"old_newspapers.txt");my $file = CALINDEX; my @cal_index; foreach my $line ( <$file> ) { if ( $line =~ /^\d/) { push @cal_index, substr $line,0,5; } } chomp @cal_index; # 2.2 substitute blank characters by commata open(DELINDEX,">","del_cal_index.txt"); print DELINDEX @cal_index; close(DELINDEX); open(DELINDEX,"del_cal_index.txt"); my $cal_ids = <DELINDEX>; $cal_ids =~ s/\s/,/g; $cal_ids =~ s/,$//; chomp $cal_ids; print $cal_ids; close (DELINDEX); close(CALINDEX); # 3. give list of IDs to calibredb for deletion: system("/usr/bin/calibredb","remove",$cal_ids) == 0 or die "system failed: $?"; Sebastian Last edited by sws; 10-01-2015 at 03:47 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
News downloads | babbish1 | Recipes | 0 | 03-31-2012 01:37 PM |
news downloads | Blaine L | Calibre | 2 | 03-08-2012 06:49 PM |
Downloads yesterdays news | deppeler | Recipes | 0 | 01-12-2011 11:56 AM |
Sllooooowwwww news downloads | syfr | Calibre | 8 | 01-22-2010 07:28 AM |
News Downloads timing | ccadi | Calibre | 2 | 01-19-2009 12:11 PM |