Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/*
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.8-slim

LABEL maintainer="timerring"

WORKDIR /app

COPY . /app

RUN apt-get update && apt-get install -y ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV TZ="Asia/Shanghai"

CMD ["python", "-m", "looplive.main"]
48 changes: 36 additions & 12 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

[简体中文](./README.md) | English

> Welcome to `looplive`! We appreciate your feedback and contributions through PRs. Please do not use this project for purposes that violate community guidelines.
> Welcome to use, provide more feedback, and contribute to this project via PR. Please do not use it for purposes that violate community regulations.

`looplive` is a fully automated 24/7 live streaming tool, with plans to support more platforms in the future.
`looplive` is a 24/7 fully automated looping live streaming tool, expected to support more platforms.

The Python toolkit package and cli designed for auto loop live.
The Python toolkit package and CLI designed for auto loop live.

## Prerequisites
## Preparation

First, ensure that you have the `ffmpeg` tool installed on your machine.
First, you need to have the `ffmpeg` tool installed on your machine.

- Ubuntu

Expand All @@ -24,19 +24,19 @@ sudo apt update && apt install ffmpeg -y
brew install ffmpeg
```

- Windows and other platforms: Please refer to the [official page](https://www.ffmpeg.org/download.html).
- Windows and more platforms: Please refer to the [official page](https://www.ffmpeg.org/download.html).
- Python >= 3.8

## Usage
## Quick Start

### Start Streaming
### Start Live Streaming

1. Go to the [live streaming page](https://link.bilibili.com/p/center/index#/my-room/start-live).
- If you do not have live streaming permissions, please apply first by clicking `Activate Live Room`, and follow the instructions provided by Bilibili.
- If you do not have live streaming permissions, please apply first by clicking `Activate Live Room Now`, and then follow the prompts from Bilibili.
2. Click `Start Live`.
3. Obtain the streaming server address `-s` and the stream key `-k`.
3. Obtain the streaming server address `-s` and stream key `-k`.

### Quick Start
### Streaming

> To avoid command parameters being incorrectly separated, please wrap each parameter in English double quotes `"`. The parameter `-f` is the folder where the video files are stored.

Expand All @@ -46,14 +46,38 @@ looplive add -s "rtmp://xxxxxxxx" -k "?streamname=xxxxxxxx" -f "your/folder/path
looplive bili
```

## Docker Deployment

### Configuration File

The `bili_server_url` and `bili_key` in the `config.json` file need to be obtained from the [live streaming page](https://link.bilibili.com/p/center/index#/my-room/start-live).

```json
{
"folder": "/app/looplive/videos",
"bili_server_url": "rtmp://xxxxxxx",
"bili_key": "?streamname=xxxxxxxxxxxxxx"
}
```

### Running

```bash
sudo docker run -it \
-v /your/path/to/config.json:/app/looplive/model/config.json \
-v /your/path/to/videos:/app/looplive/videos \
--name looplive_docker \
ghcr.io/timerring/looplive:0.0.1
```

### More Usage

```bash
$ looplive -h

looplive [-h] [-V] {check,add,reset,bili} ...

The Python toolkit package and cli designed for auto loop live.
The Python toolkit package and CLI designed for auto loop live.

positional arguments:
{check,add,reset,bili}
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ brew install ffmpeg
- Windows 和更多平台: 请参考 [官方页面](https://www.ffmpeg.org/download.html).
- Python >= 3.8

## 使用
## 快速开始

### 开始直播

Expand All @@ -36,7 +36,7 @@ brew install ffmpeg
2. 点击 `开始直播`.
3. 获取推流服务器地址 `-s` 和串流密钥 `-k`。

### 快速开始
### 推流

> 为了避免命令参数被错误分隔,请使用英文双引号 `"` 包裹每一项参数。参数 `-f` 是视频文件的存放文件夹。

Expand All @@ -46,6 +46,30 @@ looplive add -s "rtmp://xxxxxxxx" -k "?streamname=xxxxxxxx" -f "your/folder/path
looplive bili
```

## Docker 部署

### 配置文件

`config.json` 文件中 `bili_server_url` 和 `bili_key` 需要从 [直播页面](https://link.bilibili.com/p/center/index#/my-room/start-live) 获取。

```json
{
"folder": "/app/looplive/videos",
"bili_server_url": "rtmp://xxxxxxx",
"bili_key": "?streamname=xxxxxxxxxxxxxx"
}
```

### 运行

```bash
sudo docker run -it \
-v /your/path/to/config.json:/app/looplive/model/config.json \
-v /your/path/to/videos:/app/looplive/videos \
--name looplive_docker \
ghcr.io/timerring/looplive:0.0.1
```

### 更多用法

```bash
Expand Down
5 changes: 3 additions & 2 deletions looplive/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def cli():
ConfigController().reset_config()

if args.subcommand == 'bili':
if ConfigController().check_config():
BiliController().stream()
cc = ConfigController()
if cc.check_config():
BiliController(cc).stream()
else:
print("Please complete the configuration first!", flush=True)

Expand Down
11 changes: 5 additions & 6 deletions looplive/controller/bili_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import subprocess
from looplive.execute.scan_and_execute import scan_folder_and_execute
from looplive.model.model import Model
from looplive.controller.config_controller import ConfigController

class BiliController:
def __init__(self):
self.model = Model()
self.server_url = self.model.get_config()['bili_server_url']
self.key = self.model.get_config()['bili_key']
self.folder = self.model.get_config()['folder']
def __init__(self, cc: ConfigController):
self.server_url = cc.get_config()['bili_server_url']
self.key = cc.get_config()['bili_key']
self.folder = cc.get_config()['folder']

@property
def stream_url(self):
Expand Down
4 changes: 2 additions & 2 deletions looplive/controller/config_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from looplive.model.model import Model

class ConfigController:
def __init__(self):
self.model = Model()
def __init__(self, path=None):
self.model = Model(path=path)

def check_config(self):
config_info = self.model.get_config()
Expand Down
12 changes: 12 additions & 0 deletions looplive/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
from looplive.model.model import Model
from looplive.controller.config_controller import ConfigController
from looplive.controller.bili_controller import BiliController

if __name__ == '__main__':
path = os.path.join(os.path.dirname(__file__), 'model/config.json')
cc = ConfigController(path=path)
if cc.check_config():
BiliController(cc).stream()
else:
print("Please complete the configuration first!")
5 changes: 0 additions & 5 deletions looplive/model/config.json

This file was deleted.