Skip to content

Commit

Permalink
feat: 优化FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhelinCheng committed Jun 2, 2021
1 parent e003445 commit 89a684c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 92 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bilibili-downloader",
"version": "1.0.16",
"version": "1.0.18",
"description": "B 站个人动态视频下载助手,支持下载B站个人动态更新的4k视频,运行该程序后,你所关注的UP主更新的视频第一时间下载保存。",
"main": "./dist/index.js",
"scripts": {
Expand Down Expand Up @@ -58,7 +58,6 @@
"@types/lowdb": "^1.0.9",
"@types/ping": "^0.2.0",
"@types/pino": "^6.3.5",
"@types/promise-ftp": "^1.3.4",
"async": "^3.2.0",
"axios": "^0.21.1",
"basic-ftp": "^4.6.6",
Expand All @@ -70,7 +69,6 @@
"lowdb": "^1.0.0",
"ping": "^0.4.1",
"pino": "^6.11.1",
"pino-pretty": "^5.0.1",
"promise-ftp": "^1.3.5"
"pino-pretty": "^5.0.1"
}
}
1 change: 1 addition & 0 deletions src/core/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async function downloadList(
filePath,
fileName,
localPath,
baseFtpPath,
);

logger.info(`判断是否下载完成...`);
Expand Down
13 changes: 10 additions & 3 deletions src/core/ftp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @Author : Zhelin Cheng
* @Date : 2021-02-19 17:09:10
* @LastEditors : Zhelin Cheng
* @LastEditTime : 2021-06-01 15:39:49
* @FilePath : /bilibili-downloader/src/core/ftp.ts
* @LastEditTime : 2021-06-02 23:37:00
* @FilePath : \bilibili-downloader\src\core\ftp.ts
* @Description : 未添加文件描述
*/

Expand Down Expand Up @@ -35,10 +35,17 @@ export const postData = async (
destPath: string,
fileName: string,
localPath: string,
baseFtpPath: string,
): Promise<boolean> => {
try {
if (isFtp) {
await client.ensureDir(destPath);
const dirs = destPath.split(/\/|\\/);
const lastDir = dirs.pop();

await client.cd(baseFtpPath);
if (lastDir) {
await client.ensureDir(lastDir);
}
await client.uploadFrom(input, `${destPath}/${fileName}`);
return true;
} else {
Expand Down
86 changes: 1 addition & 85 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@
resolved "https://registry.npm.taobao.org/@hapi/bourne/download/@hapi/bourne-2.0.0.tgz#5bb2193eb685c0007540ca61d166d4e1edaf918d"
integrity sha1-W7IZPraFwAB1QMph0WbU4e2vkY0=

"@icetee/ftp@^0.3.15":
version "0.3.15"
resolved "https://registry.nlark.com/@icetee/ftp/download/@icetee/ftp-0.3.15.tgz#d32efd91ab7585f0a3b6cbed9ceffe2763b04ec6"
integrity sha1-0y79kat1hfCjtsvtnO/+J2OwTsY=
dependencies:
readable-stream "1.1.x"
xregexp "2.0.0"

"@nodelib/fs.scandir@2.1.4":
version "2.1.4"
resolved "https://registry.nlark.com/@nodelib/fs.scandir/download/@nodelib/fs.scandir-2.1.4.tgz#d4b3549a5db5de2683e0c1071ab4f140904bbf69"
Expand Down Expand Up @@ -246,11 +238,6 @@
resolved "https://registry.nlark.com/@types/async/download/@types/async-3.2.6.tgz#1d49339846c6aa0b0a8a08303c21176f1b64dc4f"
integrity sha1-HUkzmEbGqgsKiggwPCEXbxtk3E8=

"@types/bluebird@*":
version "3.5.35"
resolved "https://registry.nlark.com/@types/bluebird/download/@types/bluebird-3.5.35.tgz?cache=0&sync_timestamp=1621359544121&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fbluebird%2Fdownload%2F%40types%2Fbluebird-3.5.35.tgz#3964c48372bf62d60616d8673dd77a9719ebac9b"
integrity sha1-OWTEg3K/YtYGFthnPdd6lxnrrJs=

"@types/cron@^1.7.2":
version "1.7.2"
resolved "https://registry.nlark.com/@types/cron/download/@types/cron-1.7.2.tgz#e9fb420da616920dae82d13adfca53282ffaab6e"
Expand All @@ -273,13 +260,6 @@
dependencies:
"@types/node" "*"

"@types/ftp@*":
version "0.3.31"
resolved "https://registry.nlark.com/@types/ftp/download/@types/ftp-0.3.31.tgz#628c7ed8f1126317c582606c6af8dac4e0050dd9"
integrity sha1-Yox+2PESYxfFgmBsavjaxOAFDdk=
dependencies:
"@types/node" "*"

"@types/json-schema@^7.0.3":
version "7.0.7"
resolved "https://registry.nlark.com/@types/json-schema/download/@types/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
Expand Down Expand Up @@ -351,21 +331,6 @@
"@types/pino-std-serializers" "*"
"@types/sonic-boom" "*"

"@types/promise-ftp-common@*":
version "1.1.0"
resolved "https://registry.nlark.com/@types/promise-ftp-common/download/@types/promise-ftp-common-1.1.0.tgz#b877880d552bd5d3f92570cea84497e90d7fd194"
integrity sha1-uHeIDVUr1dP5JXDOqESX6Q1/0ZQ=

"@types/promise-ftp@^1.3.4":
version "1.3.4"
resolved "https://registry.nlark.com/@types/promise-ftp/download/@types/promise-ftp-1.3.4.tgz#3bbf911943ffc250b6d8685c65093d322f3facb7"
integrity sha1-O7+RGUP/wlC22GhcZQk9Mi8/rLc=
dependencies:
"@types/bluebird" "*"
"@types/ftp" "*"
"@types/node" "*"
"@types/promise-ftp-common" "*"

"@types/sonic-boom@*":
version "0.7.0"
resolved "https://registry.nlark.com/@types/sonic-boom/download/@types/sonic-boom-0.7.0.tgz#38337036293992a1df65dd3161abddf8fb9b7176"
Expand Down Expand Up @@ -624,11 +589,6 @@ binary-extensions@^2.0.0:
resolved "https://registry.nlark.com/binary-extensions/download/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha1-dfUC7q+f/eQvyYgpZFvk6na9ni0=

bluebird@2.x:
version "2.11.0"
resolved "https://registry.npm.taobao.org/bluebird/download/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
integrity sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=

boolbase@^1.0.0:
version "1.0.0"
resolved "https://registry.npm.taobao.org/boolbase/download/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
Expand Down Expand Up @@ -912,11 +872,6 @@ conventional-commits-parser@^3.0.0:
through2 "^4.0.0"
trim-off-newlines "^1.0.0"

core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=

cosmiconfig@^7.0.0:
version "7.0.0"
resolved "https://registry.npm.taobao.org/cosmiconfig/download/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
Expand Down Expand Up @@ -1668,7 +1623,7 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, inherits@^2.0.3, inherits@~2.0.1:
inherits@2, inherits@^2.0.3:
version "2.0.4"
resolved "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=
Expand Down Expand Up @@ -1806,11 +1761,6 @@ is-yarn-global@^0.3.0:
resolved "https://registry.nlark.com/is-yarn-global/download/is-yarn-global-0.3.0.tgz?cache=0&sync_timestamp=1619356554445&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-yarn-global%2Fdownload%2Fis-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232"
integrity sha1-1QLTOCWQ6jAEiTdGdUyJE5lz4jI=

isarray@0.0.1:
version "0.0.1"
resolved "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=

isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.nlark.com/isexe/download/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
Expand Down Expand Up @@ -2437,20 +2387,6 @@ progress@^2.0.0:
resolved "https://registry.nlark.com/progress/download/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha1-foz42PW48jnBvGi+tOt4Vn1XLvg=

promise-ftp-common@^1.1.5:
version "1.1.5"
resolved "https://registry.nlark.com/promise-ftp-common/download/promise-ftp-common-1.1.5.tgz#b4f8082a74035647703506763edb14230d9865da"
integrity sha1-tPgIKnQDVkdwNQZ2PtsUIw2YZdo=

promise-ftp@^1.3.5:
version "1.3.5"
resolved "https://registry.nlark.com/promise-ftp/download/promise-ftp-1.3.5.tgz#ecfa4a5e5b779a6bfdd4dd3096957b58286f5104"
integrity sha1-7PpKXlt3mmv91N0wlpV7WChvUQQ=
dependencies:
"@icetee/ftp" "^0.3.15"
bluebird "2.x"
promise-ftp-common "^1.1.5"

pstree.remy@^1.1.7:
version "1.1.8"
resolved "https://registry.npm.taobao.org/pstree.remy/download/pstree.remy-1.1.8.tgz#c242224f4a67c21f686839bbdb4ac282b8373d3a"
Expand Down Expand Up @@ -2525,16 +2461,6 @@ read-pkg@^5.2.0:
parse-json "^5.0.0"
type-fest "^0.6.0"

readable-stream@1.1.x:
version "1.1.14"
resolved "https://registry.nlark.com/readable-stream/download/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk=
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.1"
isarray "0.0.1"
string_decoder "~0.10.x"

readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.6.0:
version "3.6.0"
resolved "https://registry.nlark.com/readable-stream/download/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
Expand Down Expand Up @@ -2829,11 +2755,6 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"

string_decoder@~0.10.x:
version "0.10.31"
resolved "https://registry.nlark.com/string_decoder/download/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94"
integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=

stringify-object@^3.3.0:
version "3.3.0"
resolved "https://registry.npm.taobao.org/stringify-object/download/stringify-object-3.3.0.tgz#703065aefca19300d3ce88af4f5b3956d7556629"
Expand Down Expand Up @@ -3170,11 +3091,6 @@ xdg-basedir@^4.0.0:
resolved "https://registry.npm.taobao.org/xdg-basedir/download/xdg-basedir-4.0.0.tgz?cache=0&sync_timestamp=1617611838739&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxdg-basedir%2Fdownload%2Fxdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha1-S8jZmEQDaWIl74OhVzy7y0552xM=

xregexp@2.0.0:
version "2.0.0"
resolved "https://registry.nlark.com/xregexp/download/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943"
integrity sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=

y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.nlark.com/y18n/download/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
Expand Down

0 comments on commit 89a684c

Please sign in to comment.