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

Json decode error #6

Closed stolenvw closed 1 year ago

stolenvw commented 1 year ago

Getting this error with the 0.1.6 release

Exception in callback AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe... 1 (char 0)')>) at /home/user/.local/lib/python3.10/site-packages/pyee/asyncio.py:65
handle: <Handle AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe... 1 (char 0)')>) at /home/user/.local/lib/python3.10/site-packages/pyee/asyncio.py:65>
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/user/.local/lib/python3.10/site-packages/pyee/asyncio.py", line 71, in callback
    self.emit("error", exc)
  File "/home/user/.local/lib/python3.10/site-packages/pyee/base.py", line 179, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/home/user/.local/lib/python3.10/site-packages/pyee/base.py", line 139, in _emit_handle_potential_error
    raise error
  File "/home/user/.local/lib/python3.10/site-packages/playwright/_impl/_page.py", line 255, in _on_route
    handled = await route_handler.handle(route)
  File "/home/user/.local/lib/python3.10/site-packages/playwright/_impl/_helper.py", line 287, in handle
    [handled, *_] = await asyncio.gather(handled_future, *handler_task)
  File "/home/user/.local/lib/python3.10/site-packages/tiktokapipy/async_api.py", line 146, in capture_api_extras
    _data = await response.json()
  File "/home/user/.local/lib/python3.10/site-packages/playwright/async_api/_generated.py", line 16965, in json
    return mapping.from_maybe_impl(await self._impl_obj.json())
  File "/home/user/.local/lib/python3.10/site-packages/playwright/_impl/_fetch.py", line 467, in json
    return json.loads(content)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/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)

code thats giving the error with real username removed:

async def tester():
     async with AsyncTikTokAPI() as api:
             user = await api.user("some_user", video_limit=1)
             async for video in user.videos:
                     print(video)

asyncio.run(tester())

video info is being printed

Russell-Newton commented 1 year ago

Can you try changing your version of TikTokPy to the WIP version in #7 and seeing if that fixes the problem?

pip uninstall tiktokapipy
pip install git+https://github.com/Russell-Newton/TikTokPy.git@refs/pull/7/head
stolenvw commented 1 year ago

that gets rid of the error

Russell-Newton commented 1 year ago

Fixed in v0.1.7