Giter Club home page Giter Club logo

amcp-pylib's Introduction

Python AMCP Client Library

v0.2.2

Build Status PyPI PyPI Support Project

Introduction

Welcome to the AMCP client library repository for Python! The goal of this library is to provide simple and understandable interface for communication with CasparCG server.

Installation

pip install amcp_pylib

Usage examples

Below you can see various usage examples.

Connecting to server

from amcp_pylib.core import Client

client = Client()
client.connect("caspar-server.local", 6969)  # defaults to 127.0.0.1, 5250

Built-in support for asyncio module:

import asyncio
from amcp_pylib.core import ClientAsync

client = ClientAsync()
asyncio.new_event_loop().run_until_complete(client.connect("caspar-server.local", 6969))

Sending commands

from amcp_pylib.core import Client
from amcp_pylib.module.query import VERSION, BYE

client = Client()
client.connect()

response = client.send(VERSION(component="server"))
print(response)

response = client.send(BYE())
print(response)
<SuccessResponse(data=['2.0.7.e9fc25a Stable'],    code=201, code_description='VERSION')>
<InfoResponse(   data=['SERVER SENT NO RESPONSE'], code=0,   code_description='EMPTY')>

All supported protocol commands are listed and documented on CasparCG's wiki pages. Some commands may not be supported yet (in that case, please create issue (or pull ;) request).

amcp-pylib's People

Contributors

dependabot[bot] avatar dolejska-daniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amcp-pylib's Issues

asyncio problem

Hello.
First of all, thank you for your work on your library.
Great to be able to use this tool.
However, I have a problem with your library.
When I use:

from amcp_pylib.core import Client

client = Client()
client.connect('192.168.0.10', 5250)

Everything is OK
but
When I use:

import asyncio
from amcp_pylib.core import ClientAsync

client = ClientAsync()
asyncio.new_event_loop().run_until_complete(client.connect('192.168.0.10', 5250))

i get an error message:

venv/lib/python3.11/site-packages/amcp_pylib/core/connection_async.py:21: RuntimeWarning: coroutine 'ConnectionAsync.connect' was never awaited
  self.connect(address_info[0], address_info[4])
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

I also tried using it as follows however I was getting the same error.

import asyncio
from amcp_pylib.core import ClientAsync

async def connect():
    client = ClientAsync()
    await client.connect('192.168.0.10', 5250)

async def main():
    task = connect()
    try:
        await asyncio.wait_for(task, timeout= 4.0)
    except asyncio.TimeoutError:
        print('Gave up waiting, task canceled')
    except Exception as e:
        print(f'Task failed with: {e}')

asyncio.run(main())

normalization_extra_whitespace causes whitespace loss in data

I am passing data that is in Markdown format, and the normalization_extra_whitespace function is removing double spaces at the end of lines.

Is there a way of igoring the data part of the command when normalizing the whitespace in the command?

Example of use with CG_ADD

I don't know what I miss but I'm unable to use the CG_ADD command.

I've tried:

response = client.send(CG_ADD("CG 1 ADD 0 COUNTDOWN 1"))

And I'm getting:

RuntimeError: Command functions do not accept any positional arguments.

Thanks for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.