Giter Club home page Giter Club logo

Comments (3)

isaackogan avatar isaackogan commented on May 28, 2024
import asyncio
import logging

from TikTokLive import TikTokLiveClient
from TikTokLive.events import ConnectEvent

client: TikTokLiveClient = TikTokLiveClient(
    unique_id="https://www.tiktok.com/@jarretchambers/live"
)


@client.on(ConnectEvent)
async def on_connect(e: ConnectEvent):
    print(f"Connected to @{e.unique_id}")


async def run(retry_after: int = 60) -> None:
    """
    Loop forever.

    :param retry_after: How long to wait (sec) between retries
    :return: None

    """

    while True:

        # Wait for the client to go live 24/7
        while not await client.is_live():
            client.logger.info(f"The user has not livestreamed, try again in {retry_after} seconds")
            await asyncio.sleep(retry_after)

        # Connect once they're live
        try:
            await client.connect(callback=lambda: print("Live!"))
        except Exception:
            client.logger.info(f"The connection has been lost, retrying in 60 seconds... ")
            await asyncio.sleep(60)


if __name__ == '__main__':
    client.logger.setLevel(logging.INFO)
    asyncio.run(run())

from tiktoklive.

KalvinThien avatar KalvinThien commented on May 28, 2024

The problem is that after the connection the user is livestreaming, it will record automatically, but if that user turns off the livestream or pauses the livestream

then the program will try to connect again automatically, I tried many ways but when the user finished the livestream nothing happened, the program stood still without trying to connect to the livestream again (delay 60 seconds until reconnecting)

from tiktoklive.

isaackogan avatar isaackogan commented on May 28, 2024

Don't you think that's something you should've mentioned...?

Listen to the LiveEndEvent and manually disconnect. Also, stream pause is not the same as stream end.

from tiktoklive.

Related Issues (20)

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.