Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/domain/dublin_core/dublin_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DublinCore {
final String? relation;
final String? coverage;
final String? rights;
final String? dateString;

DublinCore({
this.title,
Expand All @@ -39,6 +40,7 @@ class DublinCore {
this.relation,
this.coverage,
this.rights,
this.dateString
});

factory DublinCore.parse(XmlElement element) {
Expand All @@ -53,6 +55,8 @@ class DublinCore {
element.findElements('dc:contributor').firstOrNull?.innerText,
date:
parseDateTime(element.findElements('dc:date').firstOrNull?.innerText),
dateString:
element.findElements('dc:date').firstOrNull?.innerText,
created: parseDateTime(
element.findElements('dc:created').firstOrNull?.innerText),
modified: parseDateTime(
Expand Down
11 changes: 11 additions & 0 deletions lib/domain/rss_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class RssItem {
final RssEnclosure? enclosure;
final DublinCore? dc;
final Itunes? itunes;
final String? imageUrl;

RssItem({
this.title,
Expand All @@ -41,9 +42,18 @@ class RssItem {
this.enclosure,
this.dc,
this.itunes,
this.imageUrl,
});

factory RssItem.parse(XmlElement element) {
final imageElement = element.findElements('image:image').firstOrNull?.innerText ??
element
.findElements('*')
.firstWhere(
(e) => e.name.local == 'image' && e.name.prefix == 'image',
orElse: () => XmlElement(XmlName('')),
)
.innerText;
return RssItem(
title: element.findElements('title').firstOrNull?.innerText,
description: element.findElements('description').firstOrNull?.innerText,
Expand Down Expand Up @@ -72,6 +82,7 @@ class RssItem {
.firstOrNull,
dc: DublinCore.parse(element),
itunes: Itunes.parse(element),
imageUrl: imageElement.isNotEmpty ? imageElement : null,
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:

dependencies:
xml: ^6.4.2
intl: ^0.19.0
intl: ^0.20.0

dev_dependencies:
flutter_lints: ^4.0.0
Expand Down