Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-27-2020, 06:43 PM   #1
wiggida
Member
wiggida began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite
Smile Scheduled download of epub file

Hi

Can someone point me in the right direction of setting up a scheduled download for a file which is already an *.epub?

This is the website: https://www.themonthly.com.au/ebook

You need to login to get behind the paywall, but then you can see the epub files ready to download. I have been manually downloading & emailing via calibre.

I would like to create a recipe similar to those for RSS feeds, to auto download this file & email to my Kindle. Can anyone point me in the right direction?

Many thanks
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2020-12-28 at 10.40.43 am.jpg
Views:	87
Size:	181.5 KB
ID:	184295  
wiggida is offline   Reply With Quote
Old 12-27-2020, 06:50 PM   #2
wiggida
Member
wiggida began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite
I should have added - I have spent ages digging through the forums, and haven't found anything useful. I might be using the wrong search terms? I know enough about coding to be dangerous, but that's about it....
wiggida is offline   Reply With Quote
Advert
Old 12-27-2020, 07:50 PM   #3
wiggida
Member
wiggida began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite
Update

Update: I found this thread & have been fiddling with the Taz Digiabo code
https://www.mobileread.com/forums/sh....php?p=3849639

Can someone tell me what "realm" should be - I think this is from the original taz digiabo code

domain = "https://www.themonthly.com.au"

url = domain + "/ebook/"

auth_handler = HTTPBasicAuthHandler()
auth_handler.add_password(realm='TAZ-ABO',
uri=url,
user=self.username,
passwd=self.password)
opener = build_opener(auth_handler)


I think my highlight on the below shows I'm close to getting it to work, but the code is falling over somewhere, the output is as shown - a bunch of HTML, it doesn't seem to be logging in / finding the epub file.

Any tips? Many thanks
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2020-12-28 at 11.46.00 am.png
Views:	80
Size:	579.7 KB
ID:	184296  
wiggida is offline   Reply With Quote
Old 12-27-2020, 10:38 PM   #4
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,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I highly doubt that website uses http basic for auth. You will need to use the form based login.
kovidgoyal is offline   Reply With Quote
Old 12-27-2020, 10:58 PM   #5
wiggida
Member
wiggida began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite
I’m not sure what that means? Can you show me how to access the form based login?

Many thanks!
wiggida is offline   Reply With Quote
Advert
Old 12-27-2020, 11:00 PM   #6
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,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
See get_browser() here: https://manual.calibre-ebook.com/new...l-life-example

you will need to adapt it to use whatever form is on the website you are using.
kovidgoyal is offline   Reply With Quote
Old 12-27-2020, 11:17 PM   #7
wiggida
Member
wiggida began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Oct 2020
Device: Kindle Paperwhite
I'm getting this error:

TypeError: get_browser() missing 1 required positional argument: 'self'

But I can't work out what the error is. I've only ever learnt to program in Fortran (!) so I'm feeling a bit in the dark here.

I don't know if it's obvious to you what's going wrong from the copy & paste below? It's my mashup of the Taz Digiabo & the get_browser you referenced??

Many thanks!
Spoiler:
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__license__ = 'GPL v3'
__copyright__ = '2010, Lars Jacob jacob.lars at gmail.com'
__docformat__ = 'restructuredtext de'

'''
KB The Monthly
'''
import os
import zipfile
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ptempfile import PersistentTemporaryFile
try:
    from urllib.request import HTTPBasicAuthHandler, build_opener, install_opener, urlopen
    from urllib.error import HTTPError
except ImportError:
    from urllib2 import HTTPBasicAuthHandler, build_opener, install_opener, urlopen, HTTPError


class KBMonthly(BasicNewsRecipe):

    title = u'KBM'
    description = u'Attempting to download'
    language = 'EN'
    lang = 'en-EN'

    __author__ = 'Kate'
    needs_subscription = True

    conversion_options = {
        'no_default_epub_cover': True
    }

#    def build_index(self):
#        domain = "https://www.themonthly.com.au"
#
#        url = domain + "/ebook/"
#
#        auth_handler = HTTPBasicAuthHandler()
#        auth_handler.add_password(realm='TAZ-ABO',
#                                  uri=url,
#                                  user=self.username,
#                                  passwd=self.password)
#        opener = build_opener(auth_handler)
#        install_opener(opener)
#
#        try:
#            f = urlopen(url)
#            except HTTPError:
#            self.report_progress(0, _('Can\'t login to download issue'))
#            raise ValueError('Failed to login, check your username and'
#                             ' password')


    def get_browser(self):
        br = BasicNewsRecipe.get_browser()
        if self.username is not None and self.password is not None:
            br.open('https://www.themonthly.com.au/ebook/')
            br.select_form(name='login')
            br['USERID']   = self.username
            br['PASSWORD'] = self.password
            br.submit()
        return br

        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'))

        return index


calibre_most_common_ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'

Last edited by PeterT; 12-28-2020 at 05:01 AM.
wiggida is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Download all custom recipes (not only scheduled ones) bobodude Recipes 2 09-12-2019 11:54 AM
Auto Retry if Scheduled download fails stevesout Calibre 1 03-14-2018 11:26 PM
Scheduled news download epub contains massive TOC button wear_a_helmet Library Management 4 11-10-2012 12:31 PM
Guardian scheduled download failing nickd Recipes 2 04-10-2011 04:35 AM
scheduled download of periodicals naskoboy Library Management 1 03-01-2011 05:40 PM


All times are GMT -4. The time now is 07:16 PM.


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