void bind(@NonNull Video item) { this.videoId = item.getId(); this.videoName.setText(item.getSnippet().getTitle()); this.videoCaption.setText(item.getSnippet().getDescription()); Thumbnail thumbnail = item.getSnippet().getThumbnails().getHigh(); if (thumbnail != null && thumbnail.getHeight() > 0) { playerViewContainer.setAspectRatio(thumbnail.getWidth() / (float) thumbnail.getHeight()); Glide.with(itemView).load(thumbnail.getUrl()).apply(options).into(thumbnailView); } }
/** * Build an {@link ActivityObject} actor given the video object * @param video Video * @param id id * @return Actor object */ private static ActivityObject buildActor(Video video, String id) { ActivityObject actor = new ActivityObject(); actor.setId("id:youtube:" + id); actor.setDisplayName(video.getSnippet().getChannelTitle()); actor.setSummary(video.getSnippet().getDescription()); actor.setAdditionalProperty("handle", video.getSnippet().getChannelTitle()); return actor; }
/** * Given a {@link YouTube.Videos} object and an * {@link Activity} object, fill out the appropriate details * * @param video Video * @param activity Activity * @throws ActivitySerializerException ActivitySerializerException */ public static void updateActivity(Video video, Activity activity, String channelId) throws ActivitySerializerException { activity.setActor(buildActor(video, video.getSnippet().getChannelId())); activity.setVerb("post"); activity.setId(formatId(activity.getVerb(), Optional.ofNullable(video.getId()).orElse(null))); activity.setPublished(new DateTime(video.getSnippet().getPublishedAt().getValue())); activity.setTitle(video.getSnippet().getTitle()); activity.setContent(video.getSnippet().getDescription()); activity.setUrl("https://www.youtube.com/watch?v=" + video.getId()); activity.setProvider(getProvider()); activity.setObject(buildActivityObject(video)); addYoutubeExtensions(activity, video); }
private void prepareYElementFromApi(Video video, YElement yElement) throws ParseException { yElement.addName(new YName(video.getSnippet().getTitle())); yElement.addDescription(new YDescription(YLanguage.Undetermined, video.getSnippet().getDescription() , DescriptionTypes.DS_SUMMARY)); prepareDate(video, yElement); String license = video.getStatus().getLicense(); if(null != license && license.contains("creativeCommon")) { yElement.addTagList(new YTagList().setType(YModelUtils.LICENSE).addValue("cc0")); } prepareContent(video, yElement); List<String> tags = video.getSnippet().getTags(); if (CollectionUtils.isNotEmpty(tags)) { yElement.addTagList(new YTagList().setType(TagTypes.TG_KEYWORD).setValues(tags)); } YCurrent currentLevel = new YCurrent().setLevel(VideoConstants.VIDEO_CURRENT_LEVEL); yElement.addStructure(new YStructure() .setHierarchy(HierarchyWithLevelIds.EXT_HIERARCHY_PUBLICATION) .setCurrent(currentLevel)); prepareAttributes(video, yElement); }