| 
			
			 | 
		#1 | 
| 
			
			
			
			 Junior Member 
			
			![]() Posts: 6 
				Karma: 10 
				Join Date: Mar 2009 
				
				
				
				Device: Kindle 2 
				
				
				 | 
	
	
	
		
		
			
			 
				
				Getting book's id number programatically
			 
			
			
			Is there a faster/easy way to get the id number of a book through an API function? The only way I have found to do this is to execute calibredb with the 'list' function and scan the returned list for the book title and author. With a large catalog, that can take a considerable amount of time. 
		
	
		
		
		
		
		
		
		
		
		
		
	
	I have to think there must be a faster, and hopefully easier, way. Thanks, ~~ Grey  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Sigil & calibre developer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487 
				Karma: 1063785 
				Join Date: Jan 2009 
				Location: Florida, USA 
				
				
				Device: Nook STR 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			How are you accessing calibre? Through a plugin? Though an external app that gets and then manipulates the data? 
		
	
		
		
		
		
		
		
		
		
		
		
	
	If you're using a plugin you can get the database object from the library_view. Then calibre.library.database.LibraryDatabase can return the id for an index.  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Junior Member 
			
			![]() Posts: 6 
				Karma: 10 
				Join Date: Mar 2009 
				
				
				
				Device: Kindle 2 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			I'm sorry, I should have provided that information. I am accessing Calibre from an external program (written in Perl). 
		
	
		
		
		
		
		
		
		
		
		
		
	
	~~ Grey  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 
			
			 | 
		#4 | 
| 
			
			
			
			 Grand Sorcerer 
			
			![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,525 
				Karma: 8065948 
				Join Date: Jan 2010 
				Location: Notts, England 
				
				
				Device: Kobo Libra 2 
				
				
				 | 
	
	
	
		
		
		
		
		 
			
			By "accessing Calibre" do you mean accessing calibre's database? If so, then do the SQL query to look up the record. If you are running calibre's command line programs from perl, then you might consider using a calibredb to dump a list of all the books, load them into a dict, and then look them up there.
		 
		
	
		
		
		
		
		
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
            
        
    
            
  | 
    
			 
			Similar Threads
		 | 
	||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| How do I use Calibre to change a book's cover? | Mike L | Calibre | 8 | 08-24-2013 01:26 AM | 
| PRS-950 Book's there, where are the pages? | Flygrl | Sony Reader | 9 | 06-06-2011 06:41 PM | 
| E-book's you want to see being made? | ebook creator | General Discussions | 29 | 03-14-2011 07:49 PM | 
| How to change the way Calibre save book's filename? | vne | Calibre | 4 | 10-21-2010 01:41 PM | 
| Could lack of piracy be the e-book's demise? | TadW | News | 44 | 02-12-2009 06:34 PM |