Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ForgQi committed Dec 5, 2021
1 parent 600a8db commit eabe7cb
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 121 deletions.
121 changes: 17 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,22 @@
*Psst — looking for a more complete solution? Check out [SvelteKit](https://kit.svelte.dev), the official framework for building web applications of all sizes, with a beautiful development experience and flexible filesystem-based routing.*
# Biliup

*Looking for a shareable component template instead? You can [use SvelteKit for that as well](https://kit.svelte.dev/docs#packaging) or the older [sveltejs/component-template](https://github.com/sveltejs/component-template)*

---

# svelte app

This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.

To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):

```bash
npx degit sveltejs/template svelte-app
cd svelte-app
```

*Note that you will need to have [Node.js](https://nodejs.org) installed.*


## Get started

Install the dependencies...

```bash
cd svelte-app
npm install
```

...then start [Rollup](https://rollupjs.org):

```bash
npm run dev
```

Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.

By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.

If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.

## Building and running in production mode

To create an optimised version of the app:

```bash
npm run build
```

You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
bilibili投稿客户端,理论上支持Windows,Linux,macOS。

主要是为了解决现有网页端不能多p投稿的问题,虽然现有b站客户端可以多p
但是有几个问题:
* 不支持多平台
* 投稿线路对国外不友好,速度较慢稳定性较差
* 不能批量选择文件,多p只能一个一个文件选择

## Single-page app mode

By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.

If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:

```js
"start": "sirv public --single"
```

## Using TypeScript

This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:

```bash
node scripts/setupTypeScript.js
```

Or remove the script via:

```bash
rm scripts/setupTypeScript.js
```

If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte).

## Deploying to the web

### With [Vercel](https://vercel.com)

Install `vercel` if you haven't already:

```bash
npm install -g vercel
```

Then, from within your project folder:

```bash
cd public
vercel deploy --name my-project
```

### With [surge](https://surge.sh/)

Install `surge` if you haven't already:

```bash
npm install -g surge
```
---
![login](biliup-img/login.png)
![main](biliup-img/main.png)

Then, from within your project folder:
## Roadmap

```bash
npm run build
surge public my-project.surge.sh
```
- [ ] 上传视频封面
- [ ] 自由切换投稿线路
- [ ] 设置投稿并发数
- [ ] 多p按照文件名排序
- [ ] 远程部署agent,本地操作
- [ ] 插件系统,如自动录播后上传
Binary file added biliup-img/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added biliup-img/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ async-stream = "0.3.2"
cookie = "0.15.1"
url = "2.2.2"
serde_yaml = "0.8"
reqwest-middleware = "0.1.1"
reqwest-retry = "0.1.1"

[features]
default = [ "custom-protocol" ]
Expand Down
15 changes: 8 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use std::cell::Cell;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use anyhow::{anyhow, bail};
use anyhow::{anyhow, bail, Context};
use app::error::Result;
use app::{Account, Config, User};
use app::video::{BiliBili, Client, LoginInfo, Studio, Video};
Expand All @@ -18,16 +18,17 @@ fn login(username: &str, password: &str, remember_me: bool) -> Result<String> {
if remember_me {
match load() {
Ok(mut config) => {
let file = std::fs::File::open("config.yaml")?;
let file = std::fs::File::create("config.yaml").with_context(||0)?;
config.user.account.username = username.into();
config.user.account.password = password.into();
serde_yaml::to_writer(file, &config)?
serde_yaml::to_writer(file, &config).with_context(||1)?
}
Err(_) => {
let file = std::fs::File::create("config.yaml")?;
serde_yaml::to_writer(file, &User{
account: Account{ username: username.into(), password: password.into() }
})?
let file = std::fs::File::create("config.yaml").with_context(||2)?;
serde_yaml::to_writer(file, &Config{
user: User {account: Account{ username: username.into(), password: password.into() }},
streamers: Default::default()
}).with_context(||3)?
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions src-tauri/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use async_stream::try_stream;
use md5::{Digest, Md5};
use cookie::Cookie;
use base64::{encode};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_retry::policies::ExponentialBackoff;
use reqwest_retry::RetryTransientMiddleware;
use url::form_urlencoded;
// use std::borrow::Borrow;

Expand Down Expand Up @@ -72,14 +75,19 @@ impl Video {
}

pub struct BiliBili {
client: reqwest::Client,
client: ClientWithMiddleware,
login_info: LoginInfo,
}

impl BiliBili {
pub fn new((login, login_info): (Client, LoginInfo)) -> BiliBili {
let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
let client = ClientBuilder::new(login.client)
// Retry failed requests.
.with(RetryTransientMiddleware::new_with_policy(retry_policy))
.build();
BiliBili{
client: login.client,
client,
login_info
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/Login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
isLogin.set(true);
console.log(`Message: ${res}`)
}).catch((e) => {
e = JSON.parse(e);
createPop(e, 5000);
console.log(e);
// e = JSON.parse(e);
// {"code":0,"data":{"cookie_info":null,"message":
// "本次登录环境存在风险, 需使用手机号进行验证或绑定",
// "sso":null,"status":2,
Expand All @@ -76,8 +79,7 @@
// const webview = new WebviewWindow('theUniqueLabel', {
// url: e.data.url
// })
createPop(JSON.stringify(e), 5000);
console.log(e);
// createPop(JSON.stringify(e), 5000);
})
}
Expand Down
Loading

0 comments on commit eabe7cb

Please sign in to comment.