GithubHelp home page GithubHelp logo

demon071 / tiktok-api-python Goto Github PK

View Code? Open in Web Editor NEW
122.0 3.0 30.0 109 KB

TIKTOK API IN PYTHON , GET TRENDING VIDEO, GET VIDEO BY CHALLENGE, GET VIDEO BY MUSIC, GET VIDEO BY USER, DOWNLOAD VIDEO NO WATERMARK

Home Page: https://rapidapi.com/AdKT36/api/video-nwm

License: MIT License

Python 100.00%
tiktok-api tiktok-nowatermark tiktok-scraper tiktok-python download-tiktok get-video-tiktok tiktok tiktokv requests-python musicaly-crawler

tiktok-api-python's People

Contributors

demon071 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tiktok-api-python's Issues

line 19 download

Hello, I am facing this problem after running the following code: python3 getChallengeFeed.py

File "/Users/hamedmuna/Tiktok-API-Python/getChallengeFeed.py", line 19, in
dl = Download()
NameError: name 'Download' is not defined
can you please identify and define it for me.
Thank you!
Mona

selenium.common.exceptions.TimeoutException: Message: script timeout

I'm getting this error
Traceback (most recent call last): File "C:\Users\hosam\Desktop\workspace1\ocean_project\Tiktok-API-Python\TiktokApi\api.py", line 57, in getUserFeed data = self.browser.fetch_browser(api_url, tt_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hosam\Desktop\workspace1\ocean_project\Tiktok-API-Python\TiktokApi\browser.py", line 65, in fetch_browser return self.driver.execute_async_script(js) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hosam\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 526, in execute_async_script return self.execute(command, {"script": script, "args": converted_args})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hosam\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute self.error_handler.check_response(response) File "C:\Users\hosam\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: script timeout (Session info: chrome=107.0.5304.107) Stacktrace: Backtrace: Ordinal0 [0x00F3ACD3+2075859] Ordinal0 [0x00ECEE61+1633889] Ordinal0 [0x00DCB680+571008] Ordinal0 [0x00E2C20A+967178] Ordinal0 [0x00E1731C+881436] Ordinal0 [0x00E2B56A+963946] Ordinal0 [0x00E17136+880950] Ordinal0 [0x00DEFEFD+720637] Ordinal0 [0x00DF0F3F+724799] GetHandleVerifier [0x011EEED2+2769538] GetHandleVerifier [0x011E0D95+2711877] GetHandleVerifier [0x00FCA03A+521194] GetHandleVerifier [0x00FC8DA0+516432] Ordinal0 [0x00ED682C+1665068] Ordinal0 [0x00EDB128+1683752] Ordinal0 [0x00EDB215+1683989] Ordinal0 [0x00EE6484+1729668] BaseThreadInitThunk [0x76C7FEF9+25] RtlGetAppContainerNamedObjectPath [0x77577BBE+286] RtlGetAppContainerNamedObjectPath [0x77577B8E+238]
when running getUserFeed.py

AttributeError: 'NoneType' object has no attribute 'group' / TypeError: cannot unpack non-iterable bool object

Hello,
While trying getUserFeed.py I get these errors:

Traceback (most recent call last):
  File "F:\Escritorio\Tiktok-API-Python-master\TiktokApi\api.py", line 198, in getInfoUser
    resp = self.extra_next_data(res.text)
  File "F:\Escritorio\Tiktok-API-Python-master\TiktokApi\api.py", line 270, in extra_next_data
    res = re.search('script id=\"SIGI_STATE\" type=\"application/json\">(.*)</script><script id=\"SIGI_RETRY\"', html).group(0)

AttributeError: 'NoneType' object has no attribute 'group' ^^

Traceback (most recent call last):
  File "F:\Escritorio\Tiktok-API-Python-master\getUserFeed.py", line 26, in <module>
    userFeed, cookie = Api.getUserFeed(username, max_cursor=max_cursor)

TypeError: cannot unpack non-iterable bool object ^^

Hope you guys can help me :)

Trending video per country

Would be useful adding a feature that lets the user select the country for the trending videos as well as the number of trending videos. Anyway best Tik tok api so far, i'm surprised of 0 stars. Really.

cannot unpack non-iterable bool object

api stop working and show this error

`[]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/requests/models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/content/TiktokApi/api.py", line 92, in getUserFeed
resp = res.json()
File "/usr/local/lib/python3.7/dist-packages/requests/models.py", line 917, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Expecting value]

    # i removed the html code because hes is big!!!!!

TypeError Traceback (most recent call last)

in ()
41
42 while True:
---> 43 userFeed, cookie = Api.getUserFeed(username=user_name, max_cursor=max_cursor)
44 dl = Download(cookie=cookie, path=folder1)
45 for post in userFeed['itemListData']:

TypeError: cannot unpack non-iterable bool object`

i removed the html code from the error report because he is big!!!!!

this error happen with getMusicFeed and with getUserFeed

Last 27 items download limit

Hi, thank you for your work. I'm a bit noob here, but when I try to download a user feed, it only downloads the last 27 videos. Is this normal behaviour?

GetChallangeFeed Not Working


from TiktokApi import *

Api = Tiktok()

limit = 40
count = 0
setFlag = 0
max_cursor = 0
while True:
    Feed, cookie = Api.getChallengeFeed(challenge='funny', max_cursor=max_cursor)
    dl = Download(cookie=cookie, path='video')
    for post in Feed['itemListData']:
        video_url = post['itemInfos']['video']['urls'][0]
        video_id = post['itemInfos']['id']
        print(video_id)
        # download video
        dl.downloadVideo(url=video_url, file_name=video_id)
        print('Download video {}.mp4'.format(video_id))
        count += 1
        if count == limit:
            setFlag = 1
            break
    max_cursor += 30 
    if setFlag == 1:
        break

Error:


  File "/home/kadirilgin1453/Python-Projeleri/TiktokProject/TiktokApi/api.py", line 213, in getInfoChallenge
    resp = self.__extra_next_data__(res.text)
  File "/home/kadirilgin1453/Python-Projeleri/TiktokProject/TiktokApi/api.py", line 264, in __extra_next_data__
    res = re.search('<script id="sigi-persisted-data">(.*)</script><script', html).group(1)
AttributeError: 'NoneType' object has no attribute 'group'

Traceback (most recent call last):
  File "/home/kadirilgin1453/Python-Projeleri/TiktokProject/main.py", line 11, in <module>
    Feed, cookie = Api.getChallengeFeed(challenge='funny', max_cursor=max_cursor)
TypeError: cannot unpack non-iterable bool object
  • [+] Python 3.10.1

how to get video count for music id?

thanks for the great work
using"getMusicFeed" i can get videos from music id for specific count (must be multiply of 30)
how to get video count for music id?
i mean how many videos found in music id

getInfoVideo list index out of range

getInfoVideo doesn't work for some url!!
for example

from TiktokApi import *
Api = Tiktok()

x=1

url= "private video"

if x==1:
    InfoVideo= Api.getInfoVideo(url=url)
    #dl = Download(cookie=cookie, path='video')
    print(InfoVideo)

it give this error

Traceback (most recent call last):
  File "/content/TiktokApi/api.py", line 281, in getInfoVideo
    vid = list(video_info.keys())[0]
IndexError: list index out of range

False

however url is correct!
any idea?

run script problem

i found your script in which you tell how to tiktok videos download without watermark. the problem is, i don't know how to run this and by using this how i can download videos. can you help me please

getInfoVideo cannot unpack non-iterable bool object

try to get tiktok info by tiktok video url

`
from TiktokApi import *
Api = Tiktok()
limit = 1000
count = 0
setFlag = 0
max_cursor = 0
url="https://www.tiktok.com/@whyao11141/video/7066723377112747290"

by_url, cookie = Api.getInfoVideo(url=url)
dl = Download(cookie=cookie, path='video')
print (by_url)

`

but i got this error

Traceback (most recent call last):
File "/content/TiktokApi/api.py", line 263, in getInfoVideo
return json.loads(resp)['props']['pageProps'], res.cookies.get_dict()
KeyError: 'props'


TypeError Traceback (most recent call last)

in ()
10 #
11 error_count=0
---> 12 userFeed, cookie = Api.getInfoVideo(url=url)
13 dl = Download(cookie=cookie, path='video')
14 print (userFeed)

TypeError: cannot unpack non-iterable bool object

any idea?

No module named 'TiktokApi.browser'

thanks for the update, i already test it but didn't work so thought it's still under progress....
using any example like user feed example
this error happen

`ModuleNotFoundError Traceback (most recent call last)

in ()
----> 1 from TiktokApi import *
2
3 Api = Tiktok()
4
5 # nhập tên người dùng

1 frames

/content/TiktokApi/api.py in ()
8 import pickle
9 from urllib.parse import urlencode, quote
---> 10 from .browser import Browser
11 from .ultis import set_url, get_param_url
12 from .encryption import get_tt_param

ModuleNotFoundError: No module named 'TiktokApi.browser'`

i am using google colab, any help will be appreciated

getChallengeFeed minCursor, maxCursor, count

Hello! Can you explain what the selection of "minCursor", "maxCursor", "count" values in the getChallengeFeed method is based on? With the values "minCursor"==0 and "maxCursor"==0, I get a list of videos by the tag I need. And also at the end of the server response there is ""...hasMore":true,"maxCursor":"128805","minCursor":"2157990","itemABParams":[],"webToken":""},"errMsg ":null}". However, with the subsequent "minCursor"==0 and "maxCursor"==30, there are no videos by the tag, although there are much more of them on the site.
Thanks!

secUid vs userid

I observe a change in the parameters for the 'getUserFeed' function in Tiktok class.
The previous version allowed querying via the userid, but the latest one only allow secUid.
What is this secUid? Possible to query via userid instead?

request timeout

can you please set kind of timeout request
mainly for getMusicFeed , since we don't know the number of video in the sound id, so set the limit =5000
but the while loop never terminate if sound have less video, and it seems there is no response from api since the script is running and no more video id printed in screen!, and that's where should be time out in the request in order to interrupt while loop!
am i right?, is there any other suggestion to interrupt the loop?
i have to interrupt it manually and that is boring

Feature Request 🧾

  • Hey there, The Api is great but could you make a function to get video info for example
    vid_info = Api.getVideo_infoById('6897853325761350913')
    and it returns Caption, num of comments, likes ,shares..etc in an array or maybe a json file

  • And another thing specify the path to download video
    Eg : Api.DownloadVideoById('6897853325761350913', path)

That's it otherwise everything is good.

Message: javascript error: a is not defined

Hello, I downloaded your code and ran it today. I encountered problems in the process of running. It was normal to get the data on the first page, but I reported an error when I got the data on the second page.The following is the log I am running.

(tiktok39) PS C:\Users\xcy\Downloads\tiktok\Tiktok-API-Python> python .\getUserFeed.py

====== WebDriver manager ======
Current google-chrome version is 103.0.5060
Get LATEST chromedriver version for 103.0.5060 google-chrome
Driver [C:\Users\xcy.wdm\drivers\chromedriver\win32\103.0.5060.53\chromedriver.exe] found in cache

DevTools listening on ws://127.0.0.1:53245/devtools/browser/53a7d838-24c1-497a-afe4-435bf709ca96
[7728:6808:0716/114037.381:ERROR:device_event_log_impl.cc(214)] [11:40:37.381] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
[4468:3220:0716/114046.588:ERROR:gl_utils.cc(319)] [.WebGL-0000065A00398D00]GL Driver Message (OpenGL, Performance, GL_CLOSE_PATH_NV, High): GPU stall due to ReadPixels
[2540:1100:0716/114046.696:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101
[2540:1100:0716/114046.806:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101
[2540:1100:0716/114048.245:ERROR:ssl_client_socket_impl.cc(996)] handshake failed; returned -1, SSL error code 1, net_error -101
Video <<7111016440416816430>> <<its the click click for me #HappyFathersDay>>
Video <<7111102531161312558>> <<words of wisdom from @rae Sremmurd @swae Lee @slim Jxmmi ✨ #SomethingInTheWater>>
Video <<7111154066201333034>> <<ok but like why are @chloe x halle’s TikTok feed the same as mine? ☕️ #SomethingInTheWater>>
Video <<7111389999735655723>> <<I like you @post Malone @doja Cat, i do 🫶 #somethinginthewater>>
Video <<7111763250424941866>> <<#PrideMonth is about celebraring our captivating, fearless and authentic selves 🏳️‍🌈❤️🏳️‍⚧️ #ForYourPride>>
Video <<7111799051363863850>> <<@givĒON with the TikTok delivery 💌 Track #15 Unholy Matrimony #BlackMusic>>
Video <<7112192663679503658>> <<the beautiful words of @Eureka O’hara are all i need in my feed 💗 #ForYourPride>>
Video <<7112528574325837099>> <<if you got 5 or more questions right, you are verified pride professional! 🙌🏆 #ForYourPride>>
Video <<7113334680421813546>> <<looks like #Horace had a great time at #TikTokVidCon 🕺🏻>>
Video <<7113746866751245611>> <<guess who came to the TikTok Creator Atrium at #TikTokVidCon? congrats to the king @khaby.lame 👑>>
Video <<7114000052686949678>> <>
Video <<7114389413366402346>> <<give your younger self a hug 🤗 #ForYourPride>>
Video <<7114419476405243178>> <<aww they love me, they really love me 💖 #BETAwards #culturesbiggestnight>>
Video <<7114767797812464939>> <<14-year-old Megan is proud of the incredible, authentic woman she became ❤️ #ForYourPride>>
Video <<7114810000027012398>> <<Caught up with a couple creators at #TikTokVidCon ✨ totally agree that 😭 CRYING 😭 is a slay.>>
Video <<7115137119445699883>> <<she spreads ✨joy✨on TikTok with her #RainbowBrightUnderEye 🌈 now get to know Originator @☆ naezrah #Originators>>
Video <<7115446230448262446>> <<brb checking out my fave creators’ fave creators 👀#TikTokTrailblazers #ForYourPride>>
Video <<7115527680971279659>> <<You’ll never know who you’ll see on the streets of @vidcon 👀 #TikTokVidCon>>
Video <<7116948637745450286>> <<In this house, we ✨ create ✨ #TikTokVidCon>>
Video <<7117323692941626666>> <<other cultures are here for THE culture and we love to see it. #BlackTikTok #BlackMusic @black TikTok>>
Video <<7117393879846128942>> <<living for the unhinged chaos on the red carpet of the TikTok creator party at #TikTokVidCon 🥳✨>>
Video <<7117750537176649006>> <<who has better hair? @chris Hemsworth or TikTok?? #ThorLoveAndThunder>>
Video <<7117809702267850026>> <<Replying to @johnrinker took a sec for even @chrishemsworth to realize 😂 #thorloveandthunder>>
Video <<7118065036903370026>> <<@soy ✨ with a little food for thought #Inspiration #FoodTok #TikTokVidCon>>
Video <<7118122340046703915>> <<sounds like Thor needs to practice some self-care 🥰 #thorloveandthu nder>>
Video <<7119208189517778219>> <<give @Hina a mic and let them slay the day away 🎤 #TikTokVidCon>>
Video <<7119217765298326830>> <<have you checked out Money Heist: Korea on @Netflix? 💰 no spoilers please! 🙈>>
Video <<7119563361938836782>> <<don’t wait for Arab American Heritage Month to discover incredible Arab American creators 🎤💅🎨 #DiversifyYourFYP>>
Video <<7119937676341726510>> <<don’t be sad that u missed #EssenceFest2022, be happy that i made u this private tour 🤳 #EssenceFest>>
Video <<7120348773460790574>> <<my soul might be broken but it's fine @beyonce #RENAISSANCE #Horace @JQGray>>
code by t.me/toolav
Traceback (most recent call last):
File "C:\Users\xcy\Downloads\tiktok\Tiktok-API-Python\TiktokApi\api.py", line 57, in getUserFeed
data = self.browser.fetch_browser(api_url, tt_params)
File "C:\Users\xcy\Downloads\tiktok\Tiktok-API-Python\TiktokApi\browser.py", line 70, in fetch_browser
return self.driver.execute_script("return a;")
File "C:\Users\xcy.conda\envs\tiktok39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 884, in execute_script
return self.execute(command, {
File "C:\Users\xcy.conda\envs\tiktok39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 430, in execute
self.error_handler.check_response(response)
File "C:\Users\xcy.conda\envs\tiktok39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: javascript error: a is not defined
(Session info: chrome=103.0.5060.114)
Stacktrace:
Backtrace:
Ordinal0 [0x01076463+2188387]
Ordinal0 [0x0100E461+1762401]
Ordinal0 [0x00F23D78+802168]
Ordinal0 [0x00F26754+812884]
Ordinal0 [0x00F26612+812562]
Ordinal0 [0x00F26F8A+814986]
Ordinal0 [0x00F7D669+1169001]
Ordinal0 [0x00F6C7DC+1099740]
Ordinal0 [0x00F7CC22+1166370]
Ordinal0 [0x00F6C5F6+1099254]
Ordinal0 [0x00F46BE0+945120]
Ordinal0 [0x00F47AD6+948950]
GetHandleVerifier [0x013171F2+2712546]
GetHandleVerifier [0x0130886D+2652765]
GetHandleVerifier [0x0110002A+520730]
GetHandleVerifier [0x010FEE06+516086]
Ordinal0 [0x0101468B+1787531]
Ordinal0 [0x01018E88+1805960]
Ordinal0 [0x01018F75+1806197]
Ordinal0 [0x01021DF1+1842673]
BaseThreadInitThunk [0x762F6359+25]
RtlGetAppContainerNamedObjectPath [0x77227B74+228]
RtlGetAppContainerNamedObjectPath [0x77227B44+180]

False
Traceback (most recent call last):
File "C:\Users\xcy\Downloads\tiktok\Tiktok-API-Python\getUserFeed.py", line 42, in
for x in data['itemList']:
TypeError: 'bool' object is not subscriptable

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.