Skip to main content

Douyu Live Stream Danmu Collector - async library and CLI for collecting chat messages.

Project description

dycap

Douyu Live Stream Danmu Collector - async library and CLI for collecting chat messages.

Installation

pip install dycap

Quick Start

CLI

# Collect to PostgreSQL (default)
export DYKIT_DSN="postgresql://user:pass@localhost:5432/douyu"
dycap -r 6657

# Collect to CSV
dycap -r 6657 --storage csv -o backup.csv

# Collect to console
dycap -r 6657 --storage console

# Show version
dycap --version

Python API

import asyncio
from dycap import AsyncCollector, PostgreSQLStorage

async def main():
    storage = await PostgreSQLStorage.create(
        room_id="6657",
        host="localhost",
        port=5432,
        database="douyu",
        user="douyu",
        password="pass"
    )
    
    async with storage:
        collector = AsyncCollector("6657", storage)
        try:
            await collector.connect()
        except KeyboardInterrupt:
            await collector.stop()

asyncio.run(main())

Features

  • Async WebSocket collection - High-performance async collection
  • Multiple storage backends - PostgreSQL, CSV, Console
  • Batch writes - Optimized PostgreSQL with buffered batch inserts
  • Type filtering - Filter message types to collect
  • Automatic reconnection - Robust connection handling

CLI Options

Option Description
-r, --room Room ID (required)
--dsn PostgreSQL DSN
--storage Storage backend (postgres/csv/console)
-o, --output Output file for CSV
-v, --verbose Enable verbose logging
--with TYPES Include only specified message types (comma-separated). Available: chatmsg(弹幕), dgb(礼物), uenter(进场), anbc(开通贵族), rnewbc(续费贵族), blab(粉丝牌升级), upgrade(等级升级)
--without TYPES Exclude specified message types (comma-separated), same candidate set as --with

Environment Variables

Variable Description
DYKIT_DSN PostgreSQL connection string
DYCAP_DSN Alias for DYKIT_DSN

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dycap-0.1.2.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dycap-0.1.2-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file dycap-0.1.2.tar.gz.

File metadata

  • Download URL: dycap-0.1.2.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dycap-0.1.2.tar.gz
Algorithm Hash digest
SHA256 73795afe68881f5d2a620b0628421b5fa5bb26e7e479c79e94345149ff361d7a
MD5 389a44ecabf7e8d553e29c1fad176ff2
BLAKE2b-256 97dedefc8dc4044451db7b6bd90c7407561946f8d45ab7862d135d3aa9f7bcf3

See more details on using hashes here.

File details

Details for the file dycap-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dycap-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dycap-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 646bb051ae6575f2c22dce17db7827d65d26832215aa6ebf5ec468a58bf1dd67
MD5 eed6d960bd10c2d45f7a7018b9f7c893
BLAKE2b-256 e2ece387830cc5b002646165e2f6dc1aa51c24e8611307c0ac3bb08aacfbe0f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page