bilistream

repository·main·Indexed 41 days ago

https://github.com/limitcool/bilistream

A self-hosted automation tool for monitoring live streams on Twitch and YouTube and automatically re-streaming them to Bilibili using FFmpeg. Version 0.2.0 features a Web Console for remote management, support for Gotify and ntfy notifications, and deployment options via Docker or as a Linux binary.

Tokens
6.4K
Snippets
22
Records
31
Agent score
50%

What's inside bilistream

  1. Web Console Capabilities

    main

    The Web Console provides a remote interface to manage your bilistream instance, including:

    • Monitoring: View status for monitoring, origin servers, Bilibili, and FFmpeg.
    • Notifications: View notification strategies and toggle channel switches.
    • Configuration: Edit config.yaml online.
    • Control: Remotely start/stop monitoring and reload configurations.
    • Logs: View recent execution logs.
    • System Info: View version number and GitHub repository links.
  2. Configure Notification Strategies

    main

    bilistream supports multiple notification channels and a hierarchical toggle system.

    Supported Channels (Notification.Channel):

    • gotify
    • ntfy
    • both (sends to both services)

    Toggle Hierarchy: Notifications are controlled by a master switch and individual channel switches. All active switches must be true for a notification to be sent via a specific channel:

    1. Notification.Enabled: The master switch for all notifications.
    2. Notification.GotifyEnabled: Specific switch for Gotify.
    3. Notification.NtfyEnabled: Specific switch for ntfy.
  3. Run bilistream as a binary

    main

    To run the bilistream binary directly on Linux, you must ensure the following dependencies are installed on your system:

    • ffmpeg
    • python3
    • yt-dlp (installed via pip)

    Installation steps for dependencies:

    apt update
    apt install -y ffmpeg python3 python3-pip
    pip3 install -U yt-dlp

    Execution:

    ./bilistream
  4. Use the Web Console

    main

    The built-in Web Console allows for remote management of bilistream. It is accessible via the address configured in WebConsole.Addr (default 0.0.0.0:9090).

    Capabilities:

    • Monitoring: View status for the source site, Bilibili, FFmpeg, and notifications.
    • Control: Remotely start/stop monitoring or reload the configuration.
    • Configuration: Edit config.yaml directly in the browser.
    • Logs: View recent execution logs.
    • Information: View current version and GitHub repository links.
  5. Deploy bilistream with Docker

    main

    You can deploy bilistream using Docker. Ensure you map the port 9090 to access the Web Console and mount your config.yaml as a writable volume so the console can save changes online.

    Important: The cookies.txt volume should be mounted as read-only (:ro) if it is only used for authentication context.

    services:
      bilistream:
        image: ghcr.io/limitcool/bilistream:v0.2.0
        restart: unless-stopped
        ports:
          - "9090:9090"
        volumes:
          - ./config.yaml:/app/config.yaml
          - ./cookies.txt:/app/cookies.txt:ro
  6. Deploy bilistream via Docker

    main

    The recommended way to run bilistream is using Docker, as the image includes all necessary dependencies like ffmpeg, python3, and yt-dlp.

    To deploy, create a docker-compose.yml file with the following configuration. Note that config.yaml must be mounted as a writable volume because the application writes configuration changes directly to it. cookies.txt is optional and should be mounted as read-only (:ro) if you need to provide login credentials for stream pulling.

    Important Notes:

    • The Web Console listens on 0.0.0.0:9090 by default.
    • Ensure config.yaml is not mounted as read-only.
    services:
      bilistream:
        image: ghcr.io/limitcool/bilistream:v0.2.0
        container_name: bilistream
        restart: unless-stopped
        ports:
          - "9090:9090"
        volumes:
          - ./config.yaml:/app/config.yaml
          - ./cookies.txt:/app/cookies.txt:ro

    To start the service:

    docker compose up -d

    To view logs:

    docker compose logs -f
  7. Access the bilistream Web Console

    main

    Starting from v0.2.0, bilistream includes a built-in Web Console for remote management. By default, the console listens on 0.0.0.0:9090. You can access it via your browser at http://<your-server-ip>:9090.

    To restrict access to the local machine only, change the WebConsole.Addr setting in your configuration to 127.0.0.1:9090.

    WebConsole:
      Addr: 0.0.0.0:9090
  8. Configure Notification Channels

    main

    Notifications can be sent via Gotify, Ntfy, or both. Use the Notification section as a master switch and the specific provider sections for credentials.

    Key Configuration Fields:

    • Notification.Enabled: Global toggle for all notifications.
    • Notification.Channel: Determines the target. Supported values: gotify, ntfy, or both.
    • Notification.GotifyEnabled / Notification.NtfyEnabled: Individual toggles for specific channels.

    Provider Settings:

    • Gotify: Requires Url and Token.
    • Ntfy: Requires Url and Topic. Supports optional Token, Username, Password, Priority, and Tags.
    Notification:
      Enabled: true
      Channel: both
      GotifyEnabled: true
      NtfyEnabled: true
    
    Gotify:
      Url: https://gotify.example.com
      Token: your-token
    
    Ntfy:
      Url: https://ntfy.sh
      Topic: bilistream-live
      Token: ""
      Username: ""
      Password: ""
      Priority: default
      Tags: bilistream,live
  9. Configure Web Console Authentication

    main

    The Web Console uses Basic Auth configured in config.yaml.

    • To enable authentication, provide a Username and Password under the WebConsole section.
    • If Password is left empty, authentication is disabled.
    • Security Note: Do not expose a console without a password to the public internet. If the program detects public listening with an empty password during startup, it will automatically generate a random password and write it to config.yaml.
    • If no config.yaml exists on first startup, the program will automatically initialize one.
    WebConsole:
      Addr: 0.0.0.0:9090
      Username: admin
      Password: change-me
  10. Configure bilistream via config.yaml

    main

    bilistream uses a single config.yaml file for all settings. If the file is missing at startup, the program will automatically initialize a default configuration.

    Security Note: If WebConsole.Addr is set to a public address and the password is empty, the program will automatically generate a random password and write it back to the config. The startup logs will notify you that a password was generated, but the password itself will not be printed in plain text in the logs.

    Configuration Schema Reference:

    • Interval: Monitoring interval.
    • Platform: The source platform (e.g., Twitch).
    • BiliLive: Bilibili credentials and stream settings:
      • SESSDATA, bili_jct, DedeUserID, DedeUserID__ckMd5: Bilibili cookies.
      • Room: Bilibili Room ID.
      • BiliRtmpUrl: Bilibili RTMP URL.
      • BiliRtmpKey: Bilibili RTMP Key.
    • Twitch: Room (Twitch username/room).
    • Youtube: Room and AccessToken.
    • YoutubePreviewLive: ChannelId.
    • FfmpegProxy: Proxy settings for FFmpeg.
    • Cookies: Path to cookies file.
    • Notification: Notification settings (see Notification Strategies).
    • Gotify: Url and Token.
    • Ntfy: Url, Topic, Token, Username, Password, Priority, Tags.
    • WebConsole: Addr, Username, Password.
    Interval: 60
    Platform: Twitch
    
    BiliLive:
      SESSDATA: ""
      bili_jct: ""
      DedeUserID: ""
      DedeUserID__ckMd5: ""
      Room: 0
      BiliRtmpUrl: "rtmp://live-push.bilivideo.com/live-bvc/"
      BiliRtmpKey: ""
    
    Twitch:
      Room: ""
    
    Youtube:
      Room: ""
      AccessToken: ""
    
    YoutubePreviewLive:
      ChannelId: ""
    
    FfmpegProxy: ""
    Cookies: ""
    
    Notification:
      Enabled: true
      Channel: gotify
      GotifyEnabled: true
      NtfyEnabled: false
    
    Gotify:
      Url: ""
      Token: ""
    
    Ntfy:
      Url: "https://ntfy.sh"
      Topic: ""
      Token: ""
      Username: ""
      Password: ""
      Priority: ""
      Tags: ""
    
    WebConsole:
      Addr: "0.0.0.0:9090"
      Username: "admin"
      Password: ""
  11. YouTube stream monitoring requirements

    main

    The YouTube platform implementation for bilistream relies on the external yt-dlp binary to resolve live stream URLs. To ensure successful stream monitoring and URL extraction, yt-dlp must be installed and available in your system's PATH.

    If you are monitoring channels that require authentication (e.g., age-restricted content), you must provide a path to a cookies file in your configuration.

  12. Requirements for Twitch monitoring

    main

    To use the Twitch plugin for stream monitoring and URL extraction, the following must be true:

    1. yt-dlp: The yt-dlp binary must be installed and available in your system's PATH.
    2. Cookies (Optional): If the stream requires authentication or specific access, ensure the cookies field in your Config points to a valid cookie file path. This path is passed to the yt-dlp command.