1
0
mirror of https://github.com/stonega/tsacdop synced 2025-01-23 20:21:01 +01:00
tsacdop-podcast-app-android/lib/webfeed/domain/rss_content.dart
stonegate 57bf41114b Export ompli file
Storage management
Syncing setting
2020-03-20 03:58:30 +08:00

31 lines
696 B
Dart

import 'package:xml/xml.dart';
final _imagesRegExp = new RegExp(
"<img\\s.*?src=(?:'|\")([^'\">]+)(?:'|\")",
multiLine: true,
caseSensitive: false,
);
/// For RSS Content Module:
///
/// - `xmlns:content="http://purl.org/rss/1.0/modules/content/"`
///
class RssContent {
String value;
Iterable<String> images;
RssContent(this.value, this.images);
factory RssContent.parse(XmlElement element) {
if (element == null) {
return RssContent('', ['']);
}
final content = element.text.trim();
final images = <String>[];
_imagesRegExp.allMatches(content).forEach((match) {
images.add(match.group(1));
});
return RssContent(content, images);
}
}