private ItemAndBroadcast getClosedEpisode( Brand brand, ProgData progData, Channel channel, DateTimeZone zone, Timestamp updatedAt) { String uri = CLOSED_EPISODE + getClosedPostfix(channel); Maybe<Identified> resolvedContent = contentResolver.findByCanonicalUris(ImmutableList.of(uri)).getFirstValue(); Episode episode; if (resolvedContent.hasValue() && resolvedContent.requireValue() instanceof Episode) { episode = (Episode) resolvedContent.requireValue(); } else { episode = (Episode) getBasicEpisode(progData, true); } episode.setCanonicalUri(uri); episode.setCurie(CLOSED_CURIE + getClosedPostfix(channel)); episode.setTitle(progData.getTitle()); episode.setScheduleOnly(true); episode.setMediaType(channel.getMediaType()); Version version = findBestVersion(episode.getVersions()); Broadcast broadcast = broadcast(progData, channel, zone, updatedAt); addBroadcast(version, broadcast); return new ItemAndBroadcast(episode, Maybe.just(broadcast)); }
protected Specialization specialization(ProgData progData, Channel channel) { if (MediaType.AUDIO.equals(channel.getMediaType())) { return Specialization.RADIO; } return Strings.isNullOrEmpty(progData.getRtFilmnumber()) ? Specialization.TV : Specialization.FILM; }
private Optional<Brand> getBrand(ProgData progData, Channel channel, Timestamp updatedAt) { Optional<Brand> possibleBrand = getBrandWithoutChannel(progData, updatedAt); if (possibleBrand.isPresent()) { Brand brand = possibleBrand.get(); brand.setSpecialization(specialization(progData, channel)); brand.setMediaType(channel.getMediaType()); setImages( progData.getPictures(), brand, PA_PICTURE_TYPE_BRAND, PA_PICTURE_TYPE_SERIES, Maybe.<String>nothing()); } return possibleBrand; }
private Optional<Brand> getBrand(ProgData progData, Channel channel, Timestamp updatedAt) { String brandId = progData.getSeriesId(); if (Strings.isNullOrEmpty(brandId) || Strings.isNullOrEmpty(brandId.trim())) { return Optional.absent(); } String brandUri = PaHelper.getBrandUri(brandId); Alias brandAlias = PaHelper.getBrandAlias(brandId); Maybe<Identified> possiblePrevious = contentResolver.findByCanonicalUris(ImmutableList.of(brandUri)).getFirstValue(); Brand brand = possiblePrevious.hasValue() ? (Brand) possiblePrevious.requireValue() : new Brand(brandUri, "pa:b-" + brandId, Publisher.PA); brand.addAlias(brandAlias); brand.setTitle(progData.getTitle()); brand.setDescription(Strings.emptyToNull(progData.getSeriesSynopsis())); brand.setSpecialization(specialization(progData, channel)); brand.setMediaType(channel.getMediaType()); setCertificate(progData, brand); setGenres(progData, brand); selectImages( progData.getPictures(), brand, PA_PICTURE_TYPE_BRAND, PA_PICTURE_TYPE_SERIES, Maybe.<String>nothing()); if (isClosedBrand(Optional.of(brand))) { brand.setScheduleOnly(true); } brand.setLastUpdated(updatedAt.toDateTimeUTC()); return Optional.of(brand); }
private Broadcast setCommonDetails( ProgData progData, Channel channel, DateTimeZone zone, Item episode, Timestamp updatedAt) { // currently Welsh channels have Welsh titles/descriptions // which flip the English ones, resulting in many writes. We'll only take the Welsh title if we // don't // already have a title from another channel if (episode.getTitle() == null || !channel.getUri().contains("wales")) { if (progData.getEpisodeTitle() != null) { episode.setTitle(progData.getEpisodeTitle()); } else { episode.setTitle(progData.getTitle()); } } if (progData.getBillings() != null) { for (Billing billing : progData.getBillings().getBilling()) { if ((episode.getDescription() == null || !channel.getUri().contains("wales")) && billing.getType().equals("synopsis")) { episode.setDescription(billing.getvalue()); } if ((episode.getShortDescription() == null || !channel.getUri().contains("wales")) && billing.getType().equals("pa_detail1")) { episode.setShortDescription(billing.getvalue()); } if ((episode.getMediumDescription() == null || !channel.getUri().contains("wales")) && billing.getType().equals("pa_detail2")) { episode.setMediumDescription(billing.getvalue()); } if ((episode.getLongDescription() == null || !channel.getUri().contains("wales")) && billing.getType().equals("pa_detail3")) { episode.setLongDescription(billing.getvalue()); } } } episode.setMediaType(channel.getMediaType()); episode.setSpecialization(specialization(progData, channel)); setGenres(progData, episode); if (progData.getCountry() != null) { episode.setCountriesOfOrigin(countryMap.parseCountries(progData.getCountry())); } if (progData.getAttr() != null) { episode.setBlackAndWhite(getBooleanValue(progData.getAttr().getBw())); } selectImages( progData.getPictures(), episode, PA_PICTURE_TYPE_EPISODE, PA_PICTURE_TYPE_SERIES, Maybe.just(PA_PICTURE_TYPE_BRAND)); episode.setPeople(people(progData)); Version version = findBestVersion(episode.getVersions()); version.set3d(getBooleanValue(progData.getAttr().getThreeD())); Duration duration = Duration.standardMinutes(Long.valueOf(progData.getDuration())); version.setDuration(duration); setCertificate(progData, episode); Broadcast broadcast = broadcast(progData, channel, zone, updatedAt); addBroadcast(version, broadcast); return broadcast; }
protected Specialization specialization(ProgData progData, Channel channel) { if (MediaType.AUDIO.equals(channel.getMediaType())) { return Specialization.RADIO; } return getBooleanValue(progData.getAttr().getFilm()) ? Specialization.FILM : Specialization.TV; }