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; }
Element createSeriesElem( Series series, Brand parent, DateTime originalPublicationDate, String lastModified) { Element element = createElement("TVSeason", LAKEVIEW); String applicationSpecificData = seriesAtomUri(findTagAlias(series)); String seriesId = seriesId(series); String providerMediaId = providerMediaId(series); addIdElements(element, seriesId, providerMediaId); if (genericTitlesEnabled) { if (series.getSeriesNumber() != null) { addTitleElements(element, String.format("Series %d", series.getSeriesNumber())); } else if (!Strings.isNullOrEmpty(series.getTitle())) { addTitleElements(element, String.format("Series %d", series.getTitle())); } else { addTitleElements(element, parent.getTitle()); } } else if (Strings.isNullOrEmpty(series.getTitle()) || series.getTitle().matches("(?i)series \\d+")) { addTitleElements( element, String.format("%s Series %s", parent.getTitle(), series.getSeriesNumber())); } else { addTitleElements(element, series.getTitle()); } Set<String> genres = Iterables.isEmpty(series.getGenres()) ? parent.getGenres() : series.getGenres(); appendCommonElements( element, series, originalPublicationDate, lastModified, applicationSpecificData, genres, null); element.appendChild( stringElement("SeasonNumber", LAKEVIEW, String.valueOf(series.getSeriesNumber()))); element.appendChild(stringElement("SeriesId", LAKEVIEW, brandId(parent))); return element; }
Element createEpisodeElem( Episode episode, Brand container, Series series, DateTime originalPublicationDate, String lastModified) { Element element = createElement("TVEpisode", LAKEVIEW); Comment comment = new Comment("Atlas ID: " + episode.getCanonicalUri()); element.appendChild(comment); String assetId = extractAssetId(episode); String programmedId = extractProgrammedId(episode); String applicationSpecificData = episodeAtomUri(brandAtomUri(findTagAlias(container)), programmedId); String providerMediaId; if (series != null) { providerMediaId = providerMediaId(series) + "#" + assetId; } else { providerMediaId = providerMediaId(container) + "#" + assetId; } addIdElements(element, episodeId(episode), providerMediaId); if (genericTitlesEnabled) { if (episode.getEpisodeNumber() != null) { addTitleElements(element, String.format("Episode %d", episode.getEpisodeNumber())); } else if (!Strings.isNullOrEmpty(episode.getTitle())) { addTitleElements(element, episode.getTitle()); } else { addTitleElements(element, container.getTitle()); } } else if (Strings.isNullOrEmpty(episode.getTitle()) || episode.getTitle().matches("(?i)(series \\d+)? episode \\d+")) { addTitleElements( element, String.format( "%s Series %s Episode %s", container.getTitle(), episode.getSeriesNumber(), episode.getEpisodeNumber())); } else { addTitleElements(element, episode.getTitle()); } Element instances = createElement("Instances", LAKEVIEW); Element videoInstance = createElement("VideoInstance", LAKEVIEW); Element availabilities = createElement("Availabilities", LAKEVIEW); Element availability = createAvailabilityElement(episode, "Xbox360", PROVIDER_ID); if (addXboxOneAvailability) { availabilities.appendChild( createAvailabilityElement(episode, "XboxOne", XBOX_ONE_PROVIDER_ID)); } availabilities.appendChild(availability); videoInstance.appendChild(availabilities); videoInstance.appendChild(stringElement("ResolutionFormat", LAKEVIEW, "SD")); videoInstance.appendChild(stringElement("DeliveryFormat", LAKEVIEW, "Streaming")); videoInstance.appendChild(stringElement("PrimaryAudioLanguage", LAKEVIEW, "en-GB")); videoInstance.appendChild(stringElement("VideoInstanceType", LAKEVIEW, "Full")); instances.appendChild(videoInstance); appendCommonElements( element, episode, originalPublicationDate, lastModified, applicationSpecificData, episode.getGenres(), instances); element.appendChild( stringElement("EpisodeNumber", LAKEVIEW, String.valueOf(episode.getEpisodeNumber()))); element.appendChild( stringElement("DurationInSeconds", LAKEVIEW, String.valueOf(duration(episode)))); element.appendChild(stringElement("SeriesId", LAKEVIEW, brandId(container))); if (episode.getSeriesRef() != null) { element.appendChild(stringElement("SeasonId", LAKEVIEW, seriesId(series))); } return element; }