Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:7onez Cti expert Sharelink Resolve Unwrap

From Leeroopedia
Knowledge Sources
Domains OSINT, Social_Media
Last Updated 2026-10-28 14:00 GMT

Overview

Concrete tool for unwrapping social share links (vm.tiktok.com, t.co, bit.ly, facebook.com/share) to their final URL and extracting platform IDs, provided by the cti-expert social intake module.

Description

The unwrap function in sharelink_resolve.py follows every URL layer nested via carrier params (outermost first), breadth-first and depth-bounded (max_depth default 6). It never revisits a URL. The platform_ids function extracts platform-specific identifiers from the resolved URLs: Facebook (page_id, profile_id, vanity, video_id, group, post_id), Instagram (username, shortcode, media_kind), TikTok (sec_user_id, u_code, share_item_id). The analyse function combines both into a single result with the redirect chain and platform IDs.

The resolver is stdlib-only — urllib.request, urllib.parse, re, json — so it runs on any machine with zero dependencies.

Usage

Import this when you need to:

  • Unwrap a social share link to its final destination URL.
  • Extract Facebook/Instagram/TikTok platform IDs from a share link.
  • Determine the redirect chain (for OPSEC analysis of the sharing platform).

Code Reference

Source Location

  • Repository: cti-expert
  • File: scripts/osint/sharelink_resolve.py
  • Lines: L105-126 (unwrap), L237-260 (platform_ids), L266-280 (analyse)

Signature

def unwrap(url, max_depth=MAX_UNWRAP_DEPTH):
    """Every URL layer nested in `url` via carrier params, outermost first.
    Breadth over all carrier params at each layer; depth-bounded; never revisits."""

def platform_ids(urls: list) -> dict:
    """Extract platform-specific IDs from a list of URLs."""

def analyse(input_url: str, final_url: str) -> dict:
    """Combine unwrap + platform_ids into a single result."""

Import

from sharelink_resolve import unwrap, platform_ids, analyse

I/O Contract

Inputs

Name Type Required Description
url str Yes /// Share link URL
max_depth int No /// Max unwrap depth (default 6)

Outputs

Name Type Description
layers list [{url, depth, via_param}] — redirect chain
platform_ids dict {facebook/instagram/tiktok: {page_id, user_id, ...}}

Usage Examples

Unwrap a TikTok Share Link

from sharelink_resolve import unwrap, platform_ids

layers = unwrap("https://vm.tiktok.com/Z123abc/")
final_url = layers[-1]["url"]
ids = platform_ids([l["url"] for l in layers])
print(final_url)
print(ids.get("tiktok", {}))  # {sec_user_id, u_code, share_item_id, ...}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment