Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 09-28-2015, 04:36 AM   #1
BoundforPNG
Member
BoundforPNG began at the beginning.
 
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:
xvfb-run calibredb add /home/cts/calibre-library/toadd/ -r --with-library /home/cts/calibre-library
in a crontab and am getting the following email every time it runs when there is nothing to add. Can I suppress this message and only get real error messages?
Quote:
Backing up metadata
Notifying calibre of the change

Last edited by BoundforPNG; 09-28-2015 at 04:49 AM.
BoundforPNG is offline   Reply With Quote
Old 09-28-2015, 07:51 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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
kovidgoyal is offline   Reply With Quote
Advert
Old 09-30-2015, 02:58 AM   #3
sws
Enthusiast
sws began at the beginning.
 
sws's Avatar
 
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: $?";
Regards,
Sebastian

Last edited by sws; 10-01-2015 at 03:47 AM.
sws is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 05:47 AM.


MobileRead.com is a privately owned, operated and funded community.