Coder Social home page Coder Social logo

lanzou-api's Introduction

Lanzou API

Warning

Depracated: 已废弃项目

蓝奏云 API node.js 版本,基于 fetch,零依赖。目前实现了大部分功能,node.js 必须 >= 18

理论上程序能够容易地转换为 Deno 版本和浏览器版本(浏览器需自行处理 CORS 限制)

构建

$ npm install
$ npm run build

$ npm run doc # 可选,生成文档

使用

https://pc.woozooo.com/mydisk.php 获取 cookie,有效期未知 基于 Promise 的 API,程序仅对蓝奏云请求接口做了简单的封装,返回数据大致为蓝奏云接口原始数据

import LanzouAPI from "./lib/lanzou.js";
LanzouAPI.queryShareFileInfoWithPassword("https://upload.lanzouj.com/i95j302p", "bxeb").then(console.log);
const lanzou = new LanzouAPI(cookie);
lanzou.getFolders().then(({ zt, info, text }) => {
    if (zt === 1) {
        console.log(info);
    } else {
        console.error(info);
    }
});
// more...

蓝奏云的接口有点混乱,但一般来说 info 表示操作结果或返回值,text 提供额外信息或 null

./src/types.ts 已经对所有返回值进行了描述

正常情况下所有的 API 都不会抛出异常(即使是网络错误)且返回以下接口

interface<Info> {
    zt: number; // 状态码: 0 失败  1 成功 等等
    info: Info | Error; // 成功时为操作结果或返回值,失败时返回 Error 对象
    text string | null; // 成功时可能返回额外信息或 null,失败时返回失败信息(字符串)
}

失败时可以通过检测 info 来获取程序捕获的异常

const { zt, info, text } = await lanzou.getFolders();
if (zt === 1) {
    // success
} else {
    if (info instanceof Error) {
        // ...
    }
}

文档

API 参见文档,由 typedoc 自动生成
https://yieldray.github.io/lanzou-api/classes/lanzou.default.html

lanzou-api's People

Contributors

yieldray avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.