Hi
I am also having a tough time trying to use a Calibre recipe to download an epub from newsmemory.com. In my case the publication is the Fall River Herald News but I suspect the logic would be similar. I am able to download the epub file using a quick and dirty linux script that basically has 2 wget commands, the first wget does a post of the username and password, the second wget download the epub file.
I'm not a python developer so I really having a hard time implementing this as a recipe. I have read the tutorials and the posting about epub downloading from Starson17 and achims. But I'm not getting too far. Having cleared up initial indentation issues my recipe completes without errors but the epub is not downloaded.
I suspect my code is not even being invoked as I am unable to see the output of my print statements. Can anyone please get me repointed in the right direction ?
Here is the code I am using with the command:
ebook-convert frhn.recipe frhn -vvv --username myusername --password mypassword
Code:
class AdvancedUserRecipe1415485404(BasicNewsRecipe):
title = u'FallRiverHeraldNews'
oldest_article = 7
max_articles_per_feed = 100
auto_cleanup = True
needs_subscription = True
feeds = [(u'Fall River Herald News', u'http://fallriverheraldnews.ma.newsmemory.com/ebook.php?page=downloadEbooks&device=android')]
def get_browser(self):
br = BasicNewsRecipe.get_browser()
print 'You have entered get_browser '
if self.username is not None and self.password is not None:
br.open('http://fallriverheraldnews.ma.newsmemory.com/ebook.php?page=downloadEbooks&device=android')
br.select_form(name='Log in')
br['USERID'] = self.username
br['PASSWORD'] = self.password
br.submit()
return br
def build_index(self):
print 'You have entered build_index '
epub_url = "http://fallriverheraldnews.ma.newsmemory.com/ebook.php?page=downloadEbooks&device=android&date=20141109&token="
url = epub_url
f = urllib2.urlopen(url)
tmp = PersistentTemporaryFile(suffix='.epub')
self.report_progress(0,_('downloading epub'))
tmp.write(f.read())
tmp.close()
zfile = zipfile.ZipFile(tmp.name, 'r')
self.report_progress(0,_('extracting epub'))
zfile.extractall(self.output_dir)
tmp.close()
index = os.path.join(self.output_dir, 'content.opf')
self.report_progress(1,_('epub downloaded and extracted'))
print 'You have leaving build_index '
return index