<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Google API | ウダ2Blog</title>
	<atom:link href="https://uda2.com/blog/tag/google-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://uda2.com/blog</link>
	<description>大阪でフリーランスとしてWEB制作している管理人が気になった技術をメモったり、作ったツールの紹介などを綴っているブログです。</description>
	<lastBuildDate>Fri, 07 Jul 2023 07:01:42 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Youtube配信スイッチング「zappin&#8217;」</title>
		<link>https://uda2.com/blog/zappin/</link>
					<comments>https://uda2.com/blog/zappin/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Mon, 21 Sep 2020 13:02:39 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[DBD]]></category>
		<category><![CDATA[Google API]]></category>
		<category><![CDATA[Youtube Live]]></category>
		<guid isPermaLink="false">https://uda2.com/blog/?p=2505</guid>

					<description><![CDATA[<p>6月末から初めたDEAD BY DAYLIGHTで吊られまくってます。コロナの影響でゲーム実況をはじめた芸能人も増え、日々Youtubeのゲーム実況動画を見てるのですがコラボされたときに一つのチャンネルしか見ていないと、</p>
The post <a href="https://uda2.com/blog/zappin/">Youtube配信スイッチング「zappin’」</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>6月末から初めたDEAD BY DAYLIGHTで吊られまくってます。<br>コロナの影響でゲーム実況をはじめた<a href="https://dbd.uda2.com/" target="_blank" rel="noreferrer noopener">芸能人</a>も増え、日々Youtubeのゲーム実況動画を見てるのですがコラボされたときに一つのチャンネルしか見ていないと、他のチャンネルで盛り上がってるシーンを見逃す事が多々あります。<br>そこで2窓・3窓しても見やすいようなプレーヤーを作ってみました。<br><a href="https://zappin.uda2.com/" target="_blank" rel="noreferrer noopener">zappin’ &#8211; Youtube Live Switcher &#8211;</a></p>



<span id="more-2505"></span>



<p></p>



<p>Youtube Data APIでトップページの「人気のライブ実況」を検索表示（5分以内はキャッシュしてます。）<br>視聴するページでは同じくYoutube Data APIで動画の情報を確認して実況中かを判断したりタイトルの抜き出しをした上で<br>YouTube Player APIでプレイヤーを用意してチャットをインラインフレームで並べています。</p>



<p>画面サイズの問題でPC向けには作っていたのですが一応タブレットやスマホでもChrome経由だとなんとか見れる場合もありますが負荷が大きいのでまともに動作しないかと思います。<br>Androidではチャットが表示されない場合は「PC版サイト」にチェックを入れると見れるかもしれません。<br>URLの追加の度にリロードしないようにJavascriptで追加できるようにしつつSNS等で伝えやすいように実況動画の追加削除をURLに反映しています。<br>チャット上のチャンネル名をクリックすると動画が切り替わりますが、内部でプレイヤーを2つ用意して切り替えた際に新しい動画の準備が整ったら切り替わるようになっていてプリロードのギリギリまで前の動画を視聴いただけるようになってます。<br>PCでは左に動画右にチャットの画面構成になりますが上の赤いバーを移動させる事で調整できます。<br>音声はそれぞれ設定を保存するようにしていますので一度設定するとチャンネルによって音のばらつきに悩まされる事も少なくなります。<br>あとGoogleのAPIの利用は有料化されてるので利用は制限させていただいております。</p>The post <a href="https://uda2.com/blog/zappin/">Youtube配信スイッチング「zappin’」</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/zappin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>音エモンPLAYLIST by Youtube</title>
		<link>https://uda2.com/blog/otoemon/</link>
					<comments>https://uda2.com/blog/otoemon/#respond</comments>
		
		<dc:creator><![CDATA[uda2]]></dc:creator>
		<pubDate>Wed, 03 Jun 2015 20:23:40 +0000</pubDate>
				<category><![CDATA[制作日記]]></category>
		<category><![CDATA[Google API]]></category>
		<category><![CDATA[Youtube]]></category>
		<category><![CDATA[音エモン]]></category>
		<guid isPermaLink="false">http://uda2.com/blog/?p=1979</guid>

					<description><![CDATA[<p>仕事中はテレビをBGM代わりにしてたが、電気代が高いと気づき、Youtubeで音楽を流すことにした。 だが普段音楽を聴く習慣が無いといい曲を探すのに何をとっかかりにすればいいのか分らない。 音楽番組「音エモン」に目をつけ</p>
The post <a href="https://uda2.com/blog/otoemon/">音エモンPLAYLIST by Youtube</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>仕事中はテレビをBGM代わりにしてたが、電気代が高いと気づき、Youtubeで音楽を流すことにした。<br />
だが普段音楽を聴く習慣が無いといい曲を探すのに何をとっかかりにすればいいのか分らない。<br />
音楽番組「<a href="http://www.ktv.jp/otoemon/index.html" target="_blank">音エモン</a>」に目をつけた、関西以外の人はご存じないかもしれないが「音エモン」は関西の深夜枠で10年以上イケてるミュージックビデオを紹介し続けている御長寿音楽番組です。<br />
そんな「音エモン」で紹介された曲をYoutubeで連続再生する事にした。<br />
<span id="more-1979"></span><br />
まずは音エモンの公式サイトからWebスクレイピング（情報収集）してタイトルと歌手名を抽出した。<br />
それからYoutubeを検索するのだけど、これはGoogleが用意してる<a href="https://developers.google.com/youtube/v3/?hl=ja" target="_blank">YouTube Data API (v3)</a>にお任せする。</p>
<p>Googleの多くのAPIはAPIキーが必要で下記の手順でキーを取得した。<br />
1. <a href="https://console.developers.google.com/" target="_blank">Google Developers Console</a>でプロジェクトを作成する。<br />
2. 作成したプロジェクトで「APIと認証」の「API」から「YouTube Data API」の承認を許可する。<br />
3. 「APIと認証」の「認証情報」から公開APIへのアクセスで新しいキーを作成する。ちなみに今回はPHPで検索するので「サーバーキー」を使う。</p>
<p>個人的にはIPアドレスを間違えて「There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.」とエラーが動かなかったので多くのサーバーを管理してる人は間違えないように。</p>
<p>APIキーが手に入ったらPHPで検索機能の実装ですが<a href="https://github.com/google/google-api-php-client" target="_blank">google/google-api-php-client</a>という専用のライブラリが用意されてるのでこれをダウンロードしておく。<br />
<a href="https://developers.google.com/youtube/v3/code_samples/php?hl=ja#search_by_keyword" target="_blank">YouTube Data API: PHP コード サンプル</a>を参考にコードを書いたが「Class &#8216;Google_Service&#8217; not found」とか言われて動かない。ダウンロードしたライブラリの方のサンプルを覗くとまず最初に「Google/autoload.php」を読み込んでいるようなので同じように読み込ませると正常に動作するようになった。</p>
<p>最後に動画を連続再生したかったので方法を模索してるとコレもGoogleが用意した<a href="https://developers.google.com/youtube/iframe_api_reference?hl=ja" target="_blank">iframe 組み込みの YouTube Player API</a>のcuePlaylistに動画IDを登録すると順番に再生してくれるらしい。</p>
<p>結局Google APIに頼りっきりだが完成した。<br />
<a href="http://otoemon.uda2.com/" target="_blank">音エモンPLAYLIST by Youtube</a></p>The post <a href="https://uda2.com/blog/otoemon/">音エモンPLAYLIST by Youtube</a> first appeared on <a href="https://uda2.com/blog">ウダ2Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://uda2.com/blog/otoemon/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
