Beispiel #1
0
 private int getYouViewId(Channel channel) {
   for (String alias : channel.getAliasUrls()) {
     Matcher m = YOUVIEW_URI_MATCHER.matcher(alias);
     if (m.matches()) {
       return Integer.decode(m.group(1));
     }
   }
   throw new RuntimeException(
       "Channel " + channel.getCanonicalUri() + " does not have a YouView alias");
 }
  private Broadcast broadcast(
      ProgData progData, Channel channel, DateTimeZone zone, Timestamp updateAt) {
    Duration duration = Duration.standardMinutes(Long.valueOf(progData.getDuration()));

    DateTime transmissionTime = getTransmissionTime(progData.getDate(), progData.getTime(), zone);

    Broadcast broadcast =
        new Broadcast(channel.getUri(), transmissionTime, duration)
            .withId(PaHelper.getBroadcastId(progData.getShowingId()));

    if (progData.getAttr() != null) {
      broadcast.setRepeat(isRepeat(channel, progData.getAttr()));
      broadcast.setSubtitled(getBooleanValue(progData.getAttr().getSubtitles()));
      broadcast.setSigned(getBooleanValue(progData.getAttr().getSignLang()));
      broadcast.setAudioDescribed(getBooleanValue(progData.getAttr().getAudioDes()));
      broadcast.setHighDefinition(getBooleanValue(progData.getAttr().getHd()));
      broadcast.setWidescreen(getBooleanValue(progData.getAttr().getWidescreen()));
      broadcast.setLive(getBooleanValue(progData.getAttr().getLive()));
      broadcast.setSurround(getBooleanValue(progData.getAttr().getSurround()));
      broadcast.setPremiere(getBooleanValue(progData.getAttr().getPremiere()));

      Boolean newSeries = getBooleanValue(progData.getAttr().getNewSeries());
      Boolean newEpisode = getBooleanValue(progData.getAttr().getNewEpisode());

      broadcast.setNewSeries(newSeries);
      broadcast.setNewEpisode(isNewEpisode(newSeries, newEpisode));
    }
    broadcast.setLastUpdated(updateAt.toDateTimeUTC());
    return broadcast;
  }
  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;
 }
Beispiel #5
0
  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;
  }
 @SuppressWarnings("deprecation")
 private String getClosedPostfix(Channel channel) {
   return "_" + channel.getKey();
 }
Beispiel #9
0
 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;
 }