| 10 | | function LDRizeCooperationNiconicoFlvFetcher(LDRizeCooperation){ |
| 11 | | var NiconicoFlvFetcher = [ |
| 12 | | { |
| 13 | | pattern: 'http://www.nicovideo.jp/watch/*', |
| 14 | | handler: function(url,title){ |
| 15 | | const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v="; |
| 16 | | const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/"; |
| 17 | | var videoId = url.match(/\wm\d+/)[0]; |
| 18 | | httpGET(nicoApiEndPoint + videoId,function(apiResult){ |
| 19 | | var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]); |
| | 10 | function LDRizeCooperationNiconicoFlvFetcher(){ |
| | 11 | var NiconicoFlvFetcher = { |
| | 12 | pattern: 'http://www.nicovideo.jp/watch/*', |
| | 13 | handler: function(url,title){ |
| | 14 | const nicoApiEndPoint = "http://www.nicovideo.jp/api/getflv?v="; |
| | 15 | const nicoWatchEndPoint = "http://www.nicovideo.jp/watch/"; |
| | 16 | var videoId = url.match(/\wm\d+/)[0]; |
| | 17 | httpGET(nicoApiEndPoint + videoId,function(apiResult){ |
| | 18 | var flvUrl = decodeURIComponent(apiResult.match(/url=(.*?)&/)[1]); |
| 21 | | httpGET(nicoWatchEndPoint + videoId,function(watchPage){ |
| 22 | | try{ |
| 23 | | var DownloadManager = Cc["@mozilla.org/download-manager;1"] |
| 24 | | .getService(Ci.nsIDownloadManager); |
| 25 | | var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] |
| 26 | | .createInstance(Ci.nsIWebBrowserPersist); |
| | 20 | httpGET(nicoWatchEndPoint + videoId,function(watchPage){ |
| | 21 | try{ |
| | 22 | var DownloadManager = Cc["@mozilla.org/download-manager;1"] |
| | 23 | .getService(Ci.nsIDownloadManager); |
| | 24 | var WebBrowserPersist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"] |
| | 25 | .createInstance(Ci.nsIWebBrowserPersist); |
| 28 | | var sourceUri = makeURI(flvUrl,null,null); |
| 29 | | var file = DownloadManager.userDownloadsDirectory; |
| 30 | | file.appendRelativePath(title + ".flv"); |
| 31 | | var fileUri = makeFileURI(file); |
| | 27 | var sourceUri = makeURI(flvUrl,null,null); |
| | 28 | var file = DownloadManager.userDownloadsDirectory; |
| | 29 | file.appendRelativePath(title + ".flv"); |
| | 30 | var fileUri = makeFileURI(file); |
| 33 | | var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv", |
| 34 | | null, null, null, null, WebBrowserPersist); |
| 35 | | WebBrowserPersist.progressListener = download; |
| 36 | | WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file); |
| 37 | | }catch(e){log(e);liberator.echoerr(e)} |
| 38 | | }); |
| | 32 | var download = DownloadManager.addDownload(0, sourceUri, fileUri, title + ".flv", |
| | 33 | null, null, null, null, WebBrowserPersist); |
| | 34 | WebBrowserPersist.progressListener = download; |
| | 35 | WebBrowserPersist.saveURI(sourceUri, null, null, null, null, file); |
| | 36 | }catch(e){log(e);liberator.echoerr(e)} |