Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i download video ? #10

Closed
DevMensIT opened this issue Sep 19, 2019 · 11 comments
Closed

How can i download video ? #10

DevMensIT opened this issue Sep 19, 2019 · 11 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@DevMensIT
Copy link

hello there ,
i'm unaware of python but i'm looking for this.
how can i video download with URL and how can i get "video_id" using URL?

hope i will get some help from you.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.92. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the question Further information is requested label Sep 19, 2019
@davidteather davidteather added enhancement New feature or request and removed question Further information is requested labels Sep 19, 2019
@davidteather
Copy link
Owner

Are you talking about [itemInfos][id]?

Currently there’s no ability to get that json by a url. I’ll implement that feature either today or over the weekend.

@DevMensIT
Copy link
Author

can you please explain to me that how i get "video_id"(v12345679978912zxasd) ?
what should i have to call to get this file "ExTikTokResonse.json" response in php ?

@davidteather
Copy link
Owner

davidteather commented Sep 19, 2019

Since this is a python package you would have to create a python script that you could use the php exec command to execute the code and fetch the output of that program.

Here is example code of how to specify a search by hashtag and result number. Ex calling command

python TikTok-Api-CLI.py funny 10

Here is a link to the php exec command.

Another option is to use this python API to find the signature you need to make requests to their database, however that would still require integration to a python script.

A third option is that the python script finds the ExTikTokResponse.json and saves it to a file, then you load that file in php.

@davidteather davidteather added the question Further information is requested label Sep 19, 2019
@davidteather
Copy link
Owner

If you want to download the video in python here's example code

from TikTokApi import TikTokapi
import urllib.request
# Starts T
api = TikTokapi("path/to/browsermob-proxy")

# The Number of trending TikToks you want to be displayed
results = 1
trending = api.trending(results)

for tiktok in trending:
    # Prints the text of the tiktok
    videoURL = tiktok["itemInfos"]["video"]["urls"][2]
    urllib.request.urlretrieve(videoURL, 'video_name.mp4') 

@DevMensIT
Copy link
Author

sorry but i'm getting error of browsermob-proxy... i don't understand how to set that path. i already downloaded that.

@davidteather
Copy link
Owner

Download browsermob proxy and place it as such and change “path/to/browsermob-proxy” to be “browsermob-proxy”

If that doesn’t work try “browsermob-proxy/bin”

ProjectFolder
  - main.py
   - browsermob-proxy
       - bin

Google adding to path on whatever your operating system is.

Then add ProjectFolder/browsermob-proxy/bin to the path.

@DevMensIT
Copy link
Author

okay i will check it. thanks again.

@davidteather
Copy link
Owner

Updated main branch adding new release and pypi release in a few minutes.

@Lem0nTree
Copy link

Lem0nTree commented Oct 27, 2019

Trying to download hashtag videos with the api,


from TikTokApi import TikTokapi

# Starts The Api Class
api = TikTokapi("browsermob-proxy/bin/browsermob-proxy")

# The Number of trending TikToks you want to be displayed
results = 10

hashtag = ("meme")


result = api.search_by_hashtag(hashtag, results)

prevloops = 0

for tiktok in trending:
    # Prints the text of the tiktok
    videoURL = tiktok["itemInfos"]["video"]["urls"]
    videoname = "video" + str(prevloops) + ".mp4"
    urllib.request.urlretrieve(videoURL, videoname)
    prevloops += 1

but unfortunately get this error
File ".\testest.py", line 20, in <module> urllib.request.urlretrieve(videoURL, 'videoname.mp4') File "C:\Users\loren\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 245, in urlretrieve url_type, path = splittype(url) File "C:\Users\loren\AppData\Local\Programs\Python\Python37\lib\urllib\parse.py", line 940, in splittype match = _typeprog.match(url) TypeError: expected string or bytes-like object

Any advice on how to download videos based on hashtag?
Thank you very much ! @davidteather

@davidteather
Copy link
Owner

You're trying to download an array of urls try

from TikTokApi import TikTokapi

# Starts The Api Class
api = TikTokapi("browsermob-proxy/bin/browsermob-proxy")

# The Number of trending TikToks you want to be displayed
results = 10

hashtag = ("meme")


result = api.search_by_hashtag(hashtag, results)

prevloops = 0

for tiktok in result :
    # Prints the text of the tiktok
    videoURL = tiktok["itemInfos"]["video"]["urls"][0]
    videoname = "video" + str(prevloops) + ".mp4"
    urllib.request.urlretrieve(videoURL, videoname)
    prevloops += 1

Repository owner locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants