biliarchiver/README.md

122 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2023-06-02 13:32:11 -07:00
# biliarchiver
2023-06-02 12:12:24 -07:00
2023-10-16 01:38:47 -07:00
> Archiving tool for Bilibili based on bilix
[![PyPI version](https://badge.fury.io/py/biliarchiver.svg)](https://badge.fury.io/py/biliarchiver)
2023-07-06 09:33:59 -07:00
## Install
```bash
pip install biliarchiver
```
## Usage
2023-08-16 11:56:03 -07:00
```bash
biliarchiver --help
```
2023-10-16 01:58:53 -07:00
### Basic usage
2023-08-16 11:56:03 -07:00
Follow these steps to start archiving:
1. Initialize a new workspace in current working directory:
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
```bash
biliarchiver init
```
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
2. Provide cookies and tokens following instructions:
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
```bash
biliarchiver auth
```
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
3. Download videos from BiliBili:
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
```bash
biliarchiver down --bvids BVXXXXXXXXX
```
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
- This command also accepts a list of BVIDs or path to a file. Details can be found in `biliarchiver down --help`.
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
4. Upload videos to Internet Archive:
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
```bash
biliarchiver up --bvids BVXXXXXXXXX
```
2023-10-16 01:58:53 -07:00
2023-08-16 11:56:03 -07:00
- This command also accepts a list of BVIDs or path to a file. Details can be found in `biliarchiver up --help`.
2023-10-16 01:58:53 -07:00
### Rest API
1. Start server
```bash
biliarchiver api
```
2. Add videos
```bash
curl -X PUT -H "Content-Type: application/json" http://127.0.0.1:8000/archive/BVXXXXXX
```
2023-08-16 11:56:03 -07:00
## Develop
### Install
Please use poetry to install dependencies:
```sh
poetry install
```
2023-08-16 12:17:56 -07:00
Build English locale if necessary. Refer to the last section for details.
2023-08-16 11:56:03 -07:00
### Run
```sh
poetry run biliarchiver --help
```
Debug using another workspace:
```sh
poetry --directory /path/to/workspace run biliarchiver --help
```
2023-08-16 11:56:03 -07:00
### Lint
```sh
poetry run ruff check .
```
### i18n
2023-08-16 12:17:56 -07:00
To generate and build locales, you need a GNU gettext compatible toolchain. You can install `mingw` and use `sh` to enter a bash shell on Windows.
Generate or update `biliarchiver.pot`:
2023-08-16 11:56:03 -07:00
```sh
find biliarchiver/ -name '*.py' | xargs xgettext -d base -o biliarchiver/locales/biliarchiver.pot
```
Add a new language:
```sh
msginit -i biliarchiver/locales/biliarchiver.pot -o en.po -l en
```
Update a language:
```sh
pnpx gpt-po sync --po biliarchiver/locales/en/LC_MESSAGES/biliarchiver.po --pot biliarchiver/locales/biliarchiver.pot
```
2023-08-16 12:17:56 -07:00
**(Important)** Build a language:
2023-08-16 11:56:03 -07:00
```sh
msgfmt biliarchiver/locales/en/LC_MESSAGES/biliarchiver.po -o biliarchiver/locales/en/LC_MESSAGES/biliarchiver.mo
```