Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old Yesterday, 11:15 AM   #1
primolarry
Junior Member
primolarry began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2016
Device: Kindle voyage
How to obtain the URL of the article in postprocess_html

Hi there,

I have coded a recipe that retrieves URL from Todoist (task app) and builds an epub

https://github.com/rga5321/todoist2e...Todoist.recipe

I would like to recover the URL of every article so I can add it in the HTML (it is coded in a separate part of the project, but it doesn't work. I want to do it inside the recipe)

In parse_index, for every chapter, I add every article with these metadata (line 178):
Code:
                                        arts.append({
                                          'title': title,
                                          'url': url,
                                          'date': item['date_added']})
But I don't know how to recover the "url" metadata in postprocess_html(self, soup, first), where I don't have the article object.

Can anyone point me in the right direction?

Thanks a lot, regards
primolarry is offline   Reply With Quote
Old Yesterday, 11:36 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,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre add a footer with the URL each article was fetched from automatically, you dont need to do anything.
kovidgoyal is offline   Reply With Quote
Old Yesterday, 11:54 AM   #3
primolarry
Junior Member
primolarry began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2016
Device: Kindle voyage
Hi kovidgoyal,

Thanks for your reply. Where does it do it, exactly? Because I must be overriding the function that does it, as the calibre footer that you mention doesn't appear in the ebook generated with my recipe.

Thanks,
primolarry is offline   Reply With Quote
Old Yesterday, 03:29 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,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
IIRC if you have your output profile set to kindle it wont, for epub with a non kindle profile it will. And it happens in _postprocess_html() I think
kovidgoyal is offline   Reply With Quote
Old Today, 11:40 AM   #5
primolarry
Junior Member
primolarry began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Sep 2016
Device: Kindle voyage
Hi kovidgoyal,

Are you sure that it is done in postprocess_html? I have:

- Commented my postprocess_html function, so the default one is used
- Forced the generic_eink profile while running the recipe with ebook-convert (--output-profile=generic_eink)

And still the articles doesn't have the footer.

If you could point me to the code in calibre that does it I would really appreciate it.

Regards,
primolarry is offline   Reply With Quote
Old Today, 12:44 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,410
Karma: 27757236
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Note the leading underscore
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert article URL? Mixx Recipes 4 01-09-2014 01:26 PM
Article download fails if I use postprocess_html function oecherprinte Recipes 3 11-26-2013 04:17 PM
New York Times - Link to article URL? gianfri Recipes 2 11-09-2013 09:53 PM
Get article URL in postprocess_html rmflight Recipes 5 11-29-2012 11:37 AM
Trying to strip the date from an article URL Finbar127 Recipes 1 02-17-2011 03:02 PM


All times are GMT -4. The time now is 05:29 PM.


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