Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
YouTube API を使ってみた
Search
wai-doi
October 29, 2021
Programming
72
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
YouTube API を使ってみた
wai-doi
October 29, 2021
More Decks by wai-doi
See All by wai-doi
無料で将棋を楽しめるサービス5選
yusukedoi
0
170
Other Decks in Programming
See All in Programming
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
270
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
3
1.7k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
200
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
180
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
230
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
770
Groovy as a human and AI friendly programming language
paulk
0
180
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.7k
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
290
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
220
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.1k
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Curse of the Amulet
leimatthew05
3
16k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
900
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
GitHub's CSS Performance
jonrohan
1033
470k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
650
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
Amusing Abliteration
ianozsvald
1
380
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
23k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
Transcript
YouTube API を使ってみた @wai_doi 2021/10/29 技術交流会 1
自己紹介 • 名前 ◦ 土居裕典(@wai_doi) • 経歴 ◦ 新卒3年目 •
趣味 ◦ 将棋 ◦ YouTobe ◦ スマホゲーム 2
YouTube APIで解決したいこと 3
クラッシュロワイヤル とは • 通称 クラロワ • リアルタイム対戦型の新感覚カードゲーム • 8枚のカードでデッキを組む •
世界中のプレイヤーと対戦 4
Stats Royale チャンネル • クラロワの上位プレイヤー の試合がアップされている チャンネル • ひとつの動画にひとつの試 合
• 1日50本以上アップされて いる https://www.youtube.com/channel/UC698QxCg2KVVWh4G6NQLX_w 5
観たい動画のいつもの探し方 チャンネルのアップロード済み動 画の一覧から探す 6
特定カードが使われる動画だけを観たい! ゴーレム サムネイル画像に写っているカードで 観たい動画をいつも選んでいる ( 面倒😥) 7
特定カードが使われる動画だけを観たい! ゴーレム サムネイル画像に写っているカードで 観たい動画をいつも選んでいる ( 面倒😥) 8 観たい動画を簡単にカードで検索で きるようにしたい!!
それぞれの動画の概要欄を見ると... 9 使われるデッキとカードが 載っている !!😀
YouTube APIを使って アプリケーション開発をしてみた 10
Stats Royaleの動画検索Railsアプリケーションの構想 • Stats Royale がアップロードした動画を対象に • YouTube APIを使って動画ごとの概要欄のテキストを取得する •
概要欄のテキストからその動画で使われるデッキとカードを抜き出す • 動画、デッキ、カードを関連付けてデータベースに持っておく • 指定したカードで検索して、そのカードが使われる動画だけを一覧で表示する 11
設計したデータモデル 動画 デッキ カード ✳ 2 ✳ 8 12
YouTube API で利用できるリソース • アクティビティ • チャンネル • 再生リストの項目 •
再生リスト • 検索 • サブカテゴリ • サムネイル • 動画カテゴリ • 動画 • ... https://developers.google.cn/youtube/v3/docs?hl=ja 13
YouTube APIの制限 • 10000 Queries / 日 • Query =
リクエスト回数 * コスト • list が一番コストが安い • insert, updateがコストが高い https://ichiro-kun.com/post/2452/ 14
googleapis/google-api-ruby-client を利用した https://github.com/googleapis/google-api-ruby-client 15
YouTube APIを使った処理フロー 1. チャンネルIDで channels.list を叩く 2. チャンネル情報を取得し、アップロードされた動画の playlist IDを抽出する
3. playlist ID で playlistItems.list を叩く 4. 動画の情報を取得し、Video IDや概要欄のテキストなどを抽出する 16
1. チャンネルIDで channels.list を叩く • チャンネルIDはチャンネルURLの末尾にある チャンネルID 17
channels.list のレスポンス https://developers.google.com/youtube/v3/docs/channels/list itemsの中 18
1. チャンネルIDで channels.list を叩く idパラメータ (チャンネルID) part パラメータ (items の中で欲しいkeyを与える)
19
2. チャンネル情報を取得し、アップロードされた動画の playlist IDを抽出する チャンネルがアップロードした 動画の playlist ID を抽出 20
playlistItems.list のレスポンス https://developers.google.com/youtube/v3/docs/playlistItems/list itemsの中 21
3. playlist ID で playlistItems.list を叩く part パラメータ (items の中で欲しいkeyを与える)
playlistID パラメータ (再生リストのID) pageTokenパラメータ (ページの指定) 次のページのトークンを抽出 22
4.動画の情報を取得し、Video IDや概要欄のテキストなど を抽出する 概要欄のカードの文字列を抽出する 23
以降の処理は割愛します 概要欄のデッキとカードを抽出する • 抽出した情報をDBに保存する • 動画を一覧表示 • 動画の個別のページで埋め込み動画が観られる • 詳細はリポジトリ
https://github.com/wai-doi/clash-royale-youtube-searcher 24
アプリケーションの画面 25 動画個別ページ 動画一覧ページ
デモ https://clash-royale-youtube-searcher.herokuapp.com/ 26
今後追加してみたい機能 • 複数のカードで検索できるようにしたい • あるカード VS あるカードの対戦で検索できるようにしたい 27
ご清聴ありがとうございました! 28