TikTokPrinter.tiktok package

Submodules

TikTokPrinter.tiktok.http module

Copyright (C) Isaac Kogan, Inc - All Rights Reserved Unauthorized copying of this project, via any medium is strictly prohibited Proprietary work of Isaac Kogan Written by Isaac Kogan <isaacikogan@gmail.com>, April 2022

You are permitted to use this project commercially so long as it was purchased firsthand from Isaac Kogan. Distributing secondhand copies to others is strictly prohibited & is illegal.

You can do anything with this project except redistribute it.

class TikTokPrinter.tiktok.http.GiftImage(gift: TikTokLive.types.objects.Gift)

Bases: TikTokPrinter.tiktok.http.ProfileImage

GiftImage HTTP Scraping Object

property url: str

Get their profile picture URL

Returns

The URL

class TikTokPrinter.tiktok.http.ProfileImage(user: Optional[TikTokLive.types.objects.User], index: int = 0)

Bases: object

ProfileImage HTTP Scraping Object

DEFAULT_REQUEST_HEADERS: Dict[str, str] = {"'Cache-Control'": 'max-age=0', "'User-Agent'": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36', 'Accept': 'content/html,application/json,application/protobuf', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.9', 'Connection': 'keep-alive', 'Origin': 'https://www.tiktok.com', 'Referer': 'https://www.tiktok.com/', 'accept': 'application/json, content/plain, */*', 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9', 'authority': 'm.tiktok.com', 'scheme': 'https', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', 'sec-fetch-site': 'none', 'sec-gcp': '1'}

Default headers for making TikTok Requests

static generate_device_id() str

Generates a valid device_id for requests

async to_bytes(custom_headers: dict = {}, proxies: Optional[List] = []) Optional[bytes]

Turn a profile image object to bytes

Parameters
  • proxies – List of proxies (picks a random one)

  • custom_headers – Custom headers if necessary

Returns

Image in bytes

async to_download(path: str, custom_headers: dict = {}, proxies: Optional[List] = []) bool

Download an image to a given file path

Parameters
  • proxies – List of proxies (picks a random one)

  • path – Path to download to

  • custom_headers – Custom headers if necessary

Returns

Whether it downloaded successfully

property url: str

Get their profile picture URL

Returns

The URL

TikTokPrinter.tiktok.media module

Copyright (C) Isaac Kogan, Inc - All Rights Reserved Unauthorized copying of this project, via any medium is strictly prohibited Proprietary work of Isaac Kogan Written by Isaac Kogan <isaacikogan@gmail.com>, April 2022

You are permitted to use this project commercially so long as it was purchased firsthand from Isaac Kogan. Distributing secondhand copies to others is strictly prohibited & is illegal.

You can do anything with this project except redistribute it.

class TikTokPrinter.tiktok.media.TikTokMedia

Bases: object

TikTokMedia formatting class providing utilities to format various media

async classmethod gift_image(gift: TikTokLive.types.objects.Gift, size: int = 200) <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>

Download a gift image

Parameters
  • gift – The gift object

  • size – The size to return the image as

Returns

The gift image

classmethod mask_circle_transparent(original: <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>, blur_radius: int, offset: int = 0) <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>

Crop image into circle with a transparent background Via https://note.nkmk.me/en/python-pillow-square-circle-thumbnail/

Parameters
  • original – Image to crop

  • blur_radius – Radius for blur (intensity)

  • offset – Image offset

Returns

New Image

classmethod remove_transparency(image: <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>, background: typing.Tuple[int, int, int] = (255, 255, 255)) <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>

Remove transparency from an RGBA image

Parameters
  • image – The image to remove transparency from

  • background – The colour for the new background

Returns

The transformed image

async classmethod user_image(user: TikTokLive.types.objects.User, size: int = 200, circle: bool = True, circle_blur_radius: int = 3) <module 'PIL.Image' from 'c:\\users\\jeanm\\pycharmprojects\\printertwo\\venv\\lib\\site-packages\\PIL\\Image.py'>

Download a user’s profile image

Parameters
  • user – The user to download the image for

  • size – The size to return the image as

  • circle – Whether to crop the image into a circle

  • circle_blur_radius – If cropping into a circle, add an optional blur around the crop area (looks nicer)

Returns

The user’s profile image

Module contents

Copyright (C) Isaac Kogan, Inc - All Rights Reserved Unauthorized copying of this project, via any medium is strictly prohibited Proprietary work of Isaac Kogan Written by Isaac Kogan <isaacikogan@gmail.com>, April 2022

You are permitted to use this project commercially so long as it was purchased firsthand from Isaac Kogan. Distributing secondhand copies to others is strictly prohibited & is illegal.

You can do anything with this project except redistribute it.