I currently treat GROUPSTART messages like repeat messages, and pull all the bytes (up to and including GROUPEND) in protoquuery, so I can do this:
const medias = query(appTree, '10:bytes').map(i => {
const t = getTree(i)
return {
type: query(t, '1:var').pop(),
url: query(t, '5:string').pop()
}
})
expect(medias.length).toEqual(10)
const icon = medias.find(m => m.type === 4).url
const screenshots = medias.filter(m => m.type === 1).map(m => m.url)
const videos = medias.filter(m => m.type === 3).map(m => m.url)
const videoThumbs = medias.filter(m => m.type === 13).map(m => m.url)
and get this:
{
"icon": "https://play-lh.googleusercontent.com/qTt7JkhZ-U0kevENyTChyUijNUEctA3T5fh7cm8yzKUG0UAnMUgOMpG_9Ln7D24NbQ",
"screenshots": [
"https://play-lh.googleusercontent.com/m-S0SqOv428DZcm46NJlyv0pffYpfsNjWz6iyf9LVM1TCWbzWs3clWaugjfzXXnCTbY",
"https://play-lh.googleusercontent.com/WYyQPx2lhnCQYueR8q99NhIsxzJZX4NIHdlf0UxoPiwrHg1WlYGiFTy51F1aBZxaslE",
"https://play-lh.googleusercontent.com/ioUSrp79Yx_rZikYRI_XtK_mdP5kavcm9oWDWYrgVqXfS4bpW46y41lbGTQJT7tPn7ej",
"https://play-lh.googleusercontent.com/-8X4UtNoQm8k7cX7q5jT2fQmFFQbSJnreoxensBZQ7kuIs9d8FWwtyxM3QvqKd4SdBOA",
"https://play-lh.googleusercontent.com/_08ljE8yjFzGuroCP-6cemh2LIrQ_zptq5K4KLahsqAsCq5cjLSU-ghzkHhf2_0UZ9c",
"https://play-lh.googleusercontent.com/ofJcMSH2oJKzax3lscP-IJCZecGnkt7XWpt7L1J7KVhridE7wejHWqhrl4oV000sty1E"
],
"videos": [
"https://youtu.be/XT7YEb9_Muw"
],
"videoThumbs": [
"https://i.ytimg.com/vi/XT7YEb9_Muw/hqdefault.jpg"
]
}
It works, but it's a bit awkward to have to pull the sub-messages first (10:bytes) then parse each as a tree. I would rather it worked more like this:
const mediaTypes = query(appTree, '10.1:var')
const mediaUrls = query(appTree, '10.5:string')
Where 10 is considered a "repeating message field" and 1/5 are fields of that, which you can pull as normal types.
I currently treat
GROUPSTARTmessages like repeat messages, and pull all the bytes (up to and includingGROUPEND) in protoquuery, so I can do this:and get this:
{ "icon": "https://play-lh.googleusercontent.com/qTt7JkhZ-U0kevENyTChyUijNUEctA3T5fh7cm8yzKUG0UAnMUgOMpG_9Ln7D24NbQ", "screenshots": [ "https://play-lh.googleusercontent.com/m-S0SqOv428DZcm46NJlyv0pffYpfsNjWz6iyf9LVM1TCWbzWs3clWaugjfzXXnCTbY", "https://play-lh.googleusercontent.com/WYyQPx2lhnCQYueR8q99NhIsxzJZX4NIHdlf0UxoPiwrHg1WlYGiFTy51F1aBZxaslE", "https://play-lh.googleusercontent.com/ioUSrp79Yx_rZikYRI_XtK_mdP5kavcm9oWDWYrgVqXfS4bpW46y41lbGTQJT7tPn7ej", "https://play-lh.googleusercontent.com/-8X4UtNoQm8k7cX7q5jT2fQmFFQbSJnreoxensBZQ7kuIs9d8FWwtyxM3QvqKd4SdBOA", "https://play-lh.googleusercontent.com/_08ljE8yjFzGuroCP-6cemh2LIrQ_zptq5K4KLahsqAsCq5cjLSU-ghzkHhf2_0UZ9c", "https://play-lh.googleusercontent.com/ofJcMSH2oJKzax3lscP-IJCZecGnkt7XWpt7L1J7KVhridE7wejHWqhrl4oV000sty1E" ], "videos": [ "https://youtu.be/XT7YEb9_Muw" ], "videoThumbs": [ "https://i.ytimg.com/vi/XT7YEb9_Muw/hqdefault.jpg" ] }It works, but it's a bit awkward to have to pull the sub-messages first (
10:bytes) then parse each as a tree. I would rather it worked more like this:Where
10is considered a "repeating message field" and 1/5 are fields of that, which you can pull as normal types.