yakyak / hangupsjs

google hangouts client library for nodejs
226 stars 46 forks source link

Support parsing of embedded photos redux #55

Closed nave7693 closed 7 years ago

nave7693 commented 8 years ago

This is a repost of #46 rebased to latest master

Added a DictField to support the way hangout is embedding links to images in their JSON. Implemented parsing of the PLUS_PHOTO type though it is a slight variation from tdryer's protocol doc.

averissimo commented 7 years ago

Had problems running YakYak with this implementation.

Can it be plugged directly without modifications?

image

averissimo commented 7 years ago

@nave7693 I am having the same testing it with latest hangupsjs code just by launching hangupsjs example code.

nave7693 commented 7 years ago

How do you get past the initial login prompt that asks for a token? I am having trouble even connecting to hangouts so I can't run the example code.

averissimo commented 7 years ago

To get pass the login I'm using files generated by YakYak, namely refreshtoken.txt.. I just copied it from .config/yakyak/refreshtoken.txt (location differs with operating system and requires a successful login with yakyak)

Made some changes on top of you code

1. DictField

I believe I corrected the issue in https://github.com/averissimo/hangupsjs/tree/fix-embed

I had to make some changes to your DictField to allow for a named an optional property assignment so that both below are valid

DictField({
      '27639957': [s.PLUS_PHOTO, 'data'],
})
#result: {data: Object}
DictField({
      '27639957': s.PLUS_PHOTO
})
# result { '27639957': Object }

2 Schema

Corrected the schema with data from hangouts server

Result

image

averissimo commented 7 years ago

haven't said before, but great work @nave7693 !!

All I did was move the pieces to the right place, but the DictField was a really cool implementation :)

nave7693 commented 7 years ago

Nice work with the investigation and fix, please feel free to send your own PR to get this code in. I do hope that some day we don't have to do this anymore - we might be able to use Google's javascript implementation for ProtoBuffer and generate the parsing schema objects directly from the one in tdryer's hangups instead of rolling our own. Not only will we save time, tdryer's schema is also more complete!

averissimo commented 7 years ago

done it #59, thanks man!

I hope that too, hangups is very active and it would be cool to use it with something like node-python or try pyjs