# YouTube Video Metadata & Direct Stream Extractor (`datapilot/youtube-video-metadata-direct-stream-extractor`) Actor

extracts video titles, direct video links, thumbnails, uploader names, durations, and view counts from YouTube URLs. Supports bulk URL processing, playlist filtering, fast extraction, and Apify Proxy fallback. Ideal for video research, content analysis, and automated data collection.

- **URL**: https://apify.com/datapilot/youtube-video-metadata-direct-stream-extractor.md
- **Developed by:** [Data Pilot](https://apify.com/datapilot) (community)
- **Categories:** Videos, Other
- **Features:** Limited permissions
- **Stats:** 27 total users, 0 monthly users, 91.2% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 extracted youtube video results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

🎬 **YouTube Video Metadata & Direct Stream Extractor** is an Apify Actor designed to read public YouTube video links and return their details together with a direct media stream link. This **YouTube Video Metadata** extractor provides the video title, ID, uploader, duration, view count, thumbnail, and a direct stream URL for each video you submit. Whether you're building a media catalog, checking video details in bulk, or feeding links into a media workflow you are authorized to use, the YouTube Video Metadata & Direct Stream Extractor delivers structured results efficiently.

With flexible link input, automatic cleanup of playlist parameters, three fallback extraction profiles, parallel processing, optional proxy fallback, and reliable Apify Dataset delivery, this **YouTube Video Metadata** actor returns one record for every link, including a clear failure record when a video cannot be read. It uses the open-source \` library and never downloads or stores the video itself.

> ℹ️ **About direct stream links:** The `direct_link` value is a temporary link to a stream hosted on YouTube's servers. It usually expires after some hours, and it may only work from the IP address that requested it. Use it only for content you own, have permission to use, or are licensed to use. See [Important Notes](#-important-notes).

***

### 📋 Table of Contents

- [Features](#-features)
- [Data Source](#-data-source)
- [How It Works](#-how-it-works)
- [Input](#-input)
- [Output](#-output)
- [Technical Stack](#-technical-stack)
- [Data Fields](#-data-fields-explained)
- [Use Cases](#-use-cases)
- [Quick Start](#-quick-start)
- [Configuration](#-configuration)
- [Performance](#-performance)
- [Important Notes](#-important-notes)
- [License & Legal](#-license--legal)

***

### 🔥 Features

- **Video Metadata** – Title, video ID, uploader, duration, view count, and thumbnail. This is the core of the **YouTube Video Metadata** extractor.
- **Direct Stream Link** – A temporary link to a media stream, with a preference for a stream that has both video and audio.
- **Multiple Videos per Run** – Process a list of links, 5 at a time.
- **Link Cleanup** – Converts `watch`, `youtu.be`, Shorts, embed, and live links into a clean single-video link and removes playlist and mix parameters.
- **Three Extraction Profiles** – If one YouTube client profile fails, the Actor tries two others before giving up.
- **Direct-First Proxy Fallback** – Tries a direct connection first, then retries through Apify Proxy if you configured one.
- **Failure Records** – A failed link produces a record with `status: "failed"` and the error message.
- **Duplicate Removal** – Identical links in your input are processed once.
- **No Downloads** – The Actor never downloads or stores the video or audio files.
- **Status Summary** – Sets a final run status message such as "Successfully extracted 5/6 video link(s)".
- **Detailed Logging** – Logs progress for every **YouTube Video Metadata** run.

***

### 📊 Data Source

#### **YouTube (via )**

- **Source**: Public YouTube video pages
- **Access Method**: The open-source ` library in metadata-only mode (`skip_download\`), without logging in
- **Coverage**: Public YouTube videos that \`\` can read from your run's IP address
- **Data**: Video details and stream information exposed by YouTube
- **Access**: No login or API key used
- **Update Frequency**: Reflects YouTube at time of run

This Actor is not affiliated with or endorsed by YouTube or Google.

***

### ⚙️ How It Works

For each video link, the Actor cleans the link, asks \` for the video's details, and picks a stream link from the available formats. If the first attempt fails, it tries other YouTube client profiles and, if configured, a proxy. Each link produces one record, saved to the Apify Dataset right away.

**Key Processing Steps:**

1. **Input Parsing** – Read the list of links (or use the built-in test video if none are given)
2. **Deduplication** – Remove repeated links
3. **Link Cleanup** – Turn video links into `https://www.youtube.com/watch?v=<id>`
4. **Extraction** – Try three client profiles in turn (`android`/`web`, `ios`/`mweb`, `tv_embedded`/`web`)
5. **Stream Selection** – Use the stream link YouTube returns, or the best format with both video and audio, or any format with a link
6. **Proxy Fallback** – If the direct attempt fails and a proxy is configured, retry through the proxy
7. **Record Saving** – Save a success record or a failure record for each link
8. **Status Message** – Report how many links succeeded

***

### 📥 Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `urls` | array or string | built-in test video | YouTube video links. Items can be text or objects with a `url` field. A string may be separated by commas or new lines. `startUrls` and `url` are also accepted as the field name. |
| `proxyConfiguration` | object | *(none: direct connection)* | Apify Proxy configuration, used as a fallback after a failed direct attempt. |
| `useApifyProxy` | boolean | `false` | Alternative way to enable Apify Proxy when `proxyConfiguration` is not given. |
| `apifyProxyGroups` | array | `["RESIDENTIAL"]` | Proxy groups used together with `useApifyProxy`. |

If no link is provided, the Actor processes a built-in test video (`https://www.youtube.com/watch?v=jNQXAC9IVRw`).

**Example Input:**

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw",
    "https://youtu.be/dQw4w9WgXcQ"
  ]
}
```

**With Proxy Fallback:**

```json
{
  "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

***

### 📤 Output

#### **Success record**

| Field | Type | Description |
|-------|------|-------------|
| `url` | string | The cleaned video link |
| `original_url` | string | The link exactly as you entered it |
| `id` | string | YouTube video ID |
| `title` | string | Video title, or `"Untitled Video"` if none is available |
| `direct_link` | string | Temporary direct stream link (can be empty) |
| `thumbnail` | string | Thumbnail image URL (can be empty) |
| `uploader` | string | Uploader or channel name, or `"Unknown"` if not available |
| `duration` | integer | Duration in seconds, or `0` if not available |
| `view_count` | integer | View count, or `0` if not available |
| `status` | string | `"success"` |
| `scraped_at` | string | ISO 8601 UTC timestamp |

#### **Failure record**

| Field | Type | Description |
|-------|------|-------------|
| `url` | string | The link as entered |
| `status` | string | `"failed"` |
| `error` | string | First line of the error message |
| `scraped_at` | string | ISO 8601 UTC timestamp |

**Example Success Record:**

```json
{
  "url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "original_url": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "id": "jNQXAC9IVRw",
  "title": "Example video title",
  "direct_link": "https://rr1---sn-example.googlevideo.com/videoplayback?...",
  "thumbnail": "https://i.ytimg.com/vi/jNQXAC9IVRw/maxresdefault.jpg",
  "uploader": "Example Channel",
  "duration": 19,
  "view_count": 300000000,
  "status": "success",
  "scraped_at": "2026-10-30T09:00:00Z"
}
```

***

### 🧰 Technical Stack

- **Extraction:**  in metadata-only mode with three client profiles and a 12-second socket timeout
- **Concurrency:** `asyncio` with a limit of 5 links at a time, and blocking extraction run in worker threads
- **Proxy:** Apify Proxy as an optional fallback after a direct attempt
- **Logging:** Apify Actor logging system
- **Platform:** Apify Actor serverless environment

***

### 📊 Data Fields Explained

- **url / original_url / id**: Which video the record belongs to
- **title / uploader / thumbnail**: Descriptive details
- **duration / view_count**: Length and popularity as reported by YouTube
- **direct_link**: A temporary stream link (see notes)
- **status / error**: Whether extraction worked, and why not if it failed

***

### 🎯 Use Cases

- **Media Catalogs** – Collect titles, durations, and thumbnails for a list of videos
- **Bulk Video Checks** – Check whether video links are still available and see their basic details
- **Authorized Media Workflows** – Pass stream links to your own tools for content you own or are licensed to use
- **Link Enrichment** – Turn a list of video links into structured data

***

### 🚀 Quick Start

#### **1. Prepare Input**

Go to Apify Console and enter:

```json
{
  "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"]
}
```

#### **2. Run the Actor**

Click **Start**. The Actor will:

- Clean each link
- Extract the video details and a stream link
- Save one record per link, including failures

#### **3. Monitor Progress**

Console shows:

```
🌐 Running with direct connection.
🎬 Processing 1 video URL(s)...
🔎 Extracting stream: https://www.youtube.com/watch?v=jNQXAC9IVRw
✅ Video #1 saved: Example video title
🎉 Complete! Successfully extracted 1/1 video link(s).
```

#### **4. View & Download Results**

- **Results Tab**: One record per link
- **Export**: JSON, CSV, Excel, or HTML
- **API Access**: Available via the Apify API

***

### ⚙️ Configuration

Several videos:

```json
{
  "urls": "https://youtu.be/dQw4w9WgXcQ, https://www.youtube.com/shorts/abc123XYZ_-"
}
```

Using the legacy proxy fields:

```json
{
  "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"],
  "useApifyProxy": true,
  "apifyProxyGroups": ["RESIDENTIAL"]
}
```

***

### 📈 Performance

#### **Processing Speed**

- Up to 5 links are processed at the same time
- Each attempt times out after about 12 seconds, and a link can take up to three profile attempts, plus a proxy retry if configured
- Cleaned single-video links are much faster than playlist links

#### **Resource Usage**

- Memory: Low, since no browser is launched and nothing is downloaded
- Network: Lightweight metadata requests
- Proxy: Optional Apify Proxy, used only after a failed direct attempt

***

### ⚠️ Important Notes

#### **About Direct Stream Links**

- **Temporary**: `direct_link` is a signed link that usually expires after some hours. Do not store it as a permanent address.
- **May Be IP-Bound**: The link may only work from the IP address that requested it. If you used a proxy, it may not work from your own machine.
- **Which Stream You Get**: The Actor prefers a stream with both video and audio. If none exists, it falls back to any stream with a link, which can be video-only or audio-only. It can also be empty if no stream link was returned.
- **No Downloading**: The Actor only returns links. It does not download, store, or convert any media.

#### **Legal & Compliance**

- **YouTube Terms**: YouTube's Terms of Service restrict downloading and accessing content except through features YouTube provides, and restrict automated access. Review them before use.
- **Copyright**: Videos are protected by copyright. Use stream links only for content you own, have permission to use, or that is licensed to allow it. Do not use them to copy or redistribute others' content without permission.
- **Affiliation**: Not affiliated with or endorsed by YouTube or Google
- **Legal**: Not legal advice

#### **Data Quality**

- **Default Values**: If YouTube does not return a field, the Actor fills in `"Untitled Video"`, `"Unknown"`, or `0` (for duration and view count). A value of `0` can mean "not available", for example for live streams.
- **Playlist and Channel Links**: Only single-video links are cleaned and supported. A playlist link is limited to its first item, and other link types may fail.
- **Failures**: Private, age-restricted, region-blocked, and removed videos usually fail, as do links blocked by YouTube. YouTube may also rate-limit or block data-center IPs, and proxy fallback is only used if you configured one.
- **Library Changes**: \` depends on YouTube's internals, which change often. Results can vary between runs and versions.
- **Freshness**: View counts and details reflect YouTube at the time of the run.

#### **Best Practices**

- Use clean single-video links
- Configure a residential proxy fallback for larger batches
- Fetch and use `direct_link` quickly, since it expires
- Check `status` and `error` before using a record

***

### 📄 License & Legal

**Terms of Use:**

- Use only for content you own or are authorized to use
- Respect YouTube's Terms of Service and creators' rights
- Do not use for unlawful copying or redistribution of copyrighted content
- Use data responsibly and in compliance with applicable laws

**Disclaimer:**
YouTube Video Metadata & Direct Stream Extractor is provided as-is for lawful, authorized purposes. It is not affiliated with or endorsed by YouTube or Google. Users are responsible for compliance with all applicable laws, copyright rules, and the terms of the data source. This is not legal advice.

# Actor input Schema

## `urls` (type: `array`):

List of public YouTube video URLs to extract metadata and stream links from.

## `proxyConfiguration` (type: `object`):

Apify Proxy fallback settings if direct connection is rate-limited.

## Actor input object example

```json
{
  "urls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `crawlResults` (type: `string`):

No description

## `overview` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://www.youtube.com/watch?v=jNQXAC9IVRw"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datapilot/youtube-video-metadata-direct-stream-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://www.youtube.com/watch?v=jNQXAC9IVRw"] }

# Run the Actor and wait for it to finish
run = client.actor("datapilot/youtube-video-metadata-direct-stream-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.youtube.com/watch?v=jNQXAC9IVRw"
  ]
}' |
apify call datapilot/youtube-video-metadata-direct-stream-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datapilot/youtube-video-metadata-direct-stream-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qP4GiJUJZfTJULgQI/builds/sWDUhpD8S8HGr963H/openapi.json
