From e4f4df09f91a977fffabf6ea8cc9b59836f92cd2 Mon Sep 17 00:00:00 2001 From: anekos Date: Tue, 18 May 2010 13:43:30 +0000 Subject: YouTubeUserChannelPlayer 実装 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37615 d0d07461-0603-4401-acd4-de1884942a52 --- stella.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'stella.js') diff --git a/stella.js b/stella.js index 96c3102..a6090be 100644 --- a/stella.js +++ b/stella.js @@ -39,7 +39,7 @@ let PLUGIN_INFO = すてら For Niconico/YouTube/Vimeo, Add control commands and information display(on status line). ニコニコ動画/YouTube/Vimeo 用。操作コマンドと情報表示(ステータスライン上に)追加します。 - 0.30.3 + 0.31.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) @@ -1014,6 +1014,63 @@ Thanks: // }}} + /********************************************************************************* + * YouTubeUserChannelPlayer {{{ + *********************************************************************************/ + + function YouTubeUserChannelPlayer () { + Player.apply(this, arguments); + } + + YouTubeUserChannelPlayer.getIDfromURL = function (url) let ([_, r] = url.match(/\/([^\/]+)($|[\?]+)/)) r; + YouTubeUserChannelPlayer.isVideoURL = function (url) /^https?:\/\/(www\.)?youtube\.com\/watch\?.+/(url); + + YouTubeUserChannelPlayer.prototype = { + __proto__: YouTubePlayer.prototype, + + get id () + YouTubeUserChannelPlayer.getIDfromURL(U.currentURL), + + get isValid () U.currentURL.match(/^http:\/\/(?:[^.]+\.)?youtube\.com\/user\//), + + fetch: function (filepath) { + // TODO 動画変数が手に入らない? + throw "not implmented!!"; + }, + + get pageinfo () { + let doc = content.document; + let wd = doc.querySelector('#playnav-curvideo-description'); + return [ + [ + 'comment', + wd.textContent + ] + ]; + }, + + get relations () { + let result = []; + let doc = content.document; + for each (let item in Array.slice(doc.querySelectorAll('div.playnav-item.playnav-video'))) { + let link = item.querySelector('a.playnav-item-title.ellipsis'); + let url = link.href; + if (!YouTubePlayer.isVideoURL(url)) + continue; + result.push( + new RelatedID( + YouTubePlayer.getIDfromURL(url), + link.querySelector('span').textContent, + item.querySelector('img').src + ) + ); + } + return result; + }, + + }; + + /********************************************************************************* * NicoPlayer {{{ *********************************************************************************/ @@ -1589,6 +1646,7 @@ Thanks: this.players = { niconico: new NicoPlayer(this.stella), youtube: new YouTubePlayer(this.stella), + youtubeuc: new YouTubeUserChannelPlayer(this.stella), vimeo: new VimeoPlayer(this.stella) }; @@ -1760,6 +1818,7 @@ Thanks: addPageInfo: function () { let self = this; + delete buffer.pageInfo.S; buffer.addPageInfoSection( 'S', 'Stella Info', -- cgit v1.2.3