Metadata-Version: 2.4
Name: tiktok-sdk
Version: 0.1.0
Summary: A Python library for interacting with tiktok's metadata and downloading video's.
Author: im-lemon
License: MIT
Project-URL: Homepage, https://github.com/im-lemon/tiktok
Project-URL: Repository, https://github.com/im-lemon/tiktok
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: bs4
Dynamic: license-file

# tiktok

A python library that uses requests to fetch data from tiktok videos, it works by sending requests to tiktok walking down it's internal paths, and returns json data!

It can also download tiktok videos, by using the ```download_video()``` function. it works by using data from ```get_metadata()```function, which returns the data walked from tiktok's video metadata, which also contains video data. It sends a request to the cdn url!

The library bypasses bot protection by using an (ai-generated) user-agent that succesfully bypasses CDN using ```requests.session.get()```.

## Usage:

It is easy to use the library by importing the ```TikTok``` class. Or, if you want control over **everything**, you can use the internal functions, since the TikTok class is just a wrapper around said internal functions.

to use internal functions:

```python
from tiktok.fetcher import ttAPIFetcher
from tiktok.parser import ttAPIParser

parser = ttAPIParser()
fetcher = ttAPIFetcher()

unparsed = fetcher.get_metadata(url) # returns r.text

parsed = parser.parse(unparsed) # uses beautifulsoup to search for the metadata.
# returns the walked directory so you can just do:

title = parsed["title"]
author_nickname = parsed["author"]["nickname"]
print(title)
print(author_nickname)

# Download a video:

fetcher.download_video(data=parsed, output_file="name.mp4")

```

Use TikTok class:

```python
from tiktok import TikTok

tt = TikTok()

data = tt.get_metadata(url) # does parsing for you and returns parsed data!

title = data["desc"]
author_nickname = data["author"]["nickname"]

# download a video:

tt.download_video(url, output_file="name.mp4") # defaults to "downloaded.mp4". Handles data extraction internally.
```

## Installation:

```bash
pip install tiktok-sdk
```
