What people actually paste into a TikTok downloader (and how to handle each one)
When I built TikTik, a free web tool that saves public TikTok videos without the watermark, I assumed the input would be simple: a URL like https://www.tiktok.com/@user/video/123. Real users proved me wrong quickly. Here
When I built TikTik, a free web tool that saves public TikTok videos without the watermark, I assumed the input would be simple: a URL like https://www.tiktok.com/@user/video/123. Real users proved me wrong quickly. Here is what actually lands in the input box, and what the backend has to do with each case.
1. A whole sentence, not a link
On Android, "Share β Copy link" sometimes copies text around the link, and people also paste from chats. So the first step happens in the browser: take the first http(s):// run of characters and ignore the rest.
const url = text.match(/https?:\/\/(?:(?!https?:\/\/)[^\s<>"'])+/i)?.[0] ?? "";
The negative lookahead stops two links glued together without a space from turning into one.
2. Three kinds of short links
Most mobile shares are short links: vm.tiktok.com/XXXX, vt.tiktok.com/XXXX, and from the web app, www.tiktok.com/t/XXXX. None of them say whether the post is a video or a photo slideshow, so you have to follow the redirect before deciding how to parse.
I first handled only the vm. and vt. hosts. The /t/ form slipped through to the video parser, which happened to work for videos and failed for slideshows. A real user hit it in production before I did.
Short links also expire. An expired one doesn't return a 404. It redirects to the TikTok home page. So the rule is: if the resolved URL has no /@user/ in it, tell the user to copy the link again instead of showing a generic error.
3. Tracking parameters everywhere
A typical shared link looks like this:
https://www.tiktok.com/@someone/video/7xxxxxxxxxxxxxxxxxx?_r=1&_t=ZM-xxxx&is_from_webapp=1&sharer_language=es&share_enter_from=general_search
Everything after ? is about the sharer, not the post. I reduce every post URL to https://www.tiktok.com/@user/(video|photo)/<id>, so the same post always maps to one key for logs and caching.
4. Links wrapped by Google
People who find a TikTok in the Google app and tap Share get a Google link, not a TikTok link: google.com/url?q=..., /goto?url=..., or share.google/.... The first two carry the target in the query string. share.google needs one request without following redirects to read the Location header. I unwrap up to a few hops, cache the result, and only then check that the final host is really tiktok.com.
5. Photo posts that look like videos
Slideshows open like videos in the app, but they are a list of images plus one music track. Their URLs use /photo/ instead of /video/, which is the only reliable way to tell before parsing. They need a different code path: list each image, offer them one by one or as a numbered ZIP, and give the music its own button.
6. Pages that are not a post
Profile pages (/@user), sound pages (/music/...), hashtags, search and discover pages all get pasted. A sound page is the interesting one: people want "the song", but the page is a list of videos. Instead of passing these to the parser and returning a stack trace, I match them up front and answer with something actionable: paste the link of a video that uses this sound.
7. Posts that exist but aren't available
Deleted posts, private accounts and videos limited to some regions all come back as errors from the parser, with messages users can't act on. I map them to one plain sentence: the content may be deleted, private or not available in our server's region. When it's a region issue, retrying from another region first is worth it before giving up.
What I learned
The download itself was the easy part. Most of the work was turning messy input into either one clean post URL or one clear sentence the user can act on. Most of the cases above showed up in real usage before I thought of them. If you build anything that accepts links from mobile users, log the raw input (without personal data) from day one.
Stack, for the curious: Python and FastAPI with yt-dlp for public posts, Nuxt with server-side rendering for the pages. Only public posts can be downloaded, and nothing is stored after the download.
Disclosure: I'm the developer of TikTik. If you have seen other strange link formats, I'd like to hear about them in the comments.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.