Skip to main content

yt-search

English

Install

Python 3.6.x or higher is required.

Install command:

# Linux/OS X
$ python -m pip install -U yt-search

# Windows
> py -3 -m pip install -U yt-search

Example

Search video

import yt_search

yt = yt_search.build("API Key")
search_result = yt.search("keyword", sMax=10, sType=["video"])
print(search_result.title)
print(search_result.videoId)
print(search_result.channelTitle)

Search YouTube channel

import yt_search

yt = yt_search.build("API Key")
search_result = yt.search("keyword", sMax=10, sType=["channel"])
print(search_result.channelTitle)
print(search_result.channelId)

Search playlist

import yt_search

yt = yt_search.build("API Key")
search_result = yt.search("keyword", sMax=10, sType=["playlist"])
print(search_result.title)
print(search_result.playlistId)
print(search_result.channelTitle)

sType can be select multiple by list

import yt_search

yt = yt_search.build("API Key")
search_result = yt.search("keyword", sMax=10, sType=["video", "playlist"])
print(search_result.title)
print(search_result.videoId)
print(search_result.playlistId)
print(search_result.channelTitle)

Download search results with wav

Need youtube-dl and ffmpeg.

import yt_search
import youtube_dl

yt = yt_search.build("API Key")
search_result = yt.search("keyword", sMax=10, sType=["video"])

options = {
    'format': 'bestaudio/bestaudio',
    'outtmpl': '%(title)s.%(ext)s',
    'postprocessors': [
        {
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'wav'
        },
        {
            'key': 'FFmpegMetadata'
        }
    ]
}
with youtube_dl.YoutubeDL(options) as ydl:
    ydl.download(["https://www.youtube.com/watch?v=" + i
                  for i in search_result.videoId])

In the case of youtube#video, playlistId returns None. In the case of youtube#playlist, videoId returns None. In the case of youtube#channel, playlistId and videoId returns None.

日本語

インストール

Python3.6.x以上が必要です。

インストールコマンド:

# Linux/OS X
$ python -m pip install -U yt-search

# Windows
> py -3 -m pip install -U yt-search

プログラムの例

動画を検索

import yt_search

yt = yt_search.build("APIキー")
search_result = yt.search("キーワード", sMax=10, sType=["video"])
print(search_result.title)
print(search_result.videoId)
print(search_result.channelTitle)

YouTubeチャンネルを検索

import yt_search

yt = yt_search.build("APIキー")
search_result = yt.search("キーワード", sMax=10, sType=["channel"])
print(search_result.channelTitle)
print(search_result.channelId)

プレイリストを検索

import yt_search

yt = yt_search.build("APIキー")
search_result = yt.search("キーワード", sMax=10, sType=["playlist"])
print(search_result.title)
print(search_result.playlistId)
print(search_result.channelTitle)

sTypeはリストで複数選択可能です。例:

import yt_search

yt = yt_search.build("APIキー")
search_result = yt.search("キーワード", sMax=10, sType=["video", "playlist"])
print(search_result.title)
print(search_result.videoId)
print(search_result.playlistId)
print(search_result.channelTitle)

検索結果をwavでダウンロード

youtube-dlとffmpegが必要です。

import yt_search
import youtube_dl

yt = yt_search.build("APIキー")
search_result = yt.search("キーワード", sMax=10, sType=["video"])

options = {
    'format': 'bestaudio/bestaudio',
    'outtmpl': '%(title)s.%(ext)s',
    'postprocessors': [
        {
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'wav'
        },
        {
            'key': 'FFmpegMetadata'
        }
    ]
}
with youtube_dl.YoutubeDL(options) as ydl:
    ydl.download(["https://www.youtube.com/watch?v=" + i
                  for i in search_result.videoId])

youtube#videoの場合はplaylistIdが、 youtube#playlistの場合はvideoIdが、 youtube#channelの場合はplaylistIdとvideoIdがNoneを返します。 Noneを返さない場合もあります(値があるとき)

Release files for yt-search 1.1.0.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yt-search 1.1.0.post1
File Size Uploaded
yt_search-1.1.0.post1.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yt-search 1.1.0.post1
File Interpreter ABI Platform
yt_search-1.1.0.post1-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / yt_search-1.1.0.post1.tar.gz

Download URL yt_search-1.1.0.post1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
41e269adbd51eae6e8b8ba9b3c082161d0a294db8f38a85f61dc940ccbbe44aa
BLAKE2b-256 checksum
How to use checksums
8e3885bddf720fbd87eff4639fbb9b4c7b9b3190604f2db3e93446f26dfbea26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.0

Release files / yt_search-1.1.0.post1-py3-none-any.whl

Download URL yt_search-1.1.0.post1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f721d46fb33cebff1b47cab54c6c04578429fe69b9e64935d81eeaa8320da5f7
BLAKE2b-256 checksum
How to use checksums
7297cc5dbe3d1847c9e1cc0024be60aabed76c65401b546e41c8899a228fc574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.12.4 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.0

Release history Release notifications | RSS feed

This release

1.1.0.post1 This release

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page