Skip to content

Commit

Permalink
Updated for TikTok-API V3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
davidteather committed May 10, 2020
1 parent 059ecab commit c33a5ce
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 26 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This project downloads the trending tiktok videos and compiles them into a video.

**Note** follow the installation instructions for the used api [TikTok-API](https://github.com/davidteather/TikTok-Api).


**NOTE** This project will most likely be behind my TikTok-API. Adapt that to use FFMpeg if you want a better experience [TikTok-API](https://github.com/davidteather/TikTok-Api). I will still update this just it will most likely be a few updates behind that other repo.

Expand All @@ -14,13 +12,11 @@ These instructions will get you a copy of the project up and running on your loc
### Installing and Prerequisites

You need to have ffmpeg installed and in your path variable, tutorial [here](https://www.thewindowsclub.com/how-to-install-ffmpeg-on-windows-10).
Also, make sure you have in the directory of tiktokbot.py folders called output and downloaded.

You will also have to follow the instructions [here](https://github.com/davidteather/TikTok-Api) for installing the unofficial tiktok-api

Python Requirements
```
pip install requests
pip install TikTokApi
```

Expand All @@ -40,6 +36,7 @@ python tiktokbot.py
## Built With

* [FFmpeg](https://ffmpeg.org/) - The tool used for video editing
* [TikTok-API](https://github.com/davidteather/TikTok-Api) - My own API for TikTok.

## Authors

Expand Down
Empty file.
Empty file removed output/outputfolder.txt
Empty file.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
TikTokApi
requests
TikTokApi
30 changes: 10 additions & 20 deletions tiktokbot.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
# Json Response https://m.tiktok.com/share/item/list?id=&type=5&count=48&minCursor=0&maxCursor=0&_signature=z9nIxxAWkszGlbLSXGTDqM.ZyN
# obj -> body -> itemListData -> itemListData[i] -> itemInfos -> video -> urls[0] gives downloadable url
import requests
import random
import string
import urllib.request
import glob
import os
import mimetypes
from TikTokApi import TikTokapi

import glob
from TikTokApi import TikTokApi

def clearTMP(delpath):
r = glob.glob(delpath)
for i in r:
os.remove(i)

if not os.path.exists("downloaded"):
os.mkdir('downloaded')

if not os.path.exists("output"):
os.mkdir("output")

clearTMP('output/output.mp4')

# Vars
count = 30
api = TikTokapi("browsermob-proxy/bin/browsermob-proxy")
api = TikTokApi()

results = api.trending(count=count)
prevloops = 0
for res in results:
r = requests.get(res["itemInfos"]["video"]["urls"][0], allow_redirects=False)
content_type = r.headers['content-type']
extension = mimetypes.guess_extension(content_type)
open('downloaded/' + str(prevloops) +
extension, "wb").write(r.content)
".mp4", "wb").write(api.get_Video_By_TikTok(res))
open("downloaded/concat.txt", 'a').write("file " +
str(prevloops) + ".mkv" + "\n")
os.system("ffmpeg -loglevel panic -i downloaded/" + str(prevloops) +
extension + " -c copy -map 0 downloaded/" + str(prevloops) + ".mkv")
".mp4" + " -c copy -map 0 downloaded/" + str(prevloops) + ".mkv")
prevloops += 1

api.quit_browser()

# concat errors
# ffmpeg -f concat -i downloaded/concat.txt -safe 1 -r 30 -fflags +genpts -c:a copy output.mp4
os.system("ffmpeg -f concat -i downloaded/concat.txt -safe 1 -r 30 -fflags +genpts -c:a copy downloaded/output.mp4")
os.system('''ffmpeg -loglevel error -r 30 -i resources/bkg.png -i downloaded/output.mp4 -b:v 1M -filter_complex ''' +
'''"[1:v]scale=''' + "750" +
Expand Down

0 comments on commit c33a5ce

Please sign in to comment.