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
74
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
YouTube API を使ってみた
wai-doi
October 29, 2021
Transcript
28 slides
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
More Decks by wai-doi
See All by wai-doi
無料で将棋を楽しめるサービス5選
yusukedoi
0
180
Other Decks in Programming
See All in Programming
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
170
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
410
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
700
Beyond Chatbots: Agentic UI with Open Standards @W-JAX 2026, München
manfredsteyer
PRO
0
130
Skills Are the New npm [AAIF Bengaluru, Nov 2026]
shivamsaraswat
0
130
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
17
9.6k
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
660
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
640
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
150
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
330
将来の標準フォーマッター?ktfmtを深堀る
t45k
1
250
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.7k
The Invisible Side of Design
smashingmag
301
52k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
860
Game over? The fight for quality and originality in the time of robots
wayneb77
1
340
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
620
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
540
The untapped power of vector embeddings
frankvandijk
2
2k
Documentation Writing (for coders)
carmenintech
77
5.7k
Faster Mobile Websites
deanohume
310
32k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
4
1.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k