#2773: support info in pdf/epub/mobi.
[librarian.git] / librarian / packagers.py
index ebeb5b3..ddfd7c8 100644 (file)
@@ -75,7 +75,7 @@ class PrestigioPdfPackager(PdfPackager):
     flags = ('less-advertising',)
 
 
     flags = ('less-advertising',)
 
 
-class VirtualoEpubPackager(Packager):
+class VirtualoPackager(Packager):
     @staticmethod
     def utf_trunc(text, limit):
         """ truncates text to at most `limit' bytes in utf-8 """
     @staticmethod
     def utf_trunc(text, limit):
         """ truncates text to at most `limit' bytes in utf-8 """
@@ -130,15 +130,19 @@ class VirtualoEpubPackager(Packager):
                 product_elem[4][0][1].text = cls.utf_trunc(info.author.last_name, 100)
                 xml.append(product_elem)
 
                 product_elem[4][0][1].text = cls.utf_trunc(info.author.last_name, 100)
                 xml.append(product_elem)
 
-                cover.VirtualoCover(
-                    u' '.join(info.author.first_names + (info.author.last_name,)),
-                    info.title
-                    ).save(os.path.join(outfile_dir, slug+'.jpg'))
+                cover.VirtualoCover(info).save(os.path.join(outfile_dir, slug+'.jpg'))
                 outfile = os.path.join(outfile_dir, '1.epub')
                 outfile_sample = os.path.join(outfile_dir, '1.sample.epub')
                 outfile = os.path.join(outfile_dir, '1.epub')
                 outfile_sample = os.path.join(outfile_dir, '1.sample.epub')
-                doc.save_output_file(epub.transform(doc),
+                doc.save_output_file(doc.as_epub(),
                         output_path=outfile)
                         output_path=outfile)
-                doc.save_output_file(epub.transform(doc, sample=25), 
+                doc.save_output_file(doc.as_epub(doc, sample=25), 
+                        output_path=outfile_sample)
+                outfile = os.path.join(outfile_dir, '1.mobi')
+                outfile_sample = os.path.join(outfile_dir, '1.sample.mobi')
+                doc.save_output_file(doc.as_mobi(cover=cover.VirtualoCover),
+                        output_path=outfile)
+                doc.save_output_file(
+                        doc.as_mobi(doc, cover=cover.VirtualoCover, sample=25), 
                         output_path=outfile_sample)
         except ParseError, e:
             print '%(file)s:%(name)s:%(message)s' % {
                         output_path=outfile_sample)
         except ParseError, e:
             print '%(file)s:%(name)s:%(message)s' % {