kindle_unpack 0.1.0 copy "kindle_unpack: ^0.1.0" to clipboard
kindle_unpack: ^0.1.0 copied to clipboard

Pure-Dart library for reading Amazon Kindle ebook files (MOBI / AZW / AZW3 / KF8) and re-emitting them as EPUB 3. No DRM removal.

example/main.dart

// Example: read a Kindle file and write an EPUB next to it.
//
//   dart run example/main.dart path/to/book.azw3
//
// Prints a small summary of what was parsed; writes
// `path/to/book.epub` alongside the input.

import 'dart:io';

import 'package:kindle_unpack/kindle_unpack.dart';

void main(List<String> args) {
  if (args.length != 1) {
    stderr.writeln('usage: dart run example/main.dart <book.mobi|.azw3>');
    exit(64);
  }
  final input = File(args[0]);
  if (!input.existsSync()) {
    stderr.writeln('No such file: ${input.path}');
    exit(66);
  }

  final book = KindleBook.fromBytes(input.readAsBytesSync());
  print('Title:   ${book.title}');
  print('Authors: ${book.exth?.authors.join(', ') ?? '(unknown)'}');
  print('Format:  ${book.format}');
  print('Parts:   ${book.parts.length}');
  print('Images:  ${book.images.all.length}');
  print('Fonts:   ${book.fonts.length}');

  final outPath = input.path.replaceFirst(
    RegExp(r'\.(azw3?|mobi)$', caseSensitive: false),
    '.epub',
  );
  File(outPath).writeAsBytesSync(book.toEpub());
  print('\nWrote EPUB → $outPath');
}
1
likes
150
points
134
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure-Dart library for reading Amazon Kindle ebook files (MOBI / AZW / AZW3 / KF8) and re-emitting them as EPUB 3. No DRM removal.

Repository (GitHub)
View/report issues

Topics

#mobi #azw3 #kf8 #epub #ebook

License

GPL-3.0 (license)

Dependencies

archive

More

Packages that depend on kindle_unpack