Russell-Newton / TikTokPy

Extract data from TikTok without needing any login information or API keys.
https://pypi.org/project/tiktokapipy/
MIT License
197 stars 25 forks source link

Is there a way to ignore slideshows or Error in video extraction: status code 100004? #27

Closed pjn5047 closed 1 year ago

pjn5047 commented 1 year ago

I believe I'm getting and error because I'm trying to extract data from a slideshow. I know I could utilize emulate_mobile=True, however this severely limits the number of videos I am able to pull data on. Traceback on the error is below:

Traceback (most recent call last):
  File "~/myproject.py", line 52, in <module>
    for video in challenge.videos:
  File "~/venv/lib/python3.10/site-packages/tiktokapipy/api.py", line 90, in __next__
    out = self.fetch(self._next_up)
  File "~/venv/lib/python3.10/site-packages/tiktokapipy/api.py", line 103, in fetch
    return self._api.video(video_link(self._light_models[idx].id))
  File "~/venv/lib/python3.10/site-packages/tiktokapipy/api.py", line 312, in video
    return self._extract_video_from_response(response, api_extras)
  File "~/venv/lib/python3.10/site-packages/tiktokapipy/api.py", line 450, in _extract_video_from_response
    raise TikTokAPIError(
tiktokapipy.TikTokAPIError: Error in video extraction: status code 100004

I can't seem to figure out where to put my except: statement since even calling the video in the for videos in challenge.videos causes the error, so I'm not sure how to move to the next iteration.

Any help is appreciated! Again, I apologize if there is a simple solution I am just missing.

pjn5047 commented 1 year ago

I ended up instead pulling the "light" video information from challenge.videos._light_models, then iterating over that ids in that list with a try/except so that I could skip over the errors and continue to the next video. It's probably inefficient, but it works for now!

Russell-Newton commented 1 year ago

Just a heads up, I updated the code such that the videos._light_models is now videos.light_models. Also, this is kind of the best way to do it at the moment. There currently isn't a more efficient way to do it, you just have to step through the iterator yourself

Russell-Newton commented 1 year ago

Small update - it looks like slideshows now work on desktop too, so you may not see this problem anymore.