From 8ec19bdf914e7cd92b44f9670a72230f5cd94c4b Mon Sep 17 00:00:00 2001 From: manageryzy Date: Thu, 29 Oct 2015 20:50:32 +0800 Subject: [PATCH] finished Signed-off-by: manageryzy --- .gitignore | 1 + package.json | 2 +- readme.md | 2 +- upload.js | 325 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 328 insertions(+), 2 deletions(-) create mode 100644 upload.js diff --git a/.gitignore b/.gitignore index c4a65da..632b7cc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ /gen/* ffmpeg.7z *.tmp +*.bak !.gitkeep diff --git a/package.json b/package.json index 0d314e8..fcc3bcf 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "download":"^4.4.1", "mp3-duration":"^1.0.5", "xmlbuilder":"^3.1.0", - "ftp":"^0.3.10", + "ftp-client":"^0.2.2", "md5-file":"^2.0.3" } } diff --git a/readme.md b/readme.md index f207df0..3ab1392 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,7 @@ ## 上传服务器 ## -**<>** +执行命令`node upload.js`。自动上传全部资源(如果服务器有同名文件不会上传),并且会把旧的xml备份到gen目录。 ## 添加歌曲 ## diff --git a/upload.js b/upload.js new file mode 100644 index 0000000..de9a946 --- /dev/null +++ b/upload.js @@ -0,0 +1,325 @@ +var Client = require('ftp'); +var fs = require('fs'); +var md5File = require('md5-file') + +try{ + var config = JSON.parse(fs.readFileSync('./data/config/password.json', 'utf8')); +}catch(e){ + console.error('please check your password.json in ./data/config/'); + throw e; +} + +var nullImage = md5File('./data/config/null.jpg'); + +var MP3List = []; +var MP3LQList = []; +var LyricList = []; +var BGList = []; +var BKList = []; + +//search mp3 +var files = fs.readdirSync('./data/mp3'); +for(var i=0;i0;){ + var o = MP3List.pop(); + var found = false; + for(var i = 0;i0;){ + var o = MP3LQList.pop(); + var found = false; + for(var i = 0;i0;){ + var o = BGList.pop(); + var found = false; + for(var i = 0;i0;){ + var o = BKList.pop(); + var found = false; + for(var i = 0;i0;){ + var o = LyricList.pop(); + var found = false; + for(var i = 0;i