private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
u = map.getMediaURLHttps();
/** * Generates preview for a single Twitter-side {@link MediaEntity} matching it against the {@link * TwitterMediaEntity} enumeration. * * @param entity The entity whose preview will be generated. * * @return The preview for the given entity. * * @throws IllegalArgumentException when an unsupported entity is given since it should only be called on valid * entities. */ private Node embedOne(final MediaEntity entity) { switch (TwitterMediaEntity.fromTwitterType(entity.getType())) { case PHOTO: return directPhotoHandler.handleMedia(entity.getMediaURLHttps()); case VIDEO: case ANIMATED_GIF: return twitterVideoHandler.handleMedia(entity.getVideoVariants()); case UNMANAGED: default: throw new IllegalArgumentException("Twitter type " + entity.getType() + " is not supported!"); } }
private Record extractRecord(String idPrefix, Schema avroSchema, Status status) { User user = status.getUser(); Record doc = new Record(avroSchema); doc.put("id", idPrefix + status.getId()); doc.put("created_at", formatterTo.format(status.getCreatedAt())); doc.put("retweet_count", status.getRetweetCount()); doc.put("retweeted", status.isRetweet()); doc.put("in_reply_to_user_id", status.getInReplyToUserId()); doc.put("in_reply_to_status_id", status.getInReplyToStatusId()); addString(doc, "source", status.getSource()); addString(doc, "text", status.getText()); MediaEntity[] mediaEntities = status.getMediaEntities(); if (mediaEntities.length > 0) { addString(doc, "media_url_https", mediaEntities[0].getMediaURLHttps()); addString(doc, "expanded_url", mediaEntities[0].getExpandedURL()); } doc.put("user_friends_count", user.getFriendsCount()); doc.put("user_statuses_count", user.getStatusesCount()); doc.put("user_followers_count", user.getFollowersCount()); addString(doc, "user_location", user.getLocation()); addString(doc, "user_description", user.getDescription()); addString(doc, "user_screen_name", user.getScreenName()); addString(doc, "user_name", user.getName()); return doc; }
static Struct convertMediaEntity(MediaEntity mediaEntity) { return new Struct(SCHEMA_MEDIA_ENTITY) .put("Id", mediaEntity.getId()) .put("Type", mediaEntity.getType()) .put("MediaURL", mediaEntity.getMediaURL()) .put("Sizes", convertSizes(mediaEntity.getSizes())) .put("MediaURLHttps", mediaEntity.getMediaURLHttps()) .put("VideoAspectRatioWidth", mediaEntity.getVideoAspectRatioWidth()) .put("VideoAspectRatioHeight", mediaEntity.getVideoAspectRatioHeight()) .put("VideoDurationMillis", mediaEntity.getVideoDurationMillis()) .put("VideoVariants", convert(mediaEntity.getVideoVariants())) .put("ExtAltText", mediaEntity.getExtAltText()) .put("URL", mediaEntity.getURL()) .put("Text", mediaEntity.getText()) .put("ExpandedURL", mediaEntity.getExpandedURL()) .put("Start", mediaEntity.getStart()) .put("End", mediaEntity.getEnd()) .put("DisplayURL", mediaEntity.getDisplayURL()); }