tdryer/hangups

Fetching video attachment metadata

Terrance opened this issue · 3 comments

When a message containing a video is received, all the media URLs in the PlusPhoto object are just the video thumbnail, with or without the overlaid play icon. hangouts.google.com makes an API request to GET https://hangoutsusermedia-pa.clients6.google.com/v1/usermediaservice/videoinformation, with fields key, mediaItemId.legacyPhotoId.obfuscatedUserId and mediaItemId.legacyPhotoId.photoId, but also an authorization heading using SAPISIDHASH. It looks like the hangups client has a SAPISID lying around -- any hints on generating the request for this?

https://github.com/das7pad/hangoutsbot/blob/1a3070925e648609b6cbe1eb62f885208b7ec71d/hangupsbot/sync/handler.py#L798

One of the fields event.conv_event._event.chat_message.message_content.attachment[0].embed_item.plus_photo.thumbnail.url or event.conv_event._event.chat_message.message_content.attachment[0].embed_item.plus_photo.thumbnail.image_url contains an url to the video data.

Verified just a minute ago.

thumbnail.url does redirect there, but presumably requires a G+ session cookie -- I see your code borrows hangups' cookies so I guess it's already authed for that. thumbnail.image_url, url and original_content_url are all the same play button preview.

chat_message {
  message_content {
    attachment {
      embed_item {
        type: ITEM_TYPE_PLUS_PHOTO
        id: "and0"
        plus_photo {
          thumbnail {
            url: "https://plus.google.com/photos/albums/$album?pid=$photo&oid=$me"
            image_url: "https://lh3.googleusercontent.com/$p/$q/$r/$s/s0/2019-09-15"
            width_px: 480
            height_px: 232
          }
          owner_obfuscated_id: "$me"
          album_id: "$album"
          photo_id: "$photo"
          url: "https://lh3.googleusercontent.com/$p/$q/$r/$s/s0/2019-09-15"
          original_content_url: "https://lh3.googleusercontent.com/$z"
          stream_id: "BABEL_UNIQUE_ID_$uuid"
          stream_id: "BABEL_STREAM_ID"
          stream_id: "shared_group_$stream"
        }
      }
    }
  }
}

Yep, looks like I can retrieve it just fine. 👍