Package: yt-search
yt-searchEnglishInstallPython 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-searchExampleSearch videoimportyt_searchyt=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 channelimportyt_searchyt=yt_search.build("API Key")search_result=yt.search("keyword",sMax=10,sType=["channel"])print(search_result.channelTitle)print(search_result.channelId)Search playlistimportyt_searchyt=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 listimportyt_searchyt=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 wavNeed youtube-dl and ffmpeg.importyt_searchimportyoutube_dlyt=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'}]}withyoutube_dl.YoutubeDL(options)asydl:ydl.download(["https://www.youtube.com/watch?v="+iforiinsearch_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プログラムの例動画を検索importyt_searchyt=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チャンネルを検索importyt_searchyt=yt_search.build("APIキー")search_result=yt.search("キーワード",sMax=10,sType=["channel"])print(search_result.channelTitle)print(search_result.channelId)プレイリストを検索importyt_searchyt=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はリストで複数選択可能です。例：importyt_searchyt=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が必要です。importyt_searchimportyoutube_dlyt=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'}]}withyoutube_dl.YoutubeDL(options)asydl:ydl.download(["https://www.youtube.com/watch?v="+iforiinsearch_result.videoId])youtube#videoの場合はplaylistIdが、
youtube#playlistの場合はvideoIdが、
youtube#channelの場合はplaylistIdとvideoIdがNoneを返します。
Noneを返さない場合もあります（値があるとき）