Skip to content

Parse media thumbnails inside media group tag. #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
5 changes: 4 additions & 1 deletion lib/domain/media/media.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class Media {
title: Title.parse(findElementOrNull(element, 'media:title')),
description: Description.parse(findElementOrNull(element, 'media:description')),
keywords: findElementOrNull(element, 'media:keywords')?.innerText,
thumbnails: element.findElements('media:thumbnail').map((e) => Thumbnail.parse(e)).toList(),
thumbnails: element
.findAllElements('media:thumbnail')
.map((e) => Thumbnail.parse(e))
.toList(),
hash: Hash.parse(findElementOrNull(element, 'media:hash')),
player: Player.parse(findElementOrNull(element, 'media:player')),
copyright: Copyright.parse(findElementOrNull(element, 'media:copyright')),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ environment:
dependencies:
xml: ^6.3.0
http: ^1.1.2
intl: ^0.19.0
intl: ^0.20.2

dev_dependencies:
test: ^1.16.4
lints: ^2.1.1
lints: ^6.0.0
22 changes: 16 additions & 6 deletions test/atom_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,22 @@ void main() {

expect(item.media!.keywords, 'kitty, cat, big dog, yarn, fluffy');

expect(item.media!.thumbnails.length, 2);
final mediaThumbnail = item.media!.thumbnails.first;
expect(mediaThumbnail.url, 'http://www.foo.com/keyframe1.jpg');
expect(mediaThumbnail.width, '75');
expect(mediaThumbnail.height, '50');
expect(mediaThumbnail.time, '12:05:01.123');
expect(item.media!.thumbnails.length, 3);
final mediaThumbnail0 = item.media!.thumbnails.first;
expect(mediaThumbnail0.url, 'http://www.foo.com/keyframe0.jpg');
expect(mediaThumbnail0.width, '50');
expect(mediaThumbnail0.height, '25');
expect(mediaThumbnail0.time, null);
final mediaThumbnail1 = item.media!.thumbnails[1];
expect(mediaThumbnail1.url, 'http://www.foo.com/keyframe1.jpg');
expect(mediaThumbnail1.width, '75');
expect(mediaThumbnail1.height, '50');
expect(mediaThumbnail1.time, '12:05:01.123');
final mediaThumbnail2 = item.media!.thumbnails[2];
expect(mediaThumbnail2.url, 'http://www.foo.com/keyframe2.jpg');
expect(mediaThumbnail2.width, '150');
expect(mediaThumbnail2.height, '100');
expect(mediaThumbnail2.time, '12:05:01.125');

expect(item.media!.hash!.algo, 'md5');
expect(item.media!.hash!.value, 'dfdec888b72151965a34b4b59031290a');
Expand Down
1 change: 1 addition & 0 deletions test/xml/Atom-Media.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<media:credit role="musician">band member 2</media:credit>
<media:category>music/artist name/album/song</media:category>
<media:rating>nonadult</media:rating>
<media:thumbnail url="http://www.foo.com/keyframe0.jpg" width="50" height="25" />
</media:group>
<media:title type="plain">The Judy's -- The Moo Song</media:title>
<media:description type="plain">This was some really bizarre band I listened to as a young lad.</media:description>
Expand Down