Book.fromProfile constructor

Book.fromProfile(
  1. Bs4Element soupElement
)

Implementation

factory Book.fromProfile(Bs4Element soupElement) {
  String getAuthor() {
    return soupElement
        .find(
          'td',
          class_: 'field author',
        )!
        .a!
        .text;
  }

  String getTitle() {
    return soupElement
        .find(
          'td',
          class_: 'field title',
        )!
        .a!
        .attributes['title']!;
  }

  String getImageUrl() {
    return soupElement
        .find(
          'div',
          class_: 'js-tooltipTrigger tooltipTrigger',
        )!
        .img!
        .attributes['src']!
        .replaceAll('_SX50_', '_SX400_');
  }

  String getIsbn() {
    return soupElement
        .find(
          'td',
          class_: 'field isbn',
        )!
        .element!
        .text
        .replaceAll('isbn', '')
        .replaceAll(' ', '');
  }

  return Book(
    title: getTitle(),
    imgUrl: getImageUrl(),
    md5: getIsbn(),
    size: 'unknown size',
    genre: '',
    author: getAuthor(),
    format: Format.unknown,
  );
}