pastebin - collaborative debugging tool
kpaste.net RSS


cinebolt
Posted by Anonymous on Fri 14th Aug 2026 06:34
raw | new post

  1. // Helper function to generate a standard UUID v4
  2. function generateUUID() {
  3.   return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  4.     var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
  5.     return v.toString(16);
  6.   });
  7. }
  8.  
  9. // Common headers required by the API
  10. const HEADERS = {
  11.   "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
  12.   "Referer": "https://cinebolt.org/"
  13. };
  14.  
  15. /**
  16.  * Fetches the stream URL for a given TMDB ID.
  17.  * If season and episode are provided, it fetches a TV show, otherwise a Movie.
  18.  */
  19. async function fetchStreamUrl(tmdbid, season = null, episode = null) {
  20.   const isTV = (season !== null && episode !== null);
  21.   const typeLabel = isTV ? `TV Show (S${season}E${episode})` : `Movie`;
  22.  
  23.   console.log(`\n--- Fetching ${typeLabel} | TMDB ID: ${tmdbid} ---`);
  24.  
  25.   // Generate a single session nonce to use across both requests
  26.   let sessionNonce = generateUUID();
  27.  
  28.   // === STEP 1: Fetch Token ===
  29.   let tokenUrl = `https://cinebolt.org/api/stream-token?tmdb_id=${tmdbid}&nonce=${sessionNonce}`;
  30.   if (isTV) {
  31.     tokenUrl += `&season=${season}&episode=${episode}`;
  32.   }
  33.  
  34.   let tokenRes;
  35.   try {
  36.     const response = await fetch(tokenUrl, { headers: HEADERS });
  37.     if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
  38.     tokenRes = await response.json();
  39.   } catch (e) {
  40.     throw new Error(`Step 1 (Token) Failed: ${e.message}`);
  41.   }
  42.  
  43.   let streamId = tokenRes.id || tmdbid;
  44.   let streamToken = tokenRes.token;
  45.  
  46.   if (!streamToken) {
  47.     throw new Error(`Could not find 'token' in the response: ${JSON.stringify(tokenRes)}`);
  48.   }
  49.  
  50.   // === STEP 2: Fetch Stream JSON ===
  51.   // Using trailing slash on {streamId}/ and unencoded token '==' to satisfy backend parser constraints
  52.   let streamUrl = `https://cinebolt.org/api/stream/${streamId}/?token=${streamToken}&nonce=${sessionNonce}`;
  53.   if (isTV) {
  54.     streamUrl += `&season=${season}&episode=${episode}`;
  55.   }
  56.  
  57.   let streamData;
  58.   try {
  59.     const response = await fetch(streamUrl, { headers: HEADERS });
  60.     if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
  61.     streamData = await response.json();
  62.   } catch (e) {
  63.     throw new Error(`Step 2 (Stream Data) Failed: ${e.message}`);
  64.   }
  65.  
  66.   // === STEP 3: Parse File URL ===
  67.   let fileUrl = streamData?.sources?.[0]?.file;
  68.   if (!fileUrl) {
  69.     throw new Error(`Missing 'file' property. Raw JSON: ${JSON.stringify(streamData)}`);
  70.   }
  71.  
  72.   return fileUrl;
  73. }
  74.  
  75. // === MAIN EXECUTION ===
  76. async function runExamples() {
  77.   console.log("=== Cinebolt POC Scraper ===");
  78.  
  79.   // Example 1: Movie (e.g., Ocean's Eleven - TMDB: 161)
  80.   try {
  81.     const movieUrl = await fetchStreamUrl(161);
  82.     console.log("SUCCESS! Movie Stream URL:");
  83.     console.log(movieUrl);
  84.   } catch (err) {
  85.     console.error("Movie Example Failed:", err.message);
  86.   }
  87.  
  88.   // Example 2: TV Show (e.g., Breaking Bad - TMDB: 1396, Season 1, Episode 1)
  89.   try {
  90.     const tvUrl = await fetchStreamUrl(1396, 1, 1);
  91.     console.log("SUCCESS! TV Stream URL:");
  92.     console.log(tvUrl);
  93.   } catch (err) {
  94.     console.error("TV Show Example Failed:", err.message);
  95.   }
  96.  
  97.   console.log("\n============================");
  98. }
  99.  
  100. runExamples();

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at