Skip to content

shadlc/ytdlp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

YT-DLP Server is an server side for yt-dlp that can allow you run it in your server.

Notice

  • Server side is English but the webpage is in all chinese, you can translate it.
  • No download speed or duration for display.

Features

  • Depend on Flask.
  • Easy use API, RESTful-API style respond.
  • Multi-threaded download task.
  • User-friendly interactive and interface.
  • Server with single python file, webpage with single HTML file, easy for learning.

Use

Install Aria2

You need to install aria2 first because this script depends on aria2 for more quickly download speed.

Init Envirment

$ python -m venv ytdlp-server
$ cd ytdlp-server
  • For Windows $ .\Scripts\Activate.ps1
  • For other platform $ source bin/activate

Clone

$ git clone https://github.com/shadlc/ytdlp-server.git
$ cd ytdlp-server

Install Requirements

$ pip install -r requirements.txt

Run

$ python3 ytdlp-server.py

Usage Notes

When started this script, you can download videos to server via yt-dlp. You can modify the configuration file "config.json".

Web Page

Displaying example that translated webpage on Google

API

/download

Directly download the video via yt-dlp.

params

  • url: The url that input for yt-dlp.

example

  • request

    GET http://127.0.0.1:8848/download?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ

    POST http://127.0.0.1:8848/download

  • post params

    url: The url that input for yt-dlp.

    cookie: Base64 encode Netscape format cookie file.

    format: The video format selector for yt-dlp.

  • response
{
  "code": 200,
  "status": "Added",
  "data": {
    "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "cookie": "youtube",
    "format": "bv*+ba/b",
    "type": "video",
    "uploader": "Rick Astley",
    "site": "youtube",
    "thumbnail": "https://i.ytimg.com/vi_webp/dQw4w9WgXcQ/maxresdefault.webp",
    "id": "dQw4w9WgXcQ",
    "duration": 212,
    "resolution": "1920x1080",
    "ext": "webm",
    "size": 3437753
  }
}

/info

Get video information via yt-dlp.

params

  • url: The url that input for yt-dlp.
  • mode: Default is "brief" and optional in "brief" or "raw".

example

  • request

    GET http://127.0.0.1:8848/info?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ

    POST http://127.0.0.1:8848/info

  • post params

    url: The url that input for yt-dlp.

    mode: Default is "brief" and optional in "brief" or "raw".

    cookie: Base64 encode Netscape format cookies file.

    format: The video format selector for yt-dlp.

  • response
{
  "code": 200,
  "status": "Success",
  "data": {
    "title": "Rick Astley - Never Gonna Give You Up (Official Music Video)",
    "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "cookie": "youtube",
    "format": "bv*+ba/b",
    "type": "video",
    "uploader": "Rick Astley",
    "site": "youtube",
    "thumbnail": "https://i.ytimg.com/vi_webp/dQw4w9WgXcQ/maxresdefault.webp",
    "id": "dQw4w9WgXcQ",
    "duration": 212,
    "resolution": "1920x1080",
    "ext": "webm",
    "size": 3437753
  }
}

/status

Get the status about download task.

params

  • None

example

  • request

GET http://127.0.0.1:8848/status

  • response
{
  "code": 200,
  "status": "Init",
  "data": {
    "tasks": []
  }
}

/history

Get the history you downloaded.

params

  • None

example

  • request

GET http://127.0.0.1:8848/history

  • response
{
  "code": 400,
  "status": "No history yet",
  "data": ""
}

/clear_download

Clear the downloading list.

params

  • None

example

  • request

GET http://127.0.0.1:8848/clear_download

  • response
{
  "code": 400,
  "status": "Cleared",
  "data": ""
}

/clear_history

Clear the download history.

params

  • None

example

  • request

GET http://127.0.0.1:8848/clear_history

  • response
{
  "code": 400,
  "status": "Cleared",
  "data": ""
}

License

License