aboutsummaryrefslogtreecommitdiffstats
path: root/stella.js
diff options
context:
space:
mode:
Diffstat (limited to 'stella.js')
-rw-r--r--stella.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/stella.js b/stella.js
index d0b6d34..b188cae 100644
--- a/stella.js
+++ b/stella.js
@@ -313,14 +313,12 @@ Thanks:
return mis;
}
- let dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
- let wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(Ci.nsIWebBrowserPersist);
let file;
if (filepath) {
file = io.File(io.expandPath(filepath));
} else {
- file = dm.userDownloadsDirectory;
+ file = io.File(FileUtils.getDir("DfltDwnld", [""]));
}
if (file.exists() && file.isDirectory() && title)
@@ -329,12 +327,15 @@ Thanks:
if (file.exists())
return U.echoError('The file already exists! -> ' + file.path);
- file = makeFileURI(file);
-
- let dl = dm.addDownload(0, U.makeURL(url, null, null), file, title, null, null, null, null, wbp);
- wbp.progressListener = dl;
- wbp.persistFlags |= wbp.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
- wbp.saveURI(U.makeURL(url), null, null, postData && makePostStream(postData), null, file);
+ Task.spawn(function () {
+ if (postData) {
+ yield U.httpRequest(url, postData, function (xhr) {
+ file.write(xhr.response);
+ });
+ } else {
+ yield Downloads.fetch(url, file);
+ }
+ }).then(null, Cu.reportError);
return file;
},
@@ -1020,7 +1021,7 @@ Thanks:
},
get title ()
- content.document.title.replace(/^YouTube - /, ''),
+ content.document.title.replace(/- YouTube$/, ''),
get totalTime () parseInt(this.player.getDuration()),
@@ -1032,7 +1033,7 @@ Thanks:
fetch: function (filepath) {
// all(1080p,720p,480p,360p) -> 37, 22, 35, 34, 5
// FIXME 一番初めが最高画質だと期待
- let cargs = content.wrappedJSObject.yt.playerConfig.args;
+ let cargs = content.wrappedJSObject.ytplayer.config.args;
cargs.url_encoded_fmt_stream_map.split(',')[0].split('&').forEach(function(x) {
let [key, val] = x.split('=');
if (key == 'url') {
@@ -1156,12 +1157,12 @@ Thanks:
},
get title ()
- content.document.title.replace(/^YouTube - /, ''),
+ content.document.title.replace(/ - YouTube$/, ''),
fetch: function (filepath) {
// all(1080p,720p,480p,360p) -> 37, 22, 35, 34, 5
// FIXME 一番初めが最高画質だと期待
- let cargs = content.wrappedJSObject.yt.playerConfig.args;
+ let cargs = content.wrappedJSObject.ytplayer.config.args;
cargs.url_encoded_fmt_stream_map.split(',')[0].split('&').forEach(function(x) {
let [key, val] = x.split('=');
if (key == 'url') {
@@ -1476,7 +1477,7 @@ Thanks:
}
},
- get title () content.document.title.replace(/\s*\u2010\s*\u30CB\u30B3\u30CB\u30B3\u52D5\u753B(.+)$/, ''),
+ get title () content.document.title.replace(/\s*\u002D\s*\u30CB\u30B3\u30CB\u30B3\u52D5\u753B(.+)$/, ''),
get totalTime () parseInt(this.player.ext_getTotalTime()),