private Element createBrandElem( Brand brand, DateTime originalPublicationDate, DateTime brandEndDate, String lastModified, LakeviewContentGroup contentGroup, int addedSeasons) { Element element = createElement("TVSeries", LAKEVIEW); addIdElements(element, brandId(brand), providerMediaId(brand)); addTitleElements( element, Strings.isNullOrEmpty(brand.getTitle()) ? "EMPTY BRAND TITLE" : brand.getTitle()); appendCommonElements( element, brand, originalPublicationDate, lastModified, brandAtomUri(findTagAlias(brand)), brand.getGenres(), null); if (addedSeasons > 0) { element.appendChild( stringElement("TotalNumberOfSeasons", LAKEVIEW, String.valueOf(addedSeasons))); } element.appendChild( stringElement( "TotalNumberOfEpisodes", LAKEVIEW, String.valueOf(countEpisodes(contentGroup)))); if (brand.getPresentationChannel() != null && channelResolver.fromKey(brand.getPresentationChannel()).hasValue()) { element.appendChild( stringElement( "Network", LAKEVIEW, channelResolver.fromKey(brand.getPresentationChannel()).requireValue().getTitle())); } else { List<Broadcast> broadcasts = extractBroadcasts(contentGroup.episodes()); if (!broadcasts.isEmpty()) { element.appendChild(stringElement("Network", LAKEVIEW, extractNetwork(broadcasts))); } else { return null; } } if (brandEndDate != null) { element.appendChild( stringElement("EndYear", LAKEVIEW, String.valueOf(brandEndDate.getYear()))); } return element; }
private void updateSchedule(Item item) { Iterable<Broadcast> broadcasts = Iterables.concat(Iterables.transform(item.getVersions(), Version.TO_BROADCASTS)); for (Broadcast broadcast : broadcasts) { Maybe<Channel> channel = channelResolver.fromUri(broadcast.getBroadcastOn()); if (channel.hasValue()) { scheduleWriter.replaceScheduleBlock( item.getPublisher(), channel.requireValue(), ImmutableSet.of(new ScheduleEntry.ItemRefAndBroadcast(item, broadcast))); } } }
public C4AtomApi(ChannelResolver channelResolver) { channelMap = ImmutableBiMap.<String, Channel>builder() .put("C4", channelResolver.fromUri("http://www.channel4.com").requireValue()) .put("M4", channelResolver.fromUri("http://www.channel4.com/more4").requireValue()) .put("F4", channelResolver.fromUri("http://film4.com").requireValue()) .put("E4", channelResolver.fromUri("http://www.e4.com").requireValue()) .put("4M", channelResolver.fromUri("http://www.4music.com").requireValue()) .put("4S", channelResolver.fromUri("http://www.channel4.com/4seven").requireValue()) .build(); }
private String extractNetwork(List<Broadcast> broadcasts) { return channelResolver .fromUri(TRANSMISSION_ORDERING.min(broadcasts).getBroadcastOn()) .requireValue() .getTitle(); }