public void fromUpload(final Upload upload) {
   final Monetization monetization =
       null == upload.getMonetization() ? new Monetization() : upload.getMonetization();
   fromMonetization(monetization);
 }
 public Upload toUpload(final Upload upload) {
   final Monetization monetization = upload.getMonetization();
   toMonetization(monetization);
   return upload;
 }
  private Map<String, Object> getMetadataMonetization(final String content, final Upload upload) {
    final Map<String, Object> params = Maps.newHashMapWithExpectedSize(MONETIZE_PARAMS_SIZE);
    final Metadata metadata = upload.getMetadata();
    final Monetization monetization = upload.getMonetization();
    if (monetization.isClaim() && License.YOUTUBE == upload.getMetadata().getLicense()) {
      params.put("video_monetization_style", "ads");
      if (!monetization.isPartner() || ClaimOption.MONETIZE == monetization.getClaimoption()) {
        params.put("claim_style", "ads");
        params.put("enable_overlay_ads", boolConverter(monetization.isOverlay()));
        params.put("trueview_instream", boolConverter(monetization.isTrueview()));
        params.put("instream", boolConverter(monetization.isInstream()));
        params.put("long_ads_checkbox", boolConverter(monetization.isInstreamDefaults()));
        params.put("paid_product", boolConverter(monetization.isProduct()));
        params.put(
            "allow_syndication",
            boolConverter(Syndication.GLOBAL == monetization.getSyndication()));
      }
      if (monetization.isPartner()) {
        params.put(
            "claim_type",
            ClaimType.AUDIO_VISUAL == monetization.getClaimtype()
                ? "B"
                : ClaimType.VISUAL == monetization.getClaimtype() ? "V" : "A");

        final String toFind =
            ClaimOption.MONETIZE == monetization.getClaimoption()
                ? "Monetize in all countries"
                : ClaimOption.TRACK == monetization.getClaimoption()
                    ? "Track in all countries"
                    : "Block in all countries";

        final Pattern pattern =
            Pattern.compile(
                "<option\\s*value=\"([^\"]+?)\"\\s*(selected(=\"\")?)?\\sdata-is-monetized-policy=\"(true|false)\"\\s*>\\s*([^<]+?)\\s*</option>");
        final Matcher matcher = pattern.matcher(content);

        String usagePolicy = null;
        int position = 0;
        while (matcher.find(position)) {
          position = matcher.end();
          if (matcher.group(5).trim().equals(toFind)) {
            usagePolicy = matcher.group(1);
          }
        }
        params.put("usage_policy", usagePolicy);

        final String assetName = monetization.getAsset().name().toLowerCase(Locale.getDefault());

        params.put("asset_type", assetName);
        params.put(
            assetName + "_custom_id",
            monetization.getCustomId().isEmpty()
                ? upload.getVideoid()
                : monetization.getCustomId());

        params.put(assetName + "_notes", monetization.getNotes());
        params.put(assetName + "_tms_id", monetization.getTmsid());
        params.put(assetName + "_isan", monetization.getIsan());
        params.put(assetName + "_eidr", monetization.getEidr());

        if (Asset.TV != monetization.getAsset()) {
          // WEB + MOVIE ONLY
          params.put(
              assetName + "_title",
              !monetization.getTitle().isEmpty() ? monetization.getTitle() : metadata.getTitle());
          params.put(assetName + "_description", monetization.getDescription());
        } else {
          // TV ONLY
          params.put("show_title", monetization.getTitle());
          params.put("episode_title", monetization.getTitleepisode());
          params.put("season_nb", monetization.getSeasonNb());
          params.put("episode_nb", monetization.getEpisodeNb());
        }
      }
    }

    return params;
  }