DraftPadからYouTube動画のリンクを取得するアシスト DraftTube

今年はずっとDraftPadだったなあ。


DraftPad 1.6.2
分類:仕事効率化,ユーティリティ
価格:無料 (Manabu Ueno)

実はもう一つ実験中のアシストがあるんですが、その前にその前に。YouTube動画リンクを拾う方法がまだ出来てない。GoogleにはAPIがあるはずなので探してみました。


Developer's Guide: JSON-C / JavaScript - YouTube — Google Developers
When submitting a YouTube Data API request, you can use the alt query parameter to specify the forma...

いろんな方法があるんですが、一番簡単そうなJSON-C形式を選びました。キーワードを書いて実行すると、検索結果がDraftPadの内蔵ブラウザに表示されます。

draftpad://self/web?source=<meta name=viewport content=initial-scale=1><meta name=format-detection content=telephone=no><body bgcolor=gray><script>function main(x){url=%22https://gdata.youtube.com/feeds/api/videos?v=2%26alt=jsonc%26q=%22+x.s;req=new XMLHttpRequest();req.open(%22get%22,url,false);req.send(null);t=JSON.parse(req.responseText);item=t.data.items;document.write(%22<table>%22);for(i in item){document.write(%22<tr><td><iframe width=160 height=160 src=http://www.youtube.com/embed/%22+item[i].id+%22></iframe></td><td valign=top><strong><a onClick=draftpad.insert(\"\\n%22+item[i].player.mobile.replace(/details/,%22watch%22)+%22\") valign=top>%22+item[i].title+%22</a></strong><br><br> 投稿日: %22+item[i].uploaded.replace(/T/,%22 %22).replace(/.000Z/,%22%22)+%22<br> 再生数: %22+item[i].viewCount+%22 回<br> 評価 : %22+String(item[i].rating).replace(/undefined/,%220%22).substr(0,3)+%22 ( %22+String(item[i].ratingCount).replace(/undefined/,%220%22)+%22 件)</td></tr>%22)}doucument.write(%22</table>%22);}location.href=%22draftpad:///webdelegate?load=main%22;</script></body>&s=<@>

登録リンクはこちら→ http://tinyurl.com/celryyn



サムネイルはそのまま再生する形式になってます。縦横160pxの正方形にすることで、レコードのジャケットをイメージしてみました。再生時はフルスクリーンになります。



動画情報が右側に並びますが、このタイトルをタップすると、動画のURLアドレスをDraftPadの本文に貼り付けます。これを基に、ブログ内の動画プレーヤーを設定。


https://m.youtube.com/watch?v=5S4KR2Vosac
問題なのはこのAPI、日本語には強いのに、英語の曲がちっともヒットしないのです。どうやら絞り込むために、よく使われる言葉をスルーする印象。とても困ります。ジャズのスタンダードだと、特徴のないタイトルだったりするのに。なんか空振り感が残ってしまった。