Esempio n. 1
0
  @Test
  public void testMergesHDandSDforFilms() {
    BtVodEntry btVodEntrySD = filmRow("About Alex");
    btVodEntrySD.setProductTargetBandwidth("SD");

    BtVodEntry btVodEntryHD = filmRow("About Alex - HD");
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");
    btVodEntryHD.setProductTargetBandwidth("HD");

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());

    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.<ParentRef>absent());
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.<ParentRef>absent());

    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.<Series>absent());
    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.<Series>absent());

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is("About Alex"));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));

    assertThat(writtenItem.getVersions().size(), is(2));

    Version hdVersion = Iterables.get(writtenItem.getVersions(), 0);
    Version sdVersion = Iterables.get(writtenItem.getVersions(), 1);
    assertThat(
        Iterables.getOnlyElement(sdVersion.getManifestedAs()).getHighDefinition(), is(false));
    assertThat(Iterables.getOnlyElement(hdVersion.getManifestedAs()).getHighDefinition(), is(true));
  }
Esempio n. 2
0
  private void testHdSdMerging(String hdTitle, String sdTitle, String extractedTitle) {
    BtVodEntry btVodEntrySD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntrySD.setTitle(sdTitle);
    ParentRef parentRef = new ParentRef(BRAND_URI);
    btVodEntrySD.setProductTargetBandwidth("SD");

    BtVodEntry btVodEntryHD = episodeRow(FULL_EPISODE_TITLE, PRODUCT_GUID);
    btVodEntryHD.setTitle(hdTitle);
    btVodEntryHD.setGuid(PRODUCT_GUID + "_HD");
    btVodEntryHD.setProductTargetBandwidth("HD");

    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    when(seriesProvider.seriesFor(btVodEntrySD)).thenReturn(Optional.of(series));
    when(seriesProvider.seriesFor(btVodEntryHD)).thenReturn(Optional.of(series));

    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntrySD)).thenReturn(Optional.of(parentRef));
    when(btVodBrandProvider.brandRefFor(btVodEntryHD)).thenReturn(Optional.of(parentRef));

    itemExtractor.process(btVodEntrySD);
    itemExtractor.process(btVodEntryHD);

    Item writtenItem = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());

    assertThat(writtenItem.getTitle(), is(extractedTitle));
    assertThat(writtenItem.getDescription(), is(SYNOPSIS));
    assertThat(writtenItem.getContainer(), is(parentRef));

    assertThat(writtenItem.getVersions().size(), is(2));

    Version hdVersion = Iterables.get(writtenItem.getVersions(), 0);
    Version sdVersion = Iterables.get(writtenItem.getVersions(), 1);
    assertThat(
        Iterables.getOnlyElement(sdVersion.getManifestedAs()).getHighDefinition(), is(false));
    assertThat(Iterables.getOnlyElement(hdVersion.getManifestedAs()).getHighDefinition(), is(true));
    assertThat(
        Iterables.getFirst(writtenItem.getClips(), null),
        is(new Clip(TRAILER_URI, TRAILER_URI, Publisher.BT_VOD)));
  }
 private DateTime extractLastAvailabilityDate(Episode episode) {
   for (Version version : episode.getVersions()) {
     for (Encoding encoding : version.getManifestedAs()) {
       for (Location location : encoding.getAvailableAt()) {
         if (location.getPolicy() != null
             && Platform.XBOX.equals(location.getPolicy().getPlatform())
             && location.getPolicy().getAvailabilityStart() != null) {
           return location.getPolicy().getAvailabilityEnd();
         }
       }
     }
   }
   return null;
 }
Esempio n. 4
0
  @Test
  public void testDoesNotCreatePayToXLocationsWithZeroPrice() {
    BtVodEntry btVodEntry =
        episodeRow(SERIES_TITLE + ": S1 S1-E9 " + REAL_EPISODE_TITLE, PRODUCT_GUID);

    btVodEntry.setProductOfferingType("type-EST");

    BtVodProductPricingPlan pricingPlan = new BtVodProductPricingPlan();

    BtVodProductPricingTier pricingTier = new BtVodProductPricingTier();
    pricingTier.setProductAbsoluteStart(DateTime.now().minusMonths(2).getMillis());
    pricingTier.setProductAbsoluteEnd(DateTime.now().plusMonths(2).getMillis());

    BtVodProductAmounts productAmounts = new BtVodProductAmounts();
    productAmounts.setGBP(0D);

    pricingTier.setProductAmounts(productAmounts);
    pricingPlan.setProductPricingTiers(Lists.newArrayList(pricingTier));
    btVodEntry.setProductPricingPlan(pricingPlan);

    ParentRef parentRef = new ParentRef(BRAND_URI);

    Series series = new Series();
    series.setCanonicalUri("seriesUri");
    series.withSeriesNumber(1);

    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(series));
    when(imageExtractor.imagesFor(Matchers.<BtVodEntry>any())).thenReturn(ImmutableSet.<Image>of());
    when(btVodBrandProvider.brandRefFor(btVodEntry)).thenReturn(Optional.of(parentRef));
    when(seriesProvider.seriesFor(btVodEntry)).thenReturn(Optional.of(series));

    itemExtractor.process(btVodEntry);

    assertThat(itemExtractor.getProcessedItems().size(), is(1));

    Item item = Iterables.getOnlyElement(itemExtractor.getProcessedItems().values());
    Version version = Iterables.getOnlyElement(item.getVersions());
    Encoding encoding = Iterables.getOnlyElement(version.getManifestedAs());

    assertThat(encoding.getAvailableAt().size(), is(1));

    Location location = Iterables.getOnlyElement(encoding.getAvailableAt());
    assertThat(
        location.getCanonicalUri().contains(RevenueContract.PAY_TO_BUY.toString()), is(false));
    assertThat(
        location.getCanonicalUri().contains(RevenueContract.PAY_TO_RENT.toString()), is(false));
  }
 private String extractAssetId(Episode episode) {
   for (Version version : episode.getVersions()) {
     for (Encoding encoding : version.getManifestedAs()) {
       for (Location location : encoding.getAvailableAt()) {
         if (location.getTransportType().equals(TransportType.LINK)
             && location.getPolicy() != null
             && Platform.XBOX.equals(location.getPolicy().getPlatform())) {
           Pattern pattern = Pattern.compile(".*asset/(\\d+).*");
           Matcher matcher = pattern.matcher(location.getUri());
           if (matcher.matches()) {
             return matcher.group(1);
           }
         }
       }
     }
   }
   return "NONE";
 }
 private ItemOnDemandHierarchy hierarchyFrom(Item item) {
   Version version = Iterables.getOnlyElement(item.getVersions());
   Encoding encoding = Iterables.getOnlyElement(version.getManifestedAs());
   Location location = Iterables.getOnlyElement(encoding.getAvailableAt());
   return new ItemOnDemandHierarchy(item, version, encoding, location);
 }
Esempio n. 7
0
  @Override
  public void handle(WsProgramme programme, Iterable<WsAudioItem> audioItems) {
    checkNotNull(programme.getProgId());
    checkNotNull(programme.getSeriesId());

    String episodeUri = uriFor(programme);

    Maybe<Identified> possibleEpisode =
        resolver.findByCanonicalUris(ImmutableSet.of(episodeUri)).get(episodeUri);

    Episode episode = null;

    if (possibleEpisode.hasValue()) {
      Identified resolved = possibleEpisode.requireValue();
      if (resolved instanceof Episode) {
        episode = (Episode) resolved;
      } else {
        log.record(
            errorEntry()
                .withDescription(
                    "Resolved %s for episode %s", resolved.getClass().getSimpleName(), episodeUri));
        return;
      }
    } else {
      episode = new Episode(episodeUri, curieFor(programme), WORLD_SERVICE);
    }

    episode.setParentRef(new ParentRef(uriForBrand(programme.getSeriesId())));
    episode.setTitle(titleFrom(programme, audioItems));
    episode.setDescription(programme.getSynopsis());
    if (!Strings.isNullOrEmpty(programme.getEpisodeNo())
        && programme.getEpisodeNo().matches("\\d+")) {
      episode.setEpisodeNumber(Integer.parseInt(programme.getEpisodeNo()));
    }
    episode.setGenres(WsGenre.genresForCode(programme.getGenreCode()));
    episode.setMediaType(AUDIO);
    episode.setSpecialization(RADIO);

    if (!Iterables.isEmpty(audioItems)) {
      for (WsAudioItem audioItem : audioItems) {
        Version version = new Version();

        if (!Strings.isNullOrEmpty(audioItem.getDuration())
            && audioItem.getDuration().matches("\\d+")) {
          version.setDuration(new Duration(Long.parseLong(audioItem.getDuration())));
        }

        Policy policy = policyFor(audioItem);

        String broadcastUri = audioItem.getLinkAudioBroadcastQuality();
        if (!Strings.isNullOrEmpty(broadcastUri)) {
          version.addManifestedAs(encodingFrom(policy, broadcastUri, MimeType.AUDIO_WAV));
        }

        String thumbnailUri = audioItem.getLinkAudioThumbnail();
        if (!Strings.isNullOrEmpty(thumbnailUri)) {
          version.addManifestedAs(encodingFrom(policy, thumbnailUri, MimeType.AUDIO_MP3));
        }
        if (!version.getManifestedAs().isEmpty()) {
          episode.addVersion(version);
        }
      }
    }

    Broadcast broadcast = broadcastFrom(programme);
    if (broadcast != null) {
      Version version = Iterables.getFirst(episode.getVersions(), new Version());
      if (version.getDuration() == null) {
        version.setDuration(Duration.standardSeconds(broadcast.getBroadcastDuration()));
      }
      version.addBroadcast(broadcast);
    }

    writer.createOrUpdate(episode);
  }