fast-dirpy 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # fast-dirpy
1
+ <div align="center">
2
+ <img src=".github/fast-dirpy.png" style="width: 90px;"/>
3
+ <h1>fast-dirpy</h1>
4
+ </div>
2
5
 
3
6
  [![npm version][npm-version-src]][npm-version-href]
4
7
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
@@ -8,6 +11,11 @@
8
11
 
9
12
  A simple library/CLI to download youtube(etc.) videos.
10
13
 
14
+ ## Supported Websites
15
+
16
+ - [YouTube](https://www.youtube.com/)
17
+ - [Bilibili](https://www.bilibili.com/)
18
+
11
19
  ## Installation
12
20
 
13
21
  ### As a library
@@ -53,6 +61,9 @@ export default defineConfig({
53
61
  # -P, --proxyPort: proxy port
54
62
 
55
63
  fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -H 127.0.0.1 -P 7890
64
+
65
+ # No proxy needed for Bilibili videos
66
+ fast-dirpy get --bilibili https://www.bilibili.com/video/BV1TSPeeGE35
56
67
  ```
57
68
 
58
69
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
@@ -70,6 +81,9 @@ fast-dirpy get https\://www.youtube.com/watch\?v\=SAXpBgkXt60
70
81
  # -H, --proxyHost: proxy host.
71
82
  # -P, --proxyPort: proxy port.
72
83
  fast-dirpy download https\://www.youtube.com/watch\?v\=SAXpBgkXt60 -p ./test.mp4 -H 127.0.0.1 -P 7890
84
+
85
+ # No proxy needed for Bilibili videos
86
+ fast-dirpy download --bilibili https://www.bilibili.com/video/BV1TSPeeGE35 -p ./test.mp4
73
87
  ```
74
88
 
75
89
  if you have set your proxy config in `fast-dirpy.config.ts`, you can omit proxy parameters:
@@ -86,7 +100,7 @@ fast-dirpy --help
86
100
 
87
101
  ### Use as a library
88
102
  ```ts
89
- import { downloadVideoFromRawLink, getDirectLink } from 'fast-dirpy'
103
+ import { downloadVideoFromRawLink, getDirectLink, getBilibiliLink } from 'fast-dirpy'
90
104
 
91
105
  // get direct link
92
106
  const link = await getDirectLink(
@@ -97,15 +111,26 @@ const link = await getDirectLink(
97
111
  }
98
112
  )
99
113
 
114
+ // get bilibili direct link
115
+ const link = await getBilibiliLink(
116
+ '<url>',
117
+ )
118
+
100
119
  // download video
101
120
  await downloadVideoFromRawLink({
102
- url,
121
+ url: '<url>',
103
122
  path: './download.mp4',
104
123
  proxy: {
105
124
  host: '127.0.0.1',
106
125
  port: 7890
107
126
  }
108
127
  })
128
+
129
+ // download bilibili video
130
+ await downloadBilibiliVideo({
131
+ url: '<url>',
132
+ path: './myvideo.mp4'
133
+ })
109
134
  ```
110
135
 
111
136
  ## License
@@ -0,0 +1,2 @@
1
+ import{a as E,b as T,c as i}from"./chunk-LP3GSA6N.js";var D=E((J,j)=>{"use strict";i();var _=function(r){return I(r)&&!L(r)};function I(e){return!!e&&typeof e=="object"}function L(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||R(e)}var v=typeof Symbol=="function"&&Symbol.for,U=v?Symbol.for("react.element"):60103;function R(e){return e.$$typeof===U}function V(e){return Array.isArray(e)?[]:{}}function l(e,r){return r.clone!==!1&&r.isMergeableObject(e)?s(V(e),e,r):e}function $(e,r,t){return e.concat(r).map(function(o){return l(o,t)})}function C(e,r){if(!r.customMerge)return s;var t=r.customMerge(e);return typeof t=="function"?t:s}function B(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function h(e){return Object.keys(e).concat(B(e))}function M(e,r){try{return r in e}catch{return!1}}function F(e,r){return M(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function K(e,r,t){var o={};return t.isMergeableObject(e)&&h(e).forEach(function(n){o[n]=l(e[n],t)}),h(r).forEach(function(n){F(e,n)||(M(e,n)&&t.isMergeableObject(r[n])?o[n]=C(n,t)(e[n],r[n],t):o[n]=l(r[n],t))}),o}function s(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||$,t.isMergeableObject=t.isMergeableObject||_,t.cloneUnlessOtherwiseSpecified=l;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):K(e,r,t):l(r,t)}s.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return s(o,n,t)},{})};var N=s;j.exports=N});i();import z from"node:fs";import P from"axios";import G from"jsdom";i();var p=T(D(),1);import{createConfigLoader as k}from"unconfig";var f={timeout:2e4};async function O(e){let r=f,t=k({sources:[{files:["fast-dirpy.config"],extensions:["ts","mts","cts","js","mjs","cjs"]}],cwd:process.cwd(),merge:!1}),{config:o,sources:n}=await t.load();return n.length?(0,p.default)((0,p.default)(r,o),e):(0,p.default)(r,e)}var H={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},{JSDOM:W}=G;async function Y(e,r=f){let{proxy:t,timeout:o}=await O(r),n=t?.host!==""?t:void 0,{data:c}=await P.get("https://dirpy.com/studio",{params:{url:e},headers:{...H,Referer:`https://dirpy.com/studio?url=${e}`},proxy:n,timeout:o}),{window:u}=new W(c),a="",m=u.document.getElementById("media-source");return m&&(a=m.src),a}async function w(e,r=f){let{path:t,url:o}=e,{proxy:n,timeout:c}=await O(r),u=n?.host!==""?n:void 0;if(o==="")return Promise.reject("Extract direct link failed!");let a=z.createWriteStream(t);return(await P({url:o,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36"},method:"GET",responseType:"stream",proxy:u,timeout:c,onDownloadProgress:d=>{let{loaded:y,total:x,progress:A}=d,S=`loaded:${y} total: ${x} progress: ${(A*100).toFixed(2)}%
2
+ `;console.log(S)}})).data.pipe(a),new Promise((d,y)=>{a.on("finish",d),a.on("error",y)})}async function ie(e,r=f){let{path:t,url:o}=e,n=await Y(o,r);await w({url:n,path:t},r)}i();function X(e){let r=e.match(/BV[a-zA-Z0-9]+/);return r?`https://bilibili-real-url.deno.dev/${r[0]}.mp4`:""}async function le(e){let{path:r,url:t}=e,o=X(t);o!==""?await w({url:o,path:r||"./download.mp4"}):console.error("Extract direct link failed!")}export{Y as a,w as b,ie as c,X as d,le as e};
@@ -0,0 +1 @@
1
+ var n=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var l=(t,e)=>()=>(t&&(e=t(t=0)),e);var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var s=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of p(e))!f.call(t,m)&&m!==o&&i(t,m,{get:()=>e[m],enumerable:!(r=a(e,m))||r.enumerable});return t};var g=(t,e,o)=>(o=t!=null?n(c(t)):{},s(e||!t||!t.__esModule?i(o,"default",{value:t,enumerable:!0}):o,t));var _=l(()=>{"use strict"});export{d as a,g as b,_ as c};
@@ -0,0 +1 @@
1
+ import{c as i}from"./chunk-LP3GSA6N.js";i();function o(p){return p}export{o as a};
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1 @@
1
+ import{a as l,c as a,d as c,e as y}from"./chunk-4ZCL2CPC.js";import{c as d}from"./chunk-LP3GSA6N.js";d();import{cac as f}from"cac";import g from"restore-cursor";var m={name:"fast-dirpy",type:"module",version:"0.1.4",description:"A simple library/CLI to download video using dirpy.com",author:"Vincent-the-gamer",license:"MIT",homepage:"https://github.com/Vincent-the-gamer/fast-dirpy#readme",repository:{type:"git",url:"git+https://github.com/Vincent-the-gamer/fast-dirpy.git"},bugs:{url:"https://github.com/Vincent-the-gamer/fast-dirpy/issues"},sideEffects:!1,main:"dist/index.js",module:"dist/index.js",types:"dist/index.d.ts",typesVersions:{"*":{".":["./dist/index.d.ts","./dist/cli.d.ts"]}},bin:{"fast-dirpy":"bin/fast-dirpy.js"},files:["dist"],scripts:{tsx:"tsx",build:"tsup",test:"vitest",dep:"taze major","lint:fix":"eslint . --fix",login:"pnpm login --registry https://registry.npmjs.com"},publishConfig:{registry:"https://registry.npmjs.com",access:"public"},dependencies:{axios:"^1.8.4",cac:"^6.7.14",jsdom:"^26.0.0","restore-cursor":"^5.1.0",unconfig:"^7.3.1"},devDependencies:{"@antfu/eslint-config":"^4.11.0","@types/node":"^22.13.17",deepmerge:"^4.3.1",eslint:"^9.23.0",taze:"^19.0.4",tsup:"^8.4.0",tsx:"^4.19.3",typescript:"^5.8.2",vitest:"^3.1.1"}};var t=f("fast-dirpy");t.command("get <url>","get video direct link.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").option("--bilibili","Tell fast-dirpy to fetch a Bilibili link.").action(async(i,r)=>{let{proxyHost:o,proxyPort:n,bilibili:e}=r;if(e){if(!i.includes("bilibili.com")){console.error("Please provide a valid Bilibili URL.");return}let s=await c(i);console.log(s)}else{let p=await l(i,o?{proxy:{host:o,port:n}}:void 0);console.log(p)}});t.command("download <url>","download a video.").option("--path, -p <path>","Download destination path + filename. e.g. /xxx/example.mp4.").option("--proxyHost, -H <proxyHost>","Proxy host.").option("--proxyPort, -P <proxyPort>","Proxy port.").option("--bilibili","Tell fast-dirpy to download from a Bilibili link, then bypass proxy.").action(async(i,r)=>{let{proxyHost:o,proxyPort:n,path:e,bilibili:s}=r;s?await y({url:i,path:e}):a({url:i,path:e||"./download.mp4"},o?{proxy:{host:o,port:n}}:void 0)});t.help();t.version(m.version);t.parse();g();
@@ -0,0 +1,16 @@
1
+ interface DirpyOptions {
2
+ proxy?: {
3
+ protocol?: string;
4
+ host: string;
5
+ port: number;
6
+ };
7
+ timeout?: number;
8
+ }
9
+ interface DownloadParams {
10
+ url: string;
11
+ path: string;
12
+ }
13
+
14
+ declare function defineConfig(options: DirpyOptions): DirpyOptions;
15
+
16
+ export { type DirpyOptions as D, type DownloadParams as a, defineConfig as d };
@@ -0,0 +1 @@
1
+ export { d as defineConfig } from './config-BACwc8Uz.js';
package/dist/config.js ADDED
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-OTOEWWYP.js";import"./chunk-LP3GSA6N.js";export{a as defineConfig};
@@ -0,0 +1,11 @@
1
+ import { D as DirpyOptions, a as DownloadParams } from './config-BACwc8Uz.js';
2
+ export { d as defineConfig } from './config-BACwc8Uz.js';
3
+
4
+ declare function getDirectLink(url: string, options?: Partial<DirpyOptions>): Promise<string>;
5
+ declare function downloadVideo(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
6
+ declare function downloadVideoFromRawLink(params: DownloadParams, options?: Partial<DirpyOptions>): Promise<void>;
7
+
8
+ declare function getBilibiliDirectLink(link: string): string;
9
+ declare function downloadBilibiliVideo(params: DownloadParams): Promise<void>;
10
+
11
+ export { DirpyOptions, DownloadParams, downloadBilibiliVideo, downloadVideo, downloadVideoFromRawLink, getBilibiliDirectLink, getDirectLink };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{a as r,b as e,c as f,d as m,e as p}from"./chunk-4ZCL2CPC.js";import{a as t}from"./chunk-OTOEWWYP.js";import{c as o}from"./chunk-LP3GSA6N.js";o();export{t as defineConfig,p as downloadBilibiliVideo,e as downloadVideo,f as downloadVideoFromRawLink,m as getBilibiliDirectLink,r as getDirectLink};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fast-dirpy",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "description": "A simple library/CLI to download video using dirpy.com",
6
6
  "author": "Vincent-the-gamer",
7
7
  "license": "MIT",
@@ -44,14 +44,14 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@antfu/eslint-config": "^4.11.0",
47
- "@types/node": "^22.13.14",
47
+ "@types/node": "^22.13.17",
48
48
  "deepmerge": "^4.3.1",
49
49
  "eslint": "^9.23.0",
50
50
  "taze": "^19.0.4",
51
51
  "tsup": "^8.4.0",
52
52
  "tsx": "^4.19.3",
53
53
  "typescript": "^5.8.2",
54
- "vitest": "^3.0.9"
54
+ "vitest": "^3.1.1"
55
55
  },
56
56
  "scripts": {
57
57
  "tsx": "tsx",