npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kyometori/yt-downloader

v1.0.4

Published

一個簡單的 Youtube 下載函式庫

Downloads

3

Readme

Youtube Downloader

npm version Downloads Last Commit Code Size License

一個簡單的 Youtube 影音下載小工具。

Warning

This package can't run expectedly on Windows and I don't know why. If you can find the bug please help me.

使用前

在你使用之前,你必須自行安裝以下套件:

然後安裝此套件

npm i --save @kyometori/yt-downloader

開始使用

首先,先引入此套件

/* CommonJS */
const { videoDownload, videosDownload, playlistDownload } = require('@kyometori/yt-downloader');

/* ModuleJS */
import { videoDownload, videosDownload, playlistDownload } from '@kyometori/yt-downloader'

下載單一影片

videoDownload({ ...options });

其中 options 包括以下內容:

  • url:目標影片連結
  • filename:會出影片的檔名,預設為影片標題。
  • folder:檔案匯出的資料夾,預設為 result。使用相對路徑時,他為「相對於程式執行時的路徑」。
  • audioonly:是否只下載音檔,預設為 true

回傳值:Promise<ChildProcess>
範例:

videoDownload({
  url: 'https://www.youtube.com/watch?v=qX1xe1RzA94',
  filename: 'audio',
  folder: '../music',
  audioonly: true
})

批量下載影片

videosDownload({ ...options });

其中 options 包括以下內容:

  • urls:一個陣列,裡面是所有要被下載的影片連結。
  • filename:會出影片的檔名,預設為影片標題。
  • folder:檔案匯出的資料夾,預設為 result。使用相對路徑時,他為「相對於程式執行時的路徑」。
  • audioonly:是否只下載音檔,預設為 true

回傳值:Promise<ChildProcess>[]
範例:

videosDownload({
  urls: [
    'https://www.youtube.com/watch?v=35FxbLTlGNI',
    'https://www.youtube.com/watch?v=OTRcHcyolUM',
    'https://www.youtube.com/watch?v=OvLE3VQ18UY',
    'https://www.youtube.com/watch?v=807atqeFsVA',
    'https://www.youtube.com/watch?v=TZC02UdbStM',
    'https://www.youtube.com/watch?v=qQEbHEjne9M'
  ],
  filename: '<title>',
  folder: '../music',
  audioonly: true
})

下載播放清單

playlistDownload({...options});

其中 options 包括以下內容:

  • url:目標播放清單連結
  • filename:會出影片的檔名,預設為影片標題。
  • folder:檔案匯出的資料夾,預設為 result。使用相對路徑時,他為「相對於程式執行時的路徑」。
  • audioonly:是否只下載音檔,預設為 true

回傳值:Promise<Promise<ChildProcess>[]>
範例:

playlistDownload({
    url: 'https://www.youtube.com/playlist?list=PLFPTffQioGfYFs7Az7h0PusfVyCPI6iVe',
    folder: 'exports',
    audioonly: false
});

檔名 Markdown

在影片檔案的 filename 選項可以填入檔名,其中以下幾個特殊字眼會被解譯成特殊的字符,讓你可以更彈性的指定標題,包含以下:

  • <title>:影片的原標題
  • <year>:當前時間西元年
  • <month>:當前時間月
  • <date>:當前時間日
  • <index>:當前影片順位

其中 <index> 在一般的影片都是 1 號,只有在使用 playlistDownloadvideosDownload 時才會依據那個影片被下載的順序來填入。

範例程式:

playlistDownload({
    url: 'https://www.youtube.com/playlist?list=PLGejWpTS0U0Ix0pa3UZJE4LMWGm7IHcqs',
    folder: 'goodmusics',
    filename: '<year>-<month>-<date>_<index>'
})

範例輸出(檔名):

2021-8-5_1.mp4
2021-8-5_2.mp4
2021-8-5_3.mp4
...