Commit c46403d9 authored by Sam Bowen's avatar Sam Bowen Committed by Commit Bot

Implement media feeds continue watching and play next.

See this part of the media feeds spec:
https://wicg.github.io/media-feeds/#play-next-tv-episodes

Some refactoring was necessary also. This is still missing the duration
on TV episode and the live details. Because those require changes to the
mojo structs, I will do them in a different CL.

The general process is:
1) Find all episodes in the Item and get them as EpisodeCandidate
2) Pick main and play next episodes from list of EpisodeCandidate
3) If main episode is present, validate and store it on item->tv_episode
4) If play next is present, validate and store it on
   item->play_next_candidate

It's OK for a TV series to have no EpisodeCandidates, but any it has
should be valid.

We should perhaps break this up into multiple files. Open to suggestions
on that.

Bug: 1068751
Change-Id: I37260ee8a905be347e764667921794bb845a4b77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2146072Reviewed-by: default avatarBecca Hughes <beccahughes@chromium.org>
Commit-Queue: Sam Bowen <sgbowen@google.com>
Cr-Commit-Position: refs/heads/master@{#758965}
parent 2e0d5c87
...@@ -76,6 +76,12 @@ bool ParseStringValue(const std::string& property_type, ...@@ -76,6 +76,12 @@ bool ParseStringValue(const std::string& property_type,
schema_org::property::PropertyConfiguration prop_config = schema_org::property::PropertyConfiguration prop_config =
schema_org::property::GetPropertyConfiguration(property_type); schema_org::property::GetPropertyConfiguration(property_type);
if (prop_config.number) { if (prop_config.number) {
int64_t l;
bool parsed_long = base::StringToInt64(value, &l);
if (parsed_long) {
values->long_values.push_back(l);
return true;
}
double d; double d;
bool parsed_double = base::StringToDouble(value, &d); bool parsed_double = base::StringToDouble(value, &d);
if (parsed_double) { if (parsed_double) {
......
...@@ -200,6 +200,19 @@ TEST_F(SchemaOrgExtractorTest, DoubleValue) { ...@@ -200,6 +200,19 @@ TEST_F(SchemaOrgExtractorTest, DoubleValue) {
EXPECT_EQ(expected, extracted); EXPECT_EQ(expected, extracted);
} }
TEST_F(SchemaOrgExtractorTest, StringValueRepresentingLong) {
EntityPtr extracted =
Extract("{\"@type\": \"VideoObject\",\"copyrightYear\": \"1999\"}");
ASSERT_FALSE(extracted.is_null());
EntityPtr expected = Entity::New();
expected->type = "VideoObject";
expected->properties.push_back(CreateLongProperty("copyrightYear", 1999));
EXPECT_EQ(expected, extracted);
}
TEST_F(SchemaOrgExtractorTest, StringValueRepresentingDouble) { TEST_F(SchemaOrgExtractorTest, StringValueRepresentingDouble) {
EntityPtr extracted = EntityPtr extracted =
Extract("{\"@type\": \"VideoObject\",\"copyrightYear\": \"1999.5\"}"); Extract("{\"@type\": \"VideoObject\",\"copyrightYear\": \"1999.5\"}");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment