This project is read-only.
MOBI,PRC internals
MobiLib Reference

Tools:
MobiEdit
SimpleTool

First program: only open file and show its metadata

using MobiLibrary;// and reference to MobiLib.dll

static void Main(string[] args)
{
    MobiLib ml = new MobiLib();
    //
    if(ml.ReadFile("9780735656949.mobi"))
    {
        ml.ShowInfo();
    }
    //
    return;
}//Main

Result:

--[9780735656949.mobi]----------------------------------
Name: [Microsoft169-ywhere_Anytime]
CreationTime: 2011-09-14 14:17:55
ModificationTime: 2011-09-14 14:18:07
BackupTime: 1970-01-01 00:00:00
FullName: [Microsoft© Office 365: Connect and Collaborate Virtually Anywhere, Anytime]
TextEncoding: Windows-1252 Western European languages(1252)
Locale: en (English/0x9)
InputLanguage: Unknown (0x0)
OutputLanguage: Unknown (0x0)
EXTHDR:
EXTH_header(10):
  0) PublishingDate(106): [2011]
  1) Author(100): [Katherine Murray]
  2) Publisher(101): [Microsoft Press]
  3) Rights(109): [All rights reserved]
  4) Type(111): [Text]
  5) fontsignature(300): [(58):3,0,0,0,64,0,0,0,0,0,0,0,0,0,0,128,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,237,236,190,1,174,1,169,1,183,64,148,64,147,64,153,64,152,64,156,64,157,64,162,68,146]
  6) Creator Software(204): [1]
  7) Creator Major Version(205): [6]
  8) Creator Minor Version(206): [2]
  9) Creator Build Number(207): [43]
.



Second program: with metadata modifications

MobiLib ml = new MobiLib();

ml.ReadFile("9780735656949.mobi");

ml.CreationTime = DateTime.Now;// current Creation Time

ml.FullName = "My first book";// book title - in booth places; ml.Name is obsolete
ml.Name = ml.FullName;

ml.exthAuthor = "ME! ME!";

ml.exthPublisher = "Meow publisher";

ml.Locale = LanguageCodes.Name2LCID("fr");// LanguageCodes.Name2LCID() converts name of language into number called LCID

ml.exthDeleteType(300);// What is fontsignature? We don't need this. (Why 300? because  `5) fontsignature(300):'

ml.ShowInfo();

ml.WriteFileAs("my_book.mobi");// and we have new file

Result:

--[9780735656949.mobi]----------------------------------
Name: [My first book]
CreationTime: 2011-11-15 20:36:23
ModificationTime: 2011-09-14 14:18:07
BackupTime: 1970-01-01 00:00:00
FullName: [My first book]
TextEncoding: Windows-1252 Western European languages(1252)
Locale: fr (Francuski/0xC)
InputLanguage: Unknown (0x0)
OutputLanguage: Unknown (0x0)
EXTHDR:
EXTH_header(9):
  0) PublishingDate(106): [2011]
  1) Author(100): [ME! ME!]
  2) Publisher(101): [Meow publisher]
  3) Rights(109): [All rights reserved]
  4) Type(111): [Text]
  5) Creator Software(204): [1]
  6) Creator Major Version(205): [6]
  7) Creator Minor Version(206): [2]
  8) Creator Build Number(207): [43]
.

In Calibre e-book viewer

Second program

Third program: batch metadata modifications

MobiLib ml = new MobiLib();
List<string> l = new List<string>();
//
l = Directory.GetFiles(".", "*.mobi", SearchOption.TopDirectoryOnly).ToList().Union<string>(Directory.GetFiles(".", "*.prc", SearchOption.TopDirectoryOnly)).ToList<string>();// all files *.mobi and *.prc
l.Sort();
//
foreach (string f in l)
{
    if (ml.ReadFile(f))
    {
        ml.Locale = LanguageCodes.Name2LCID("pl");//polish
        ml.exthPublisher = "me";
        ml.WriteFile();
        Console.WriteLine("=>{0}", f);
    }
    else
    {
        Console.WriteLine("ERROR: {0}", f);
    }
}


Fourth program: with ListBox control (or other control)

listBox1.DisplayMember = "OneLine";

bindingSource1.DataSource = ml.EnumAll;
listBox1.DataSource = bindingSource1;

Last edited Jan 4, 2012 at 10:26 AM by Miroslaw_Maczka, version 20

Comments

No comments yet.