View Full Version : How to disable conversion date in title and source link in page?


siebert
11-19-2010, 06:07 AM
Hi,

I'm using the python recipe for brand eins and there are two thinks I'd like to change in the generated epubs:

- The ebook title is set from the recipe, but calibre seems to append automatically the conversion date in brackets. Is it possible to prevent that from the recipe?

- At the end of each source page there is a note that it was converted via calibre and a link to the source url. Is it possible to disable this note and link from the recipe?

Ciao,
Steffen

kovidgoyal
11-19-2010, 05:52 PM
no and no

siebert
11-20-2010, 03:06 AM
Hi,

I've seen from other recipes that adding the line
timefmt = ''
fixes my first issue (probably as a side effect, but it seems to work).

If the second one isn't possible now, could you implement a switch to disable it or a function to override in a future version of calibre?

Thanks,
Steffen

kovidgoyal
11-20-2010, 10:12 AM
I have no interest in doing that, but patches are welcome.

siebert
11-21-2010, 07:40 AM
no and no

You lied, nothing is impossible in python :D

Proof is here:
http://www.mobileread.com/forums/showthread.php?p=1227446

I admit that the solution is ugly as I have to replicate lots of code, so a switch within calibre would be very nice.

Ciao,
Steffen

Consti
11-21-2010, 08:26 AM
@kovidgoyal: Please include the new version of the Recipe in the next version of Calibre.

The newest version can be found here:
https://github.com/consti/BrandEins-Recipe/raw/master/brandeins.recipe

It includes changes made by Steffen;

Thanks!

kovidgoyal
11-21-2010, 10:26 AM
well sure you can do pretty much anything in principle. But I am not going to put those changes into the builtin recipe. You are of course free to continue using the custom recipe for yourself :)

siebert
11-21-2010, 12:53 PM
well sure you can do pretty much anything in principle. But I am not going to put those changes into the builtin recipe.

Am I correct if I assume that you only don't like the feature described below to be included in the builtin recipe or is there anything else? I could submit a recipe without it but all the other improvements.

NEW: Remove "This article was downloaded by calibre from..." section from bottom of each page.

Ciao,
Steffen

kovidgoyal
11-21-2010, 01:21 PM
I've already merged the other improvements.

Starson17
11-21-2010, 01:22 PM
Am I correct if I assume that you only don't like the feature described below to be included in the builtin recipe or is there anything else? I could submit a recipe without it but all the other improvements.
Ciao,
Steffen
My philosophy is to try to build recipes that are consistent with other built-ins.
In this list:

NEW: The issue to download can be selected via the username field.
NEW: Add cover image.
NEW: Prevent that conversion date is appended to title.
NEW: Remove "This article was downloaded by calibre from..." section from bottom of each page.
FIXED: "brand eins" is written in lowercase.

Numbers 2 and 5 are consistent. Numbers 1, 3 and 4 I would make as optional via an edit by the user in a custom recipe, and explain them in the description. Of course, Kovid is the final arbiter.

siebert
11-21-2010, 01:29 PM
I've already merged the other improvements.

Thats great.

Ciao,
Steffen

siebert
11-21-2010, 05:47 PM
I've already merged the other improvements.

Hi,

I've noticed that you also removed the timefmt = '' line. Could you tell me the reason why you don't like that change?

This feature used by serveral other official recipes and as the brand eins recipe fetches complete issues from the web archive, the content should always be the same regardless of the conversion date, so I see no point in including it in the title.

Ciao,
Steffen

kovidgoyal
11-21-2010, 09:05 PM
I'm confused are you saying the downloaded content will be the same if I run the recipe today and a onth from now, the resulting ebook will be the same?

dates in titles are useful or people that use ereadres that don't allow sorting by dates/dont display dates in their UI

siebert
11-22-2010, 03:56 AM
I'm confused are you saying the downloaded content will be the same if I run the recipe today and a onth from now, the resulting ebook will be the same?

Essentially, yes.

By default, the recipe fetches the last fully available issue (as for the latest issue, the one which is currently sold at the news stands, only a few selected articles are available online, so the recipe defaults to the issue before the current one to get a complete issue) from the archive, so if I run the recipe today and in a month, I'll probably get two different issues downloaded. But if I download the same issue (for example by modifing the issue selection in the recipe or now via the username setting) again in a month, the content will be the same as it is now.

brand eins is a monthly published print magazine, but they are kind enough to have all their back issues available for free on their online web archive. So I'd like to have the output of this calibre recipe as close as possible to an electronic version of their printed magazine, resembling an EPUB issue of brand eins they would probably publish themselves.


dates in titles are useful or people that use ereadres that don't allow sorting by dates/dont display dates in their UI

As the brand eins EPUB title already includes the month and year of the magazine it contains (for example the title is "brand eins 10/2010" for the october issue of 2010), all information I need to identify and sort this ebook is already available in the title and the conversion date doesn't add any useful information to it, so I'd like to get rid of it.

I hope you can now understand my motivation of that change.

Ciao,
Steffen

kovidgoyal
11-22-2010, 11:58 AM
In that case, the better approach is that rather than setting self.title, set self.timefmt.

See for example the Atlantic recipe.

siebert
11-22-2010, 01:20 PM
In that case, the better approach is that rather than setting self.title, set self.timefmt.


So you propose to set self.title to "brand eins" and self.timefmt to "10/2010" for the october issue? What is the benefit of doing it this way?

Ciao,
Steffen

kovidgoyal
11-22-2010, 01:44 PM
it's far more semantic and the rest of the conversion pipeline can use the information as appropriate

siebert
11-23-2010, 06:33 AM
Ok, here is the patch against the latest checked-in version:


*** brand_eins_orig.recipe Tue Nov 23 08:12:11 2010
--- brand_eins.recipe Tue Nov 23 08:25:53 2010
***************
*** 91,98 ****
latest_jahrgang = soup.findAll('div', attrs={'class': re.compile(r'\bjahrgang-latest\b') })[0].findAll('ul')[0]
pre_latest_issue = latest_jahrgang.findAll('a')[len(latest_jahrgang.findAll('a'))-issue]
url = pre_latest_issue.get('href', False)
! # Get the title for the magazin - build it out of the title of the cover - take the issue and year;
! self.title = "brand eins "+ re.search(r"(?P<date>\d\d\/\d\d\d\d)", pre_latest_issue.find('img').get('title', False)).group('date')
url = 'http://brandeins.de/'+url

# url = "http://www.brandeins.de/archiv/magazin/tierisch.html"
--- 91,100 ----
latest_jahrgang = soup.findAll('div', attrs={'class': re.compile(r'\bjahrgang-latest\b') })[0].findAll('ul')[0]
pre_latest_issue = latest_jahrgang.findAll('a')[len(latest_jahrgang.findAll('a'))-issue]
url = pre_latest_issue.get('href', False)
! # Magazin title
! self.title = "brand eins"
! # Get month and year of the magazine issue - build it out of the title of the cover
! self.timefmt = " " + re.search(r"(?P<date>\d\d\/\d\d\d\d)", pre_latest_issue.find('img').get('title', False)).group('date')
url = 'http://brandeins.de/'+url

# url = "http://www.brandeins.de/archiv/magazin/tierisch.html"


Ciao,
Steffen

Consti
11-26-2010, 12:57 AM
I've reverted Steffens changes until further notice.
I have to look in the changes.. sorry for including them so fast.

I am in Beijing right now, so I'll look into it as soon as I am back home.

@steffen: Sorry for reverting the changes. Lets talk about it as soon as I am back (should be in one week or so :) )