如何从iBooks收集所有笔记和精彩集锦?


13

我已经阅读了iBooks中的很多重点和注释,并且希望能够以一种易于使用和操作的格式收集它们(例如,用于撰写论文和引用引号)。

例如,我想要像这样的亮点

生成一些东西(例如,用CSV)

Quod me nutrit me destruit - 维持我的东西也摧毁了我,14,Tamburlane Part One和Two,Christopher Marlowe,Anthony B. Dawson编辑,Bloomsbury,https://itun.es/us/qSrZ0.l

我可以看到如何使用iBook的“共享”功能(当然还有复制和粘贴),费力地,一次一个注意事项,但是我看不到任何方法可以批量执行,对于所有人我的笔记来自一本书,甚至我的所有书籍。

有没有办法实现这一点,例如使用Apple脚本或使用Automator?或者也许有一个包含我的笔记的文本或XML文件,并突出显示我可以编写一个脚本(最好是Python)来解析。

Answers:


11

iBooks没有AppleScript支持。该注释存储在一个SQLite文件~/Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation/

你可以尝试解析它。这个答案提供了Digested的链接,该链接读取该数据库,然后允许您将注释导出到Evernote,但我不知道它们将具有什么格式,或者如果你想弄乱Evernote。

一个(可能)简单的解决方案是在iBooks for iOS中打开这本书。然后,您可以批量发送电子邮件给自己。

  1. 打开书本
  2. 按“列表按钮”以显示目录
  3. 切换到Notes选项卡
  4. 按“共享”按钮
  5. 选择编辑备注
  6. 全选
  7. 通过电子邮件分享

编辑:

实际上,在阅读了关于reddit的评论之后,似乎还有一种方法可以从OS X上的iBooks中导出它们:

您可以通过电子邮件从Notes - >全选 - >共享导出笔记(您需要在右键单击时按住Ctrl键以保留选择)。您突出显示的部分将与您的笔记一起复制到电子邮件中,并且格式正确。奇怪的是,在Mac上,应用程序并不关心本书是否受到复制保护 - 它总是会复制突出显示的部分。iOS应用程序确实有所区别。如果您的图书受版权保护,则只会共享章节名称。这似乎是不幸的唯一方法。:/

使用笔记本电脑的触控板,我必须ctrl + shift在触控板上按住,以便在保留选择的同时显示上下文菜单。


这非常有帮助。通过将注释转换为CSV或其他方便的形式,我仍然有一段距离。我无法从SQL数据库中做任何事情,而且看起来不错的邮件不能以编程方式访问。
orome 2014年

它只是我,还是在新版本的iBooks中不再可能?我再也看不到编辑备注按钮了。在这种情况下,如何导出所有笔记?
incandescentman

@incandescentman它适用于iOS 8.4。
弗雷德

1
@incandescentman我上面的答案中的编号步骤是针对iOS的。答案的最后一部分 - “编辑”之后的部分 - 适用于OS X.这对我来说仍然适用于Yosemite。
弗雷德

2
所以,我现在在el capitan,但reddit评论的指示对我来说仍然有效。我想这个过程确实会有所不同,具体取决于您使用的是鼠标还是触控板。在没有外接键盘/鼠标的情况下使用笔记本电脑,在使用全选后选择评论后,我按下控制键+移动+点击触控板。这就提出了这个:截图。选择跨章节的评论。
弗雷德

3

我为此编写了一个脚本,它从Mac中提取笔记并输出Evernote导出文件,准备双击。也许你可以修改我的脚本,如果它不符合你的目的。

简而言之,它读取SQLite数据库:./ Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary ./Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotations

...在这种情况下,将它们导出为Evernote的.enex格式。

https://github.com/jorisw/ibooks2evernote/

    <?php
    /*
     *  iBooks notes to Evernote converter
     *  by Joris Witteman <joris@jor.is>
     *  
     *  Reads the iBooks Annotations library on your Mac and exports
     *  them, tagged with their respective book title and imported in
     *  separate notebooks.
     *
     *  Usage:
     *  
     *  Move this script to the top of your personal home directory on your Mac.
     *  This is the folder that has your name, which the Finder opens if you
     *  click on the Finder icon in the Dock.
     *
     *  To export your notes to Evernote:
     *  
     *  1. Run the following command in the Terminal:
     *
     *     php ./ibooks2evernote.php
     *    
     *  2. Open the newly created "iBooks exports for Evernote" folder from your
     *     home folder, open each file in there, Evernote will open and start 
     *     importing your notes.
     *
     */




















    // Default file locations for required iBooks data 
    define('RESULT_DIRECTORY_NAME',"iBooks exports for Evernote");
    define('BOOKS_DATABASE_DIRECTORY','./Library/Containers/com.apple.iBooksX/Data/Documents/BKLibrary');
    define('NOTES_DATABASE_DIRECTORY','./Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation');


    if(file_exists(RESULT_DIRECTORY_NAME)){
        die("The destination folder for the exports already exists on your Mac.\nPlease move that one out of the way before proceeding.\n");
    }

    // Verify presence of iBooks database

    if(!file_exists(BOOKS_DATABASE_DIRECTORY)){
        die("Sorry, couldn't find an iBooks Library on your Mac. Have you put any books in there?\n");
    }else{
        if(!$path = exec('ls '.BOOKS_DATABASE_DIRECTORY."/*.sqlite")){
            die("Could not find the iBooks library database. Have you put any books in there?\n");
        }else{
            define('BOOKS_DATABASE_FILE',$path);
        }
    }


    // Verify presence of iBooks notes database

    if(!file_exists(NOTES_DATABASE_DIRECTORY)){
        die("Sorry, couldn't find any iBooks notes on your Mac. Have you actually taken any notes in iBooks?\n");
    }else{
        if(!$path = exec('ls '.NOTES_DATABASE_DIRECTORY."/*.sqlite")){
            die("Could not find the iBooks notes database. Have you actually taken any notes in iBooks?\n");
        }else{
            define('NOTES_DATABASE_FILE',$path);
        }
    }


    // Fire up a SQLite parser

    class MyDB extends SQLite3
    {
      function __construct($FileName)
      {
         $this->open($FileName);
      }
    }


    // Retrieve any books.

    $books = array();

    $booksdb = new MyDB(BOOKS_DATABASE_FILE);

    if(!$booksdb){
      echo $booksdb->lastErrorMsg();
    } 

    $res = $booksdb->query("
                SELECT
                    ZASSETID,
                    ZTITLE AS Title,
                    ZAUTHOR AS Author
                FROM ZBKLIBRARYASSET
                WHERE ZTITLE IS NOT NULL");

    while($row = $res->fetchArray(SQLITE3_ASSOC) ){
        $books[$row['ZASSETID']] = $row;
    }

    $booksdb->close();

    if(count($books)==0) die("No books found in your library. Have you added any to iBooks?\n");

    // Retrieve the notes.

    $notesdb = new MyDB(NOTES_DATABASE_FILE);

    if(!$notesdb){
      echo $notesdb->lastErrorMsg();
    } 

    $notes = array();

    $res = $notesdb->query("
                SELECT
                    ZANNOTATIONREPRESENTATIVETEXT as BroaderText,
                    ZANNOTATIONSELECTEDTEXT as SelectedText,
                    ZANNOTATIONNOTE as Note,
                    ZFUTUREPROOFING5 as Chapter,
                    ZANNOTATIONCREATIONDATE as Created,
                    ZANNOTATIONMODIFICATIONDATE as Modified,
                    ZANNOTATIONASSETID
                FROM ZAEANNOTATION
                WHERE ZANNOTATIONSELECTEDTEXT IS NOT NULL
                ORDER BY ZANNOTATIONASSETID ASC,Created ASC");

    while($row = $res->fetchArray(SQLITE3_ASSOC) ){
        $notes[$row['ZANNOTATIONASSETID']][] = $row;
    }

    $notesdb->close();


    if(count($notes)==0) die("No notes found in your library. Have you added any to iBooks?\n\nIf you did on other devices than this Mac, make sure to enable iBooks notes/bookmarks syncing on all devices.");


    // Create a new directory and cd into it

    mkdir(RESULT_DIRECTORY_NAME);
    chdir(RESULT_DIRECTORY_NAME);

    $i=0;
    $j=0;
    $b=0;

    foreach($notes as $AssetID => $booknotes){

        $Body = '<?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
        <en-export export-date="'.@strftime('%Y%m%dT%H%M%S',time()).'" application="iBooks2Evernote" version="iBooks2Evernote Mac 0.0.1">';

        $BookTitle  = $books[$AssetID]['Title'];

        $j = 0;

        foreach($booknotes as $note){

            $CappedText = null;
            $TextWithContext = null;

            // Skip empty notes
            if(strlen($note['BroaderText']?$note['BroaderText']:$note['SelectedText'])==0) continue;

            $HighlightedText = $note['SelectedText'];

            // Cap the titles to 255 characters or Evernote will blank them.

            if(strlen($HighlightedText)>255) $CappedText = substr($note['SelectedText'],0,254)."…";

            // If iBooks stored the surrounding paragraph of a highlighted text, show it and make the highlighted text show as highlighted.
            if(!empty($note['BroaderText']) && $note['BroaderText'] != $note['SelectedText']){
                $TextWithContext = str_replace($note['SelectedText'],"<span style=\"background: yellow;\">".$note['SelectedText']."</span>",$note['BroaderText']);
            }

            // Keep some counters for commandline feedback
            if($j==0)$b++;
            $i++;
            $j++;

            // Put it in Evernote's ENEX format.
            $Body .='
    <note><title>'.($CappedText?$CappedText:$HighlightedText).'</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
    <en-note>
    <div>
    <p>'.($TextWithContext?$TextWithContext:$HighlightedText).'</p>
    <p><span style="color: rgb(169, 169, 169);font-size: 12px;">From chapter: '.$note['Chapter'].'</span></p>
    </div>
    <div>'.$note['Note'].'</div>
    </en-note>
    ]]></content><created>'.@strftime('%Y%m%dT%H%M%S',@strtotime("2001-01-01 +". ((int)$note['Created'])." seconds")).'</created><updated>'.@strftime('%Y%m%dT%H%M%S',@strtotime("2001-01-01 +". ((int)$note['Modified'])." seconds")).'</updated><tag>'.$BookTitle.'.</tag><note-attributes><author>joris@jor.is</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>';

        }

        $Body .='
        </en-export>
        ';

        file_put_contents($BookTitle.".enex", $Body);
    }

    echo "Done! Exported $i notes into $b separate export files in the '".RESULT_DIRECTORY_NAME."' folder.\n\n";

3
  1. 为SQLite安装免费的DB Browser
  2. 转到iBooks annotations文件夹: ~/Library/Containers/com.apple.iBooksX/Data/Documents/AEAnnotation/
  3. .sqlite文件复制到某处(如桌面)以保持原始安全。
  4. 使用DB Browser打开文件。
  5. 通过浏览数据在目标书中查找一些注释。
  6. 按ZANNOTATIONASSETID过滤,仅显示目标书中的注释。
  7. 将您想要的注释复制并粘贴到Numbers或您喜欢的任何应用程序中。

Apple的着名易用性!
orome 2016年

@raxacoricofallapatorius:说真的。这只是为了得到我突出显示的词汇表的一些条件。
加文2016年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.