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 06-28-2012, 08:49 AM   #1
Zeno_
Member
Zeno_ began at the beginning.
 
Zeno_'s Avatar
 
Posts: 21
Karma: 10
Join Date: Jun 2012
Device: Sony PRS-T1
Download ePub from url? [unprotected]

I need to get an ePub from an URL, so for example from:

Code:
http://example.com/download/20120628/20120628download.epub
I have zero Python-knowledge, but I can imagine a part of the script will look like:

Code:
'http://example.com/download/' + %Y + %m + %d + '/' + %Y + %m + %d + 'download.epub'
The ePub is correctly formatted and all, so downloading the ePub and adding it to Calibre is the only thing the recipe needs to do!

Help is greatly appreciated.

Last edited by Zeno_; 06-28-2012 at 08:51 AM.
Zeno_ is offline   Reply With Quote
Old 06-28-2012, 09:10 AM   #2
wmfs
Member
wmfs began at the beginning.
 
Posts: 14
Karma: 10
Join Date: Jun 2012
Device: snoy
My Python knowledge is little better the yours I'm afraid Zeno_, but I do have a Perl script that I've used in the past to save a pdf file to my computer from a url, and I suspect it would also work for ePub files.

Hope this helps.

WmFS

#===========================================
# DownloadPDF.pl
#===========================================
# Set $file to name of the output file
# Set $url to remote file
#===========================================

use LWP::UserAgent;

$file = "The Perl Review (March 2002).pdf";
$url = "https://www.theperlreview.com/Issues/The_Perl_Review_0_1.pdf";

$ua = LWP::UserAgent->new;
$req = HTTP::Request->new(GET => $url);
$res = $ua->request($req);

if ($res->is_success)
{
open OUTFILE, ">" . $file;
$record = $res->content;
print OUTFILE $record;
close OUTFILE;
}
else
{
print "Failed to download $url\n";
$record = $res->content;
print $record;
}

Last edited by wmfs; 06-28-2012 at 09:15 AM.
wmfs is offline   Reply With Quote
Advert
Old 06-28-2012, 12:32 PM   #3
Zeno_
Member
Zeno_ began at the beginning.
 
Zeno_'s Avatar
 
Posts: 21
Karma: 10
Join Date: Jun 2012
Device: Sony PRS-T1
Thanks for the script wmfs, but I don't think I could turn it into a recipe to use with Calibre.

edit: Found using old NRC Handelsblad recipe

Last edited by Zeno_; 06-28-2012 at 03:20 PM.
Zeno_ is offline   Reply With Quote
Old 06-29-2012, 08:46 PM   #4
sdow1
Connoisseur
sdow1 began at the beginning.
 
Posts: 55
Karma: 10
Join Date: Apr 2010
Location: new york city
Device: nook, ipad
If it's a one-time download, as opposed to something you're trying to automate for repeated download, you could also just use dotepub (http://dotepub.com/).

This, combined with the 'automatic adding' feature that calibre added recently makes it extremely easy to go directly from a web page article to an epub in calibre. (I literally just hit the dotepub bookmark on my toolbar when I want to save an article and 20 seconds later it's sitting in my calibre library.)

Only caveat is that the entire content needs to be on the page you're viewing - most sites have a 'single page' or 'print version' option, but some don't.

ETA: I just realized that the file is already an epub embedded in a website. Not quite the same thing.
sdow1 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Source URL / Automated Download Demosthenex Library Management 10 04-26-2012 07:27 AM
Print friendly url unrelated to regular url (and javascript) sleepless Recipes 3 12-03-2011 10:43 AM
Simple download from rss url recipe BloodOmen Recipes 0 02-16-2011 09:21 PM
Gen3 CyBook Gen3 User Guide Download URL HarryT Bookeen 11 01-13-2010 02:27 PM
Connect Reader Software - Download URL NatCh Sony Reader 13 10-17-2007 11:41 AM


All times are GMT -4. The time now is 04:46 PM.


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