From 36cca78a2d69becd06e3b2da1b399d33e6fb20bb Mon Sep 17 00:00:00 2001 From: imprologic Date: Thu, 27 Apr 2023 18:04:17 -0400 Subject: [PATCH 1/2] Added optional media:thumbnail to media:group --- lib/domain/media/group.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/domain/media/group.dart b/lib/domain/media/group.dart index fddecef..e810c21 100644 --- a/lib/domain/media/group.dart +++ b/lib/domain/media/group.dart @@ -2,6 +2,7 @@ import 'package:webfeed/domain/media/category.dart'; import 'package:webfeed/domain/media/content.dart'; import 'package:webfeed/domain/media/credit.dart'; import 'package:webfeed/domain/media/rating.dart'; +import 'package:webfeed/domain/media/thumbnail.dart'; import 'package:webfeed/util/iterable.dart'; import 'package:xml/xml.dart'; @@ -10,12 +11,14 @@ class Group { final List? credits; final Category? category; final Rating? rating; + final Thumbnail? thumbnail; Group({ this.contents, this.credits, this.category, this.rating, + this.thumbnail, }); factory Group.parse(XmlElement element) { @@ -36,6 +39,10 @@ class Group { .findElements('media:rating') .map((e) => Rating.parse(e)) .firstOrNull, + thumbnail: element + .findElements('media:thumbnail') + .map((e) => Thumbnail.parse(e)) + .firstOrNull, ); } } From c15bb0e120e9acbbd98038d0d85375a755db8d3d Mon Sep 17 00:00:00 2001 From: imprologic Date: Sat, 29 Apr 2023 14:44:53 -0400 Subject: [PATCH 2/2] parse other elements in media:group --- lib/domain/media/group.dart | 14 ++++++++++++++ test/atom_test.dart | 27 +++++++++++++++++++++++++++ test/xml/Atom-YouTube.xml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 test/xml/Atom-YouTube.xml diff --git a/lib/domain/media/group.dart b/lib/domain/media/group.dart index e810c21..0976157 100644 --- a/lib/domain/media/group.dart +++ b/lib/domain/media/group.dart @@ -1,8 +1,10 @@ import 'package:webfeed/domain/media/category.dart'; import 'package:webfeed/domain/media/content.dart'; import 'package:webfeed/domain/media/credit.dart'; +import 'package:webfeed/domain/media/description.dart'; import 'package:webfeed/domain/media/rating.dart'; import 'package:webfeed/domain/media/thumbnail.dart'; +import 'package:webfeed/domain/media/title.dart'; import 'package:webfeed/util/iterable.dart'; import 'package:xml/xml.dart'; @@ -12,6 +14,8 @@ class Group { final Category? category; final Rating? rating; final Thumbnail? thumbnail; + final Title? title; + final Description? description; Group({ this.contents, @@ -19,6 +23,8 @@ class Group { this.category, this.rating, this.thumbnail, + this.title, + this.description, }); factory Group.parse(XmlElement element) { @@ -43,6 +49,14 @@ class Group { .findElements('media:thumbnail') .map((e) => Thumbnail.parse(e)) .firstOrNull, + title: element + .findElements('media:title') + .map((e) => Title.parse(e)) + .firstOrNull, + description: element + .findElements('media:title') + .map((e) => Description.parse(e)) + .firstOrNull, ); } } diff --git a/test/atom_test.dart b/test/atom_test.dart index 5814efc..3ba2c59 100644 --- a/test/atom_test.dart +++ b/test/atom_test.dart @@ -257,4 +257,31 @@ void main() { expect(item.content, null); expect(item.rights, null); }); + + + test('parse Atom-YouTube.xml media group', () { + var xmlString = File('test/xml/Atom-YouTube.xml').readAsStringSync(); + + var feed = AtomFeed.parse(xmlString); + + expect(feed.items!.length, 1); + var item = feed.items!.first; + + var mediaGroup = item.media?.group; + expect(mediaGroup, isNotNull); + + var thumbnail = mediaGroup?.thumbnail; + expect(thumbnail, isNotNull); + expect(thumbnail?.url, 'https://i4.ytimg.com/vi/SD6exDEZe3A/hqdefault.jpg'); + + var title = mediaGroup?.title; + expect(title, isNotNull); + expect(title?.value, 'Saifedean Ammous: How Bitcoin ENDS Inflation'); + + var description = mediaGroup?.description; + expect(description, isNotNull); + expect(description?.value, isNotNull); + + }); + } diff --git a/test/xml/Atom-YouTube.xml b/test/xml/Atom-YouTube.xml new file mode 100644 index 0000000..914b69b --- /dev/null +++ b/test/xml/Atom-YouTube.xml @@ -0,0 +1,35 @@ + + + yt:channel: + + Swan Bitcoin + + + Swan Bitcoin + https://www.youtube.com/channel/UCl4takhOQtiyprismCPsa2Q + + 2020-04-26T16:35:43+00:00 + + yt:video:SD6exDEZe3A + SD6exDEZe3A + UCl4takhOQtiyprismCPsa2Q + Saifedean Ammous: How Bitcoin ENDS Inflation + + + Swan Bitcoin + https://www.youtube.com/channel/UCl4takhOQtiyprismCPsa2Q + + 2023-04-29T16:21:00+00:00 + 2023-04-29T16:21:00+00:00 + + Saifedean Ammous: How Bitcoin ENDS Inflation + + + Connect with Swan on social media: Twitter: https://twitter.com/SwanBitcoin​​​Instagram: https://instagram.com/SwanBitcoin Telegram: https://t.me/swansignal​​​LinkedIn: https://www.linkedin.com/company/swanbitcoin Swan Bitcoin is the best way to accumulate Bitcoin with automatic recurring buys and instant buys from $10 to $10 million. Get started in just 5 minutes. Your first $10 purchase is on us: https://swanbitcoin.com/yt Download the all new Swan app! iOS: https://apps.apple.com/us/app/swan-bitcoin/id1576287352 Android: https://play.google.com/store/apps/details?id=com.swanbitcoin.android&pli=1 Join us for Pacific Bitcoin Festival 2023! Purchase your tickets now before prices go up: https://www.pacificbitcoin.com/?utm_medium=social&utm_source=youtube&utm_campaign=youtube_description Are you a high net worth individual or do you represent corporation that might be interested in learning more about Bitcoin? Swan Private guides corporations and high net worth individuals toward building generational wealth with Bitcoin. Find out more at: https://www.swanbitcoin.com/private/?utm_medium=social&utm_source=youtube&utm_campaign=youtube_post Check out the best place for Bitcoin education, Swan Bitcoin’s “Bitcoin Canon”. Compiling all of the greatest articles, news sources, videos and more from your favorite bitcoiners! https://swanbitcoin.com/cannon?utm_medium=social&utm_source=youtube&utm_campaign=youtube_description Get paid to recruit new Bitcoiners: https://swanbitcoin.com/enlist?utm_medium=social&utm_source=twitter&utm_campaign=social_selling #Bitcoin #SwanBitcoin + + + + + + + \ No newline at end of file