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 07-24-2014, 10:11 PM   #1
yang738
Member
yang738 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jun 2014
Device: kindle fire hd
my first plugin did not work

I have tried the hello world plugin , but it didn't work.

I have set up the environment variable: calibre_develop_from.

D:\Development\Calibredev>dir

25/07/2014 11:57 1,070 __init__.py

D:\Development\Calibredev>calibre-customize -b .
Plugin updated: Hello World Plugin (1, 0, 0)


I added a txt file to calibre , and converted into epub file.

I hope to change the metadata during the converting, just like what the hello world plugin did. but it didn't change anything.

the following is the hello world plugin : any one can kindly help me to do the first plugin? thanks in advance.


import os
from calibre.customize import FileTypePlugin

class HelloWorld(FileTypePlugin):

name = 'Hello World Plugin' # Name of the plugin
description = 'Set the publisher to Hello World for all new conversions'
supported_platforms = ['windows', 'osx', 'linux'] # Platforms this plugin will run on
author = 'Acme Inc.' # The author of this plugin
version = (1, 0, 0) # The version number of this plugin
file_types = set(['epub', 'txt']) # The file types that this plugin will be applied to
on_postprocess = True # Run this plugin after conversion is complete
minimum_calibre_version = (0, 7, 53)

def run(self, path_to_ebook):
from calibre.ebooks.metadata.meta import get_metadata, set_metadata
file = open(path_to_ebook, 'r+b')
ext = os.path.splitext(path_to_ebook)[-1][1:].lower()
mi = get_metadata(file, ext)
mi.publisher = 'Hello World'
set_metadata(file, mi, ext)
return path_to_ebook
yang738 is offline   Reply With Quote
Old 07-24-2014, 10:13 PM   #2
yang738
Member
yang738 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jun 2014
Device: kindle fire hd
actually, I want to develop a plugin with the following function:

1: it can get meta from txt file and update the calibre metadata.

2:it can update the metadata when I select one file and click a button.


who can kindly guide to complete this plugin? thanks.

Stephen
yang738 is offline   Reply With Quote
Advert
Old 07-24-2014, 10:16 PM   #3
yang738
Member
yang738 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jun 2014
Device: kindle fire hd
I set up the environment variable , but echoing it not working.

what's wrong with it?

Stephen


C:\Users\Administrator>echo $CALIBRE_DEVELOP_FROM
$CALIBRE_DEVELOP_FROM

C:\Users\Administrator>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Administrator\AppData\Roaming
asl.log=Destination=file
CALIBRE_DEVELOP_FROM=d:\development\calibre\src
yang738 is offline   Reply With Quote
Old 07-24-2014, 10:32 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by yang738 View Post
actually, I want to develop a plugin with the following function:

1: it can get meta from txt file and update the calibre metadata.

2:it can update the metadata when I select one file and click a button.


who can kindly guide to complete this plugin? thanks.
As with all things plugin related, you should look at kiwidude's plugins. For this, there is already the Import List plugin. While it is intended for creating books from a list, one of the features listed is "Option to update metadata of existing books". Odds are you can use this plugin directly, or use it as a base for your own.
davidfor is offline   Reply With Quote
Old 07-24-2014, 10:35 PM   #5
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by yang738 View Post
C:\Users\Administrator>echo $CALIBRE_DEVELOP_FROM
$CALIBRE_DEVELOP_FROM
The command is wrong for Windows. It should be:

Code:
echo  %CALIBRE_DEVELOP_FROM%
davidfor is offline   Reply With Quote
Advert
Old 07-24-2014, 10:43 PM   #6
yang738
Member
yang738 began at the beginning.
 
Posts: 11
Karma: 10
Join Date: Jun 2014
Device: kindle fire hd
thanks so much for your posting.
yang738 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] KindleUnpack - The Plugin DiapDealer Plugins 527 08-15-2025 01:36 PM
Calibre's collections plugin didn't work atp Library Management 4 03-12-2012 08:01 PM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 02:24 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM
New Plugin Type Idea: Library Plugin cgranade Plugins 3 09-15-2010 12:11 PM


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


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