Skip to content

Instantly share code, notes, and snippets.

@eagletmt
Created April 30, 2011 15:02
Show Gist options
  • Save eagletmt/949731 to your computer and use it in GitHub Desktop.
Save eagletmt/949731 to your computer and use it in GitHub Desktop.
patches for stella.js
diff --git a/stella.js b/stella.js
index c0719a2..223de97 100644
--- a/stella.js
+++ b/stella.js
@@ -964,35 +964,11 @@ Thanks:
set volume (value) (this.player.setVolume(value), this.volume),
fetch: function (filepath) {
- function _fetch (id, t) {
- let url =
- "http://youtube.com/get_video?video_id=" + id +
- "&t=" + decodeURIComponent(t) +
- (quality ? "&fmt=" + quality : '');
- U.download(url, filepath, '.flv', self.title);
- }
-
- let self = this;
-
// all(1080p,720p,480p,360p) -> 37, 22, 35, 34, 5
// FIXME 一番初めが最高画質だと期待
- let cargs = content.wrappedJSObject.yt.config_.SWF_CONFIG.args;
- let quality = cargs.fmt_map.match(/^\d+/);
- let t = cargs.t;
- let id = this.id;
-
- // 時間が経っていると無効化されてしまっている
- //_fetch(t, id);
-
- U.httpRequest(
- U.currentURL,
- null,
- function (xhr) {
- // XXX t が変わるために、キャッシュを利用できない問題アリアリアリアリ
- let [, t] = xhr.responseText.match(/swfHTML.*&t=([^&]+)/);
- _fetch(id, t);
- }
- );
+ let cargs = content.wrappedJSObject.yt.config_.PLAYER_CONFIG.args;
+ let url = decodeURIComponent(cargs.fmt_url_map.split(',')[0].split('|')[1]);
+ U.download(url, filepath, '.flv', this.title);
},
makeURL: function (value, type) {
diff --git a/stella.js b/stella.js
index 223de97..ad82531 100644
--- a/stella.js
+++ b/stella.js
@@ -1454,6 +1454,7 @@ Thanks:
functions: {
currentTime: 'w',
+ fetch: 'x',
makeURL: 'x',
muted: 'w',
pause: 'x',
@@ -1503,6 +1504,25 @@ Thanks:
get volume () parseInt(this.player.__stella_volume),
set volume (value) (this.api_setVolume(value), this.player.__stella_volume = value),
+ fetch: function(filepath) {
+ let self = this;
+ let id = U.currentURL.match(/vimeo\.com\/(\d+)/)[1];
+ U.httpRequest(
+ 'http://www.vimeo.com/moogaloop/load/clip:' + id,
+ null,
+ function(xhr) {
+ let doc = xhr.responseXML;
+ let signature = U.xpathGet('/xml/request_signature', doc).textContent;
+ let timestamp = U.xpathGet('/xml/timestamp', doc).textContent;
+ let isHD = parseInt(U.xpathGet('/xml/video/isHD', doc).textContent);
+ let url = 'http://www.vimeo.com/moogaloop/play/clip:' + id
+ + '/' + signature + '/' + timestamp
+ + '/?q=' + (isHD ? 'hd' : 'sd');
+ U.download(url, filepath, isHD ? '.mp4' : '.flv', self.title);
+ }
+ );
+ },
+
makeURL: function (value, type) {
switch (type) {
case Player.URL_ID:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment