function main() {
var youTubeVideoId = "lcdmDfGPeyU";
var mediaOperation = AdsApp.adMedia().newVideoBuilder()
.withYouTubeVideoId(youTubeVideoId)
.build();
var video = mediaOperation.getResult();
//var v = campaign.getString('video_link');
var mediaOperation = AdsApp.adMedia().newVideoBuilder()
//.withYouTubeVideoId(v.split('=').pop())
.withYouTubeVideoId("lcdmDfGPeyU")
.build();
var TryThis = mediaOperation.getResult();
var VideoAdGroup = AdsApp.videoCampaigns().withCondition("Name=BushraHAGA").get().next().newVideoAdGroupBuilder().withAdGroupType("TRUE_VIEW_IN_STREAM").withName("GA4").build().getResult()
var VideoAd = VideoAdGroup.newVideoAd().inStreamAdBuilder()
VideoAd.withVideo(TryThis)
VideoAd.withAdName("GLGLY3")
VideoAd.withFinalUrl("
https://www.youtube.com/watch?v=lcdmDfGPeyU")
VideoAd.withDisplayUrl("
youtube.com/watch?v=lcdmDfGPeyU")
VideoAd.withCallToAction("PLAY NOW")
VideoAd.build();
Logger.log(VideoAd.build().getErrors())
//var videos = AdsApp.adAssets().newYouTubeVideoAssetBuilder().withYouTubeVideoId("lcdmDfGPeyU").withName("dddd2").build()
// Logger.log(videos)
// Logger.log(videos.isSuccessful())
// Logger.log(videos.getResult())
// AdsApp.videoAdGroups().withCondition("Name=GALGLY2").get().next().newVideoAd().inStreamAdBuilder().withVideo(TryThis).withAdName("GLGLY2")
// .withFinalUrl("
https://www.youtube.com/watch?v=lcdmDfGPeyU")
//.withDisplayUrl("
youtube.com/watch?v=lcdmDfGPeyU")
// .withCallToAction("PLAY NOW")
// .build()
}
// You can filter on the YouTubeVideoId if you already have that video in
// your account to fetch the exact one you want right away.