Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Parse multiimage community posts #3599

Merged

Conversation

ChunkyProgrammer
Copy link
Contributor

@ChunkyProgrammer ChunkyProgrammer commented Jan 29, 2023

#3522
FreeTubeApp/FreeTube#1568

This PR will allow the parsing of "MultiImage" community posts. It's essentially an array of image thumbnails.
This is an example of how the attachment is formatted:

      "attachment": {
        "type": "multiImage",
        "images": [
          [
            {
              "url": "https://yt3.ggpht.com/lveyJ9xgshW-HMEXABj2qpVWE3tfpxmxGWUaJxoyFOirBDkOiAy1gQnWfsS0mrTasGcIo6akAv9E__U=s320-c-fcrop64=1,000029fcfffff6c8-nd-v1",
              "width": 320,
              "height": 320
            },
            {
              "url": "https://yt3.ggpht.com/lveyJ9xgshW-HMEXABj2qpVWE3tfpxmxGWUaJxoyFOirBDkOiAy1gQnWfsS0mrTasGcIo6akAv9E__U=s560-c-fcrop64=1,000029fcfffff6c8-nd-v1",
              "width": 560,
              "height": 560
            },
            {
              "url": "https://yt3.ggpht.com/lveyJ9xgshW-HMEXABj2qpVWE3tfpxmxGWUaJxoyFOirBDkOiAy1gQnWfsS0mrTasGcIo6akAv9E__U=s640-c-fcrop64=1,000029fcfffff6c8-nd-v1",
              "width": 640,
              "height": 640
            },
            {
              "url": "https://yt3.ggpht.com/lveyJ9xgshW-HMEXABj2qpVWE3tfpxmxGWUaJxoyFOirBDkOiAy1gQnWfsS0mrTasGcIo6akAv9E__U=s1280-c-fcrop64=1,000029fcfffff6c8-nd-v1",
              "width": 1280,
              "height": 1280
            },
            {
              "url": "https://yt3.ggpht.com/lveyJ9xgshW-HMEXABj2qpVWE3tfpxmxGWUaJxoyFOirBDkOiAy1gQnWfsS0mrTasGcIo6akAv9E__U=s2000-c-fcrop64=1,000029fcfffff6c8-nd-v1",
              "width": 2000,
              "height": 2000
            }
          ],
          [
            {
              "url": "https://yt3.ggpht.com/1Y1FPvZeQ7B-AuRy2umFkMimXHu6ifJCKRtkLG6NOUFnm2tRaoMBnRyoGzQ7y2GUIsnrRiC5uUsyDg=s320-c-fcrop64=1,00000000ffffffff-nd-v1",
              "width": 320,
              "height": 320
            },
            {
              "url": "https://yt3.ggpht.com/1Y1FPvZeQ7B-AuRy2umFkMimXHu6ifJCKRtkLG6NOUFnm2tRaoMBnRyoGzQ7y2GUIsnrRiC5uUsyDg=s560-c-fcrop64=1,00000000ffffffff-nd-v1",
              "width": 560,
              "height": 560
            },
            {
              "url": "https://yt3.ggpht.com/1Y1FPvZeQ7B-AuRy2umFkMimXHu6ifJCKRtkLG6NOUFnm2tRaoMBnRyoGzQ7y2GUIsnrRiC5uUsyDg=s640-c-fcrop64=1,00000000ffffffff-nd-v1",
              "width": 640,
              "height": 640
            },
            {
              "url": "https://yt3.ggpht.com/1Y1FPvZeQ7B-AuRy2umFkMimXHu6ifJCKRtkLG6NOUFnm2tRaoMBnRyoGzQ7y2GUIsnrRiC5uUsyDg=s1280-c-fcrop64=1,00000000ffffffff-nd-v1",
              "width": 1280,
              "height": 1280
            },
            {
              "url": "https://yt3.ggpht.com/1Y1FPvZeQ7B-AuRy2umFkMimXHu6ifJCKRtkLG6NOUFnm2tRaoMBnRyoGzQ7y2GUIsnrRiC5uUsyDg=s2000-c-fcrop64=1,00000000ffffffff-nd-v1",
              "width": 2000,
              "height": 2000
            }
          ],
          [
            {
              "url": "https://yt3.ggpht.com/glqnpJulKWdDr_L6BfTXX8g0HrdCDx4AhsA2WkNnRTSLPpj_MIiP7K52a9-kX4SWCLd-grH4Si5Jdnw=s320-c-fcrop64=1,008c0000ff73ffff-nd-v1",
              "width": 320,
              "height": 320
            },
            {
              "url": "https://yt3.ggpht.com/glqnpJulKWdDr_L6BfTXX8g0HrdCDx4AhsA2WkNnRTSLPpj_MIiP7K52a9-kX4SWCLd-grH4Si5Jdnw=s560-c-fcrop64=1,008c0000ff73ffff-nd-v1",
              "width": 560,
              "height": 560
            },
            {
              "url": "https://yt3.ggpht.com/glqnpJulKWdDr_L6BfTXX8g0HrdCDx4AhsA2WkNnRTSLPpj_MIiP7K52a9-kX4SWCLd-grH4Si5Jdnw=s640-c-fcrop64=1,008c0000ff73ffff-nd-v1",
              "width": 640,
              "height": 640
            },
            {
              "url": "https://yt3.ggpht.com/glqnpJulKWdDr_L6BfTXX8g0HrdCDx4AhsA2WkNnRTSLPpj_MIiP7K52a9-kX4SWCLd-grH4Si5Jdnw=s1280-c-fcrop64=1,008c0000ff73ffff-nd-v1",
              "width": 1280,
              "height": 1280
            },
            {
              "url": "https://yt3.ggpht.com/glqnpJulKWdDr_L6BfTXX8g0HrdCDx4AhsA2WkNnRTSLPpj_MIiP7K52a9-kX4SWCLd-grH4Si5Jdnw=s2000-c-fcrop64=1,008c0000ff73ffff-nd-v1",
              "width": 2000,
              "height": 2000
            }
          ],
          [
            {
              "url": "https://yt3.ggpht.com/TI7Hl13GxRZz406yEWfdsdoM0_AIuuTqM8ZQ4b8kUdjFT92xzW3WvP_HIQ0Dutf1DXqfOsh4UShwZAQ=s320-c-fcrop64=1,0bec0000b69fffff-nd-v1",
              "width": 320,
              "height": 320
            },
            {
              "url": "https://yt3.ggpht.com/TI7Hl13GxRZz406yEWfdsdoM0_AIuuTqM8ZQ4b8kUdjFT92xzW3WvP_HIQ0Dutf1DXqfOsh4UShwZAQ=s560-c-fcrop64=1,0bec0000b69fffff-nd-v1",
              "width": 560,
              "height": 560
            },
            {
              "url": "https://yt3.ggpht.com/TI7Hl13GxRZz406yEWfdsdoM0_AIuuTqM8ZQ4b8kUdjFT92xzW3WvP_HIQ0Dutf1DXqfOsh4UShwZAQ=s640-c-fcrop64=1,0bec0000b69fffff-nd-v1",
              "width": 640,
              "height": 640
            },
            {
              "url": "https://yt3.ggpht.com/TI7Hl13GxRZz406yEWfdsdoM0_AIuuTqM8ZQ4b8kUdjFT92xzW3WvP_HIQ0Dutf1DXqfOsh4UShwZAQ=s1280-c-fcrop64=1,0bec0000b69fffff-nd-v1",
              "width": 1280,
              "height": 1280
            },
            {
              "url": "https://yt3.ggpht.com/TI7Hl13GxRZz406yEWfdsdoM0_AIuuTqM8ZQ4b8kUdjFT92xzW3WvP_HIQ0Dutf1DXqfOsh4UShwZAQ=s2000-c-fcrop64=1,0bec0000b69fffff-nd-v1",
              "width": 2000,
              "height": 2000
            }
          ],
          [
            {
              "url": "https://yt3.ggpht.com/pCRgvqzJPeW1mXhNSTW9_Ukvzn4z0UFZN9BgG6M96A_UIMx2D9Ko5EQcm6HaN52urORrZhX25gMHCQ=s320-c-fcrop64=1,1eb30000c966ffff-nd-v1",
              "width": 320,
              "height": 320
            },
            {
              "url": "https://yt3.ggpht.com/pCRgvqzJPeW1mXhNSTW9_Ukvzn4z0UFZN9BgG6M96A_UIMx2D9Ko5EQcm6HaN52urORrZhX25gMHCQ=s560-c-fcrop64=1,1eb30000c966ffff-nd-v1",
              "width": 560,
              "height": 560
            },
            {
              "url": "https://yt3.ggpht.com/pCRgvqzJPeW1mXhNSTW9_Ukvzn4z0UFZN9BgG6M96A_UIMx2D9Ko5EQcm6HaN52urORrZhX25gMHCQ=s640-c-fcrop64=1,1eb30000c966ffff-nd-v1",
              "width": 640,
              "height": 640
            },
            {
              "url": "https://yt3.ggpht.com/pCRgvqzJPeW1mXhNSTW9_Ukvzn4z0UFZN9BgG6M96A_UIMx2D9Ko5EQcm6HaN52urORrZhX25gMHCQ=s1280-c-fcrop64=1,1eb30000c966ffff-nd-v1",
              "width": 1280,
              "height": 1280
            },
            {
              "url": "https://yt3.ggpht.com/pCRgvqzJPeW1mXhNSTW9_Ukvzn4z0UFZN9BgG6M96A_UIMx2D9Ko5EQcm6HaN52urORrZhX25gMHCQ=s2000-c-fcrop64=1,1eb30000c966ffff-nd-v1",
              "width": 2000,
              "height": 2000
            }
          ]
        ]
      }

I do not plan on adding support for viewing these posts in invidious at this time as I am unfamiliar with ecr files and I think adding support may require a js library or doing something like this (which is not keyboard accessible): https://medium.com/carwow-product-engineering/making-a-carousel-component-without-javascript-f7c68e3e6f8b

Another option would be to have a div with a scrollbar to allow scrolling to different images.

@SamantazFox SamantazFox merged commit d6dd341 into iv-org:master Feb 2, 2023
@ChunkyProgrammer ChunkyProgrammer deleted the Feat-multi-image-community-posts branch February 2, 2023 21:54
@SamantazFox
Copy link
Member

Thanks for your contribution ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants