# 🚀 YouTube Playlist Scraper🎥 (`scrapearchitect/youtube-playlist-scraper`) Actor

🎥 Extract video titles, channels, stats, thumbnails, and metadata from YouTube playlists in 🚀 2-5 mins! Perfect for research, archiving, or content analysis. Fast, reliable, and proxy-ready. 📊 🚀 YouTube Playlist Scraper🎥

- **URL**: https://apify.com/scrapearchitect/youtube-playlist-scraper.md
- **Developed by:** [Scrape Architect](https://apify.com/scrapearchitect) (community)
- **Categories:** Videos, Developer tools, Automation
- **Stats:** 56 total users, 1 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period. You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

***

## 🚀 YouTube Playlist Scraper – Surgical Video Extraction + Metadata Control 🎯📊

### 📜 Overview

Need **precision control** over YouTube playlist scraping? Now with **surgical video selection** and **metadata toggles**!

The enhanced **YouTube Playlist Scraper** lets you:\
✅ **Target specific videos** by position (e.g., 2nd & 5th videos)\
✅ **Toggle metadata**: Include/exclude views, likes, tags & descriptions\
✅ **Combine limits**: Set max videos + specific indexes in one run

Perfect for:

- Targeted content analysis 🎯
- Lightweight API feeds 📲
- Archiving key playlist positions 📌

> 🆕 **Feature Spotlight**:
>
> - `videoNumbers="2,5"` → Scrape 2nd & 5th videos per playlist
> - `includeAdditionalInfo=false` → 20% smaller payloads

***

### 🔥 Enhanced Features

#### 🎯 Precision Controls

- **Video Position Selection**: "1,3,5" for 1st/3rd/5th videos
- **Metadata Toggle**: Remove stats/tags with one switch
- **Hybrid Filtering**: Combine `maxVideosPerPlaylist=20` + `videoNumbers="2,5"`

#### ⚡ Performance Boosters

- 40% faster scraping when metadata disabled
- Index-based skipping avoids full playlist scans

#### 📦 Structured Output Options

| Mode | Includes | Ideal For |\
|------|----------|-----------|\
| **Full Metadata** (default) | Views, likes, tags, descriptions | SEO analysis 📈 |\
| **Lightweight** | Titles, URLs, thumbnails only | Mobile apps 📱 |

***

### 🛠️ Input Configuration

```json
{
  "includeAdditionalInfo": true,
  "maxVideosPerPlaylist": 20,
  "playlist_urls": [
    {
      "url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK",
      "method": "GET"
    },
    {
      "url": "https://www.youtube.com/playlist?list=PLe6YKWr4VVM1x2LIpiqmVvG4QgIvoDEdO",
      "method": "GET"
    }
  ],
  "videoNumbers": "2,5"
}
```

#### 📋 New Field Explanations

| Parameter | Type | Format | Behavior |\
|-----------|------|--------|----------|\
| `videoNumbers` | String | "1,3" | Targets specific video positions (1-based index) |\
| `includeAdditionalInfo` | Boolean | true/false | Toggles view counts/tags/descriptions |\
| `maxVideosPerPlaylist` | Number | 0=unlimited | Max videos scanned before applying `videoNumbers` filter |

##### 💡 Parameter Interactions:

1. `videoNumbers` overrides `maxVideosPerPlaylist` when both exist
   - Example: `maxVideos=20` + `videoNumbers="2,5"` → Scans first 20 videos, then picks 2nd & 5th
2. Blank `videoNumbers` uses `maxVideosPerPlaylist` limit

***

### 📤 Output Examples

#### Full Metadata Mode (`includeAdditionalInfo=true`)

```json
{
  "playlist_url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK",
  "video_title": "Islamic background music no copyright",
  "channel_name": "Islamic Music",
  "video_url": "https://www.youtube.com/watch?v=u9i6OaCjhlw",
  "duration": "2m 28s",
  "thumbnail": "https://i.ytimg.com/vi_webp/u9i6OaCjhlw/maxresdefault.webp",
  "additional_info": {
    "view_count": 3576151,
    "like_count": 55209,
    "tags": ["islamic music", "no copyright"],
    "description": "⚠️ You’re free to use this song..."
  }
}
```

#### Lightweight Mode (`includeAdditionalInfo=false`)

```json
{
  "playlist_url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK",
  "video_title": "Islamic background music no copyright",
  "video_url": "https://www.youtube.com/watch?v=u9i6OaCjhlw",
  "thumbnail": "https://i.ytimg.com/vi_webp/u9i6OaCjhlw/maxresdefault.webp"
}
```

***

### 🏆 Why Choose This Scraper?

| Feature | 🚀 This Scraper | Basic Tools |\
|---------|-----------------|-------------|\
| Video Selection | Position targeting + bulk limits | Bulk-only |\
| Data Control | Metadata toggle | All-or-nothing |\
| Speed | 2-3 mins for 20 videos | 5-8 mins |\
| Error Handling | Skips missing indexes | Fails entire job |

***

### 🧑💻 Enhanced Use Cases

🎯 **Position Analysis**

- Compare engagement of 1st vs 5th videos in playlists

📲 **API Optimization**

- Lightweight mode reduces payload size for mobile apps

🔬 **Academic Research**

- Study content placement strategies in playlists

📊 **Trend Spotting**

- Track if specific positions (e.g., video #3) consistently perform best

***

### ⚙️ How It Works Now

1. **Input Processing**
   - Converts `videoNumbers="2,5"` → `[2,5]` indexes
   - Applies `maxVideosPerPlaylist` limit

2. **Playlist Scanning**
   - Fetches videos up to `maxVideosPerPlaylist`
   - Filters to specified indexes

3. **Output Generation**
   - Includes/excludes metadata per `includeAdditionalInfo`
   - Returns Apify-encrypted dataset

***

### ❓ Troubleshooting New Features

**Issue**: "Video position 5 not found"\
**Fix**:

- Ensure playlist has ≥5 videos
- Increase `maxVideosPerPlaylist` beyond 5

**Issue**: "Additional info missing when enabled"\
**Fix**:

- YouTube sometimes hides metrics - retry with proxies
- Check `includeAdditionalInfo=true` in input

**Issue**: "Only 1 video returned from 20-video playlist"\
**Fix**:

- Verify `videoNumbers` indexes exist in first `maxVideosPerPlaylist` videos

***

# Actor input Schema

## `playlist_urls` (type: `array`):

An array of playlist URLs from YouTube. Each URL can be a string or an object with a 'url' key.

## `includeAdditionalInfo` (type: `boolean`):

Whether to scrape additional info like duration, view count, etc.

## `videoNumbers` (type: `string`):

Enter the video numbers (1-based index) to scrape from each playlist as a comma-separated list. E.g., 1,3,7. Leave empty to scrape all videos.

## `maxVideosPerPlaylist` (type: `integer`):

Maximum of 1000 videos ✔ per playlist (set to 0 to retrieve all)

## Actor input object example

```json
{
  "playlist_urls": [
    {
      "url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK&si=BBK3LDszV-myqaMS"
    },
    {
      "url": "https://www.youtube.com/playlist?list=PLe6YKWr4VVM1x2LIpiqmVvG4QgIvoDEdO"
    }
  ],
  "includeAdditionalInfo": true,
  "videoNumbers": "",
  "maxVideosPerPlaylist": 10
}
```

# 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 = {
    "playlist_urls": [
        {
            "url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK&si=BBK3LDszV-myqaMS"
        },
        {
            "url": "https://www.youtube.com/playlist?list=PLe6YKWr4VVM1x2LIpiqmVvG4QgIvoDEdO"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapearchitect/youtube-playlist-scraper").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 = { "playlist_urls": [
        { "url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK&si=BBK3LDszV-myqaMS" },
        { "url": "https://www.youtube.com/playlist?list=PLe6YKWr4VVM1x2LIpiqmVvG4QgIvoDEdO" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("scrapearchitect/youtube-playlist-scraper").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 '{
  "playlist_urls": [
    {
      "url": "https://youtube.com/playlist?list=PLKqX9tEhgjeaqBzvPfRT4WZ_lLPc4gNfK&si=BBK3LDszV-myqaMS"
    },
    {
      "url": "https://www.youtube.com/playlist?list=PLe6YKWr4VVM1x2LIpiqmVvG4QgIvoDEdO"
    }
  ]
}' |
apify call scrapearchitect/youtube-playlist-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapearchitect/youtube-playlist-scraper"
        }
    }
}

```

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/KKafJz86nUXhImvgZ/builds/CgqefoYpGBI5AMzkw/openapi.json
