bookmarksParser method

  1. @override
List<Bookmark> bookmarksParser(
  1. String bookmarkPath
)
override

Implementation

@override
List<Bookmark> bookmarksParser(String bookmarkPath) {
  var bookmarkSQL = """
          SELECT
              datetime(
                  moz_bookmarks.dateAdded/1000000,'unixepoch','localtime'
              ) AS added_time,
              url,
              moz_bookmarks.title,
              moz_folder.title
          FROM
              moz_bookmarks JOIN moz_places, moz_bookmarks as moz_folder
          ON
              moz_bookmarks.fk = moz_places.id
              AND moz_bookmarks.parent = moz_folder.id
          WHERE
              moz_bookmarks.dateAdded IS NOT NULL AND url LIKE 'http%'
              AND moz_bookmarks.title IS NOT NULL
     """;

  var conn = sqlite3.open('file:$bookmarkPath?mode=ro', uri: true);
  var result = conn.select(bookmarkSQL);

  var bookmarks = <Bookmark>[];

  for (var e in result) {
    bookmarks.add(
      Bookmark(
        url: e['url'],
        name: e['title'],
        folder: e['folder'],
        date: DateTime.fromMicrosecondsSinceEpoch(int.parse(e['d'])),
      ),
    );
  }
  conn.dispose();

  return bookmarks;
}