1
0
mirror of https://github.com/crawler-commons/crawler-commons synced 2024-09-20 08:42:15 +02:00

Adding duration to the map generated by VideoAttributes.asMap (#301)

This commit is contained in:
Evan Halley 2020-07-24 10:46:59 -04:00 committed by GitHub
parent ce9579409e
commit 9affd1d992
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ Crawler-Commons Change Log
Current Development 1.2-SNAPSHOT (yyyy-mm-dd)
- [SiteMapParser] Document options *strict* and *allowPartial* in SiteMapParser constructors (sebastian-nagel) #267
- [Robots] Maximum values (crawl-delay and warnings): document and make visible (sebastian-nagel, Avi Hayun) #276
- [Sitemaps] Adding duration to the map generated by VideoAttributes.asMap (evanhalley) #300
Release 1.1 (2020-06-29)
- [sitemaps] Sitemaps to implement Serializable (cdalexndr, sebastian-nagel) #244

View File

@ -57,6 +57,7 @@ public class VideoAttributes extends ExtensionMetadata {
public static final String ALLOWED_PLATFORMS = "allowed_platforms";
public static final String RESTRICTED_PLATFORMS = "restricted_platforms";
public static final String IS_LIVE = "is_live";
public static final String DURATION = "duration";
/**
* Video thumbnail URL found under video/thumbnail_loc (required)
@ -678,6 +679,10 @@ public class VideoAttributes extends ExtensionMetadata {
if (isLive != null) {
map.put(IS_LIVE, new String[]{ isLive.toString() });
}
if (duration != null) {
map.put(DURATION, new String[]{ duration.toString() });
}
return Collections.unmodifiableMap(map);
}
}

View File

@ -36,6 +36,7 @@ public class VideoAttributesTest {
attributes.setUploader("GrillyMcGrillerson");
attributes.setUploaderInfo(new URL("http://www.example.com/users/grillymcgrillerson"));
attributes.setLive(false);
attributes.setDuration(54321);
Map<String, String[]> map = attributes.asMap();
assertEquals(attributes.getThumbnailLoc().toString(), map.get(VideoAttributes.THUMBNAIL_LOC)[0]);
@ -63,6 +64,7 @@ public class VideoAttributesTest {
assertArrayEquals(attributes.getAllowedPlatforms(), map.get(VideoAttributes.ALLOWED_PLATFORMS));
assertArrayEquals(attributes.getRestrictedPlatforms(), map.get(VideoAttributes.RESTRICTED_PLATFORMS));
assertEquals(attributes.getLive().toString(), map.get(VideoAttributes.IS_LIVE)[0]);
assertEquals(attributes.getDuration().toString(), map.get(VideoAttributes.DURATION)[0]);
}
@Test
@ -93,5 +95,6 @@ public class VideoAttributesTest {
assertNull(map.get(VideoAttributes.ALLOWED_PLATFORMS));
assertNull(map.get(VideoAttributes.RESTRICTED_PLATFORMS));
assertNull(map.get(VideoAttributes.IS_LIVE));
assertNull(map.get(VideoAttributes.DURATION));
}
}