Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8882

YoutubeをAPI Key不要で検索するnode-ytsrの説明文を翻訳した

$
0
0
プロトアウトスタジオの卒業制作では「Youtube動画内テキスト検索」(別名:気づいたらYoutube観て1日が終わってた撲滅システム)」を作ろうとしています。 同じ課題感を持っている方には使っていただけるようにしますので、応援いただけますと幸いです。 なにはなくともYoutubeに検索単語を入れて、URLを返してもらうのは必要なのでGitHubでそれを調べました。 今回はログインやGoogle-API-Keyを必要としないnode-ytsrを読み解いていきます。 node-ytsr ダウンロード数は27万回。 更新状況も良さそう。(4月26日更新 v3.5.0) discordのサポートチャンネルもあり、信用できそうです。 では、読んでいきます。 DL翻訳を使ったあとに英文も読んではいますが、英語は勉強中なので信用しきらないようにお願いします。m(__)m Simple js only package to search for Youtube for Videos, Playlists and many more. Does not require any login or Google-API-Key. Youtubeの動画やプレイリストなどを検索するシンプルなjsのみのパッケージです。ログインやGoogle-API-Keyを必要としません。 const ytsr = require('ytsr'); const searchResults = await ytsr('github'); dosth(searchResults); ytsr(searchString, [options]) Searches for the given string 与えられた文字列を検索する searchString 検索文字列 search string or url (from getFilters) to search from 検索文字列、または検索対象となるURL(getFiltersから)。 options オプション object with options オプションを持つオブジェクト possible settings: 可能な設定 gl[String] -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request gl[String] -> 国の2桁のコード、デフォルトはUS - リクエストのローカライズを可能にします。 hl[String] -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request hl[String] -> 言語を表す2桁のコード、デフォルトはen - リクエストのローカライズを可能にします。 safeSearch[Boolean] -> pull items in youtube restriction mode. safeSearch[Boolean] -> youtube制限モードでアイテムを引き出します。 limit[integer] -> limits the pulled items, defaults to 100, set to Infinity to get the whole list of search results - numbers <1 result in the default being used limit[integer] -> 引っ張るアイテムを制限します。デフォルトは100で、Infinityに設定すると検索結果の全リストを取得します - 数値が1未満の場合はデフォルトが使用されます。 pages[Number] -> limits the pulled pages, pages contain 20-30 items, set to Infinity to get the whole list of search results - numbers <1 result in the default limit being used - overwrites limit pages[Number] -> 抽出されるページを制限します。ページには20~30のアイテムが含まれ、Infinityに設定すると検索結果の全リストが表示されます。 requestOptions[Object] -> Additional parameters to passed to miniget, which is used to do the https requests requestOptions[Object] -> httpsリクエストを行うために使用されるminigetに渡される追加のパラメータです。 returns a Promise  Promiseを返します。 Example response 応答の例 ytsr.getFilters(searchString, options) Pulls avaible filters for the given string or link 指定された文字列またはリンクに対する利用可能なフィルタを取得します。 const ytsr = require('ytsr'); const filters1 = await ytsr.getFilters('github'); const filter1 = filters1.get('Type').get('Video'); const filters2 = await ytsr.getFilters(filter1.url); const filter2 = filters2.get('Features').get('Live'); const options = { pages: 2, } const searchResults = await ytsr(filter2.url, options); dosth(searchResults); searchString 検索文字列 string to search for 検索対象の文字列 or previously optained filter ref または以前に取得したフィルタの参照 options オプション gl[String] -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request gl[String] -> 国の2桁のコード、デフォルトはUS - リクエストのローカライズを可能にします。 hl[String] -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request hl[String] -> 言語を表す2桁のコード、デフォルトはen - リクエストのローカライズを可能にします。 requestOptions[Object] -> Additional parameters to passed to miniget, which is used to do the https requests requestOptions[Object] -> httpsリクエストに使用されるminigetに渡される追加パラメータ returns a Promise resulting in a Map> Map>になったPromiseを返します。 Example response ytsr.continueReq(continuationData) Continues a previous request by pulling yet another page. 前回のリクエストの続きで、さらに別のページを引きます。 The previous request had to be done using pages limitation. 前のリクエストは、ページ数制限を使って行う必要がありました。 var ytsr = require('ytsr'); const search = await ytsr('github', { pages: 1 }); display(search.items); const r2 = ytsr.continueReq(search.continuation); display(r2.items); const r3 = ytsr.continueReq(r2.continuation); display(r3.items); returns a Promise resolving into { continuation, items } は、{ continuation, items }に解決するPromiseを返します。 Install インストール npm install --save ytsr

Viewing all articles
Browse latest Browse all 8882

Trending Articles