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

Store images pulled from iFramely in our own CDN #3450

Open
catdevnull opened this issue Sep 13, 2024 · 6 comments
Open

Store images pulled from iFramely in our own CDN #3450

catdevnull opened this issue Sep 13, 2024 · 6 comments
Labels
Module: Rendering Going from 'raw' Markdown/HTML to what subscribers see in their browser/inbox. Type: Performance Improvements to the speed and efficiency of the interface and backend. Type: Stability Work that will make Buttondown more reliable and decrease manual/operator labor for staff.

Comments

@catdevnull
Copy link

Screenshot 2024-09-13 at 6 59 25 PM

@catdevnull catdevnull added Type: Bug A problem that impairs or prevents the functions of the product. Module: Rendering Going from 'raw' Markdown/HTML to what subscribers see in their browser/inbox. labels Sep 13, 2024
@catdevnull catdevnull self-assigned this Sep 13, 2024
@catdevnull
Copy link
Author

catdevnull commented Sep 16, 2024

Now TikTok embeds aren't loading at all in emails :/ even in the marketing page. Not sure what regressed. Looking into it

It seems that it fixed itself after a few hours 🤷 maybe an intermittent issue with iframely

@catdevnull
Copy link
Author

It seems that TikTok's thumbnail URLs are IP-specific or something similar. Example: https://p16-sign-va.tiktokcdn.com/obj/tos-maliva-p-0068/82eb60c8e35e45cc9e8208c254cc244e_1680895330?x-expires=1713117600&x-signature=oYnzq5DmewcFor2woi5HcEu7JRs%3D

Screenshot 2024-09-16 at 6 52 31 PM

I don't think there's a good way to solve this; we can probably scrap TikTok ourselves, but I believe that's probably a stretch? But otherwise we need to hide TikTok thumbnails from emails, which sucks.

unrelated: hotlinking

Apparently we are doing something that iframely doesn't recommend

A preview image, usually smaller size, but not guaranteed. We recommend that you do not hot-link third party images on your site. There’s Camo, for example.

https://iframely.com/docs/links

Even then, if we put a reverse proxy for it, it probably won't work, because the URL is likely locked to iframely's server's IPs.

@catdevnull
Copy link
Author

Took a quick look into scraping. I don't know how stable this would be, but it seems fairly trivial:

  1. GET the HTML for the page
  2. Parse the JSON inside script#__UNIVERSAL_DATA_FOR_REHYDRATION__
  3. parsed['__DEFAULT_SCOPE__']['webapp.video-detail']['itemInfo']['itemStruct'].video.cover is the URL

But then we would have to upload the cover somewhere.. and cache it.. 🤔

@jmduke would like your input in this

@jmduke
Copy link
Member

jmduke commented Sep 17, 2024

Huh, fascinating. So for you https://buttondown.com/features/integrations/tiktok does not currently work? (It does on my end, which points to, as you say, some sort of IP/geo-based perms which makes sense because we're hitting a CDN.)

In that case, I think we can combine this issue with the hotlinking guidance and just re-upload thumbnails to our own S3 bucket.

@catdevnull
Copy link
Author

Well, it is working now, lol... but yesterday, it looked like the first post.

Maybe, instead, what's happening is that iframely is caching a thumbnail url that expires (but isn't IP-locked) and eventually refreshes it. That might be more likely. Either way, the un-hotlinking stuff should help prevent it in most cases.

Should I do the reuploading stuff? I'm not familiar with how we do these kinds of things, especially because we really want to deduplicate stuff (and ideally store where we got it from.)

@jmduke
Copy link
Member

jmduke commented Sep 17, 2024

Yup, that all tracks.

I'd say feel free to leave it for now. I'll retitle this issue to reflect the scope creep and think a bit about the right way to approach it

@jmduke jmduke added Type: Performance Improvements to the speed and efficiency of the interface and backend. Type: Stability Work that will make Buttondown more reliable and decrease manual/operator labor for staff. and removed Type: Bug A problem that impairs or prevents the functions of the product. labels Sep 17, 2024
@jmduke jmduke changed the title TikTok embeds: profile picture (or preview?) fails to load Store images pulled from iFramely in our own CDN Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Rendering Going from 'raw' Markdown/HTML to what subscribers see in their browser/inbox. Type: Performance Improvements to the speed and efficiency of the interface and backend. Type: Stability Work that will make Buttondown more reliable and decrease manual/operator labor for staff.
Projects
Status: In progress
Development

No branches or pull requests

2 participants