NIKDISSV-Forever / HDRezka

HDRezka (rezka.ag) Python API
MIT License
10 stars 0 forks source link

TypeError: 'bool' object is not iterable #1

Open 10kkm opened 1 year ago

10kkm commented 1 year ago

File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/root/anipj/main.py", line 52, in main stream = await ani.get_stream(g, h, translats[b-1][1]) File "/usr/local/lib/python3.10/dist-packages/hdrezka/stream/player.py", line 77, in get_stream return urls_from_ajax_response( File "/usr/local/lib/python3.10/dist-packages/hdrezka/post/urls/urls.py", line 12, in urls_from_ajax_response return URLs(VideoURLs(response.get('url', '')), File "/usr/local/lib/python3.10/dist-packages/hdrezka/post/urls/kind/video.py", line 24, in init self.qualities: tuple[Quality] = *sorted(self.raw_data), TypeError: 'bool' object is not iterable

on windows its working well, but when im trying on my vps its throwing this error

NIKDISSV-Forever commented 1 year ago

I failed to reproduce this error, could you please provide me with the get_stream arguments at which this error occurs and any other information that will help reproduce the error (package version, part of your source code, startup parameters, system or something else) I used VCL if it matters.

NIKDISSV-Forever commented 1 year ago

https://github.com/NIKDISSV-Forever/HDRezka/commit/f24deb9769d126a166a8f709936305493770154a It'll now raise TypeError, since pass the bool isn't the correct behavior.

10kkm commented 1 year ago

its the first try on linux with pm2 and venv, python 3.10, this error appears for any get stream. And i saw another error about dictionary changed File "G:\anipj\venv\lib\site-packages\hdrezka\stream\player.py", line 25, in set for k in self.storage.keys(): so i fixed it with tuple(self.storage.keys())

NIKDISSV-Forever commented 1 year ago

its the first try on linux with pm2 and venv, python 3.10, this error appears for any get stream. And i saw another error about dictionary changed File "G:\anipj\venv\lib\site-packages\hdrezka\stream\player.py", line 25, in set for k in self.storage.keys(): so i fixed it with tuple(self.storage.keys())

fixed at https://github.com/NIKDISSV-Forever/HDRezka/commit/c1d4d4455c31a38b885a3a1affc98b9de0945ff2

Upgrade to 3.0.3 and check the functionality, if there are no more problems, the issue can be closed.

10kkm commented 1 year ago

TypeError: got False (type <class 'bool'>) but expected type str | dict Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 297, in _process_update response = await self.feed_update(bot, update, kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 146, in feed_update response = await self.update.wrap_outer_middleware( File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/middlewares/error.py", line 25, in call return await handler(event, data) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/middlewares/user_context.py", line 23, in call return await handler(event, data) File "/usr/local/lib/python3.10/dist-packages/aiogram/fsm/middleware.py", line 39, in call return await handler(event, data) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/event/telegram.py", line 123, in trigger return await wrapped_inner(event, kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/event/handler.py", line 42, in call return await wrapped() File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 264, in _listen_update return await self.propagate_event(update_type=update_type, event=event, kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/router.py", line 115, in propagate_event return await observer.wrap_outer_middleware(_wrapped, event=event, data=kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/router.py", line 111, in _wrapped return await self._propagate_event( File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/router.py", line 124, in _propagate_event response = await observer.trigger(event, **kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/event/telegram.py", line 123, in trigger return await wrapped_inner(event, kwargs) File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/event/handler.py", line 42, in call return await wrapped() File "/root/anipj/main.py", line 154, in buttons_callback print(f"{await pl.get_stream(seas, epi, trans)}") File "/usr/local/lib/python3.10/dist-packages/hdrezka/stream/player.py", line 76, in get_stream return urls_from_ajax_response( File "/usr/local/lib/python3.10/dist-packages/hdrezka/post/urls/urls.py", line 12, in urls_from_ajax_response return URLs(VideoURLs(response.get('url', '')), File "/usr/local/lib/python3.10/dist-packages/hdrezka/post/urls/kind/video.py", line 27, in init raise TypeError(f'got {data!r} (type {type(data)}) but expected type {str | dict}') TypeError: got False (type <class 'bool'>) but expected type str | dict

10kkm commented 1 year ago

any chance to fix this?

NIKDISSV-Forever commented 1 year ago

Сould you send the series season and episode on which this error occurs, or does it occur everywhere? So far, I can't say what this is related to.

10kkm commented 1 year ago

it occurs with any

NIKDISSV-Forever commented 1 year ago

I haven't any ideas at the moment...

10kkm commented 1 year ago

its okay i can just use windows server

10kkm commented 1 year ago

nah these windows servers are expensive, we need to fix that 💀

NIKDISSV-Forever commented 1 year ago

Since I don't get the same behavior, maybe for example you have redefined the sorted function somewhere so that it returns a bool? I'll check everything again, but maybe the problem occurs in your environment

10kkm commented 1 year ago

nah, everything is OK, i launch it with pm2 and python3.10 by path /usr/bin/python3.10 i tried with and without env, can we go to discord or telegram and discuss it? Cuz here its not so fast, then we'll write here if its solved

10kkm commented 1 year ago

receive_response_headers.complete return_value=(b'HTTP/1.1', 301, b'Moved Permanently', INFO HTTP Request: GET https://rezka.ag/52222-52222.html "HTTP/1.1 301 Moved Permanently" huh

10kkm commented 1 year ago

oh this error with bool appears in other libs, ig its cuz of 301 moved perm

NIKDISSV-Forever commented 1 year ago

I doubt that this is because of 301, there is a check in the code that this is a redirect (301, 302)

10kkm commented 1 year ago

lol, i get this bool on windows server too. latest 3.11, 2012 r2. On local pc i dont get this error, nice

10kkm commented 8 months ago

hey there, some sites are blocked, will this lib support proxy???

NIKDISSV-Forever commented 8 months ago

Fixed https://github.com/NIKDISSV-Forever/HDRezka/commit/af16c0f4cbe28ec75f80da077554aa4c89e76327. Update to version 3.2.0.

10kkm commented 8 months ago

TypeError: got False (type <class 'bool'>) but expected type str | dict Traceback (most recent call last): File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 297, in _process_update response = await self.feed_update(bot, update, kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 146, in feed_update response = await self.update.wrap_outer_middleware( File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/middlewares/error.py", line 25, in call return await handler(event, data) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/middlewares/user_context.py", line 23, in call return await handler(event, data) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/fsm/middleware.py", line 39, in call return await handler(event, data) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/event/telegram.py", line 123, in trigger return await wrapped_inner(event, kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/event/handler.py", line 42, in call return await wrapped() File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/dispatcher.py", line 264, in _listen_update return await self.propagate_event(update_type=update_type, event=event, kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/router.py", line 115, in propagate_event return await observer.wrap_outer_middleware(_wrapped, event=event, data=kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/router.py", line 111, in _wrapped return await self._propagate_event( File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/router.py", line 124, in _propagate_event response = await observer.trigger(event, **kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/event/telegram.py", line 123, in trigger return await wrapped_inner(event, kwargs) File "/root/anipj/gay/lib/python3.10/site-packages/aiogram/dispatcher/event/handler.py", line 42, in call return await wrapped() File "/root/anipj/main.py", line 215, in buttons_callback stream = await pl.get_stream(seas, epi, trans) File "/root/anipj/gay/lib/python3.10/site-packages/hdrezka/stream/player.py", line 88, in get_stream return urls_from_ajax_response( File "/root/anipj/gay/lib/python3.10/site-packages/hdrezka/post/urls/urls.py", line 17, in urls_from_ajax_response return URLs(VideoURLs(response.get('url', '')), File "/root/anipj/gay/lib/python3.10/site-packages/hdrezka/post/urls/kind/video.py", line 37, in init raise TypeError(f'got {data!r} (type {type(data)}) but expected type {str | dict}') TypeError: got False (type <class 'bool'>) but expected type str | dict

didnt help 3.2.0

NIKDISSV-Forever commented 8 months ago

I really don't understand, maybe if you tell me which series (values of pl, seas, epi, trans variables on error) this happens on, I can handle this case properly. Because, as far as I understand, the url field from the API response cannot be bool under any circumstances, but this happens to you.

10kkm commented 8 months ago

do u have discord??

NIKDISSV-Forever commented 8 months ago

nikdissv#4299

10kkm commented 8 months ago

will u accept the friend request?

Gokujo commented 7 months ago

same issue:

Traceback (most recent call last):
  File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\main.py", line 13, in main
    stream = await player.get_stream(1, 1, translator_id)  # raise AJAXFail if invalid episode or translator
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\stream\player.py", line 88, in get_stream
    return urls_from_ajax_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\post\urls\urls.py", line 17, in urls_from_ajax_response
    return URLs(VideoURLs(response.get('url', '')),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\post\urls\kind\video.py", line 43, in __init__
    raise TypeError(f'got {data!r} (type {type(data)}) but expected type {str | dict}')
TypeError: got False (type <class 'bool'>) but expected type str | dict

i switched to python 3.11

thos vars are given image

NIKDISSV-Forever commented 7 months ago

same issue:

Traceback (most recent call last):
  File "C:\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\main.py", line 13, in main
    stream = await player.get_stream(1, 1, translator_id)  # raise AJAXFail if invalid episode or translator
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\stream\player.py", line 88, in get_stream
    return urls_from_ajax_response(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\post\urls\urls.py", line 17, in urls_from_ajax_response
    return URLs(VideoURLs(response.get('url', '')),
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Development\Python\Projects\rezkaMovie\.venv311\Lib\site-packages\hdrezka\post\urls\kind\video.py", line 43, in __init__
    raise TypeError(f'got {data!r} (type {type(data)}) but expected type {str | dict}')
TypeError: got False (type <class ) but     dict

i switched to python 3.11

thos vars are given image


The latest theory was that False is returned in the 'url' field if there are no valid urls for this stream. That's probably why, with all my attempts, I couldn't repeat this error (from Kazakhstan). I can only try to advise you to send requests from a proxy (https://github.com/NIKDISSV-Forever/HDRezka/issues/3) or VPN, and tell me later if you succeeded. Also make sure that you have access to the stream through the browser.