play-dl-fix/README.md
aritrakarak 31b53d3cd6 README.md updated
Removed readme from YouTube folder and combined with base one along with improvements.
2021-08-24 11:27:29 +05:30

3.5 KiB

Why play-dl ?

ytdl-core has some issues with miniget and also stream abort issues. On the other hand, youtube-dl is a very perfect alternative but it takes time to launch. Hence, play-dl is created to avoid these issues along with providing comparatively faster performance than others.

Download videos/playlists or search for videos

This is a light-weight youtube downloader and searcher.

  • searches by video, playlist, channel
  • obtains audio playback url

Installation

npm install play-dl@latest

Examples

For pre-made examples, head over to /examples folder.

Basic Usage

const youtube = require('play-dl');
// ES6: import youtube from 'play-dl';
const options = {
    limit : 1
}
const results = await youtube.search('post malone sunflower', options);

Search

search(url : string, options? : SearchOptions)

This enables all searching mechanism (video, channel, playlist)

const options = {
    limit : 1
}
const results = await youtube.search('never gonna give you up', options);
console.log(results[0].url);
  • SearchOptions

    • type : video | channel | playlist
    • limit : integer

Video

video_basic_info(url : string)

The basic video details play-dl fetches at first.

const video = await video_basic_info(url)

video_info(url : string)

This contains everything with deciphered formats along with video_details.

const video = await video_info(url)
  • format property

    This returns all the formats available for a video.

    const video = await video_info(url)
    console.log(video.format)
    

Playlist

playlist_info(url : string)

This fetches all details about a playlist.

const playlist = await playlist_info(url)
//This only fetches first 100 videos from a playlist
  • fetch() method

    This fetches and returns all videos from the whole provided playlist .

    const playlist = await playlist_info(url)
    //This only fetches first 100 videos from a playlist
    
    await playlist.fetch()
    // This one fetches all videos from a playlist.
    
  • page(page_number : number)

    This returns no. of videos from a page.

    Every 100 videos have been divided into pages. Example: There are 782 videos in a playlist, so there will be 8 pages.

    const playlist = await playlist_info(url);
    // This only fetches first 100 videos from a playlist.
    
    await playlist.fetch();
    // This one fetches all videos from a playlist.
    
    console.log(playlist.page(1));
    // This displays first 100 videos of a playlist
    
    
  • total_videos property

    This returns total no. of videos that have been fetched so far.

    const playlist = await playlist_info(url)
    //This only fetches first 100 videos from a playlist.
    
    await playlist.fetch()
    // This one fetches all videos from a playlist.
    
    console.log(playlist.total_videos)
    // This displays total no. of videos fetched so far.
    
  • videoCount property

    This returns total no. of videos in the provided playlist.

    const playlist = await playlist_info(url)
    //This only fetches first 100 videos from a playlist.
    
    await playlist.fetch()
    // This one fetches all videos from a playlist.
    
    console.log(playlist.videoCount)
    // This displays total no. of videos in a playlist.