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

TypeError: 'bool' object is not iterable #1

Open
10kkm opened this issue Aug 3, 2023 · 26 comments
Open

TypeError: 'bool' object is not iterable #1

10kkm opened this issue Aug 3, 2023 · 26 comments

Comments

@10kkm
Copy link

10kkm commented Aug 3, 2023

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
Copy link
Owner

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
Copy link
Owner

f24deb9 It'll now raise TypeError, since pass the bool isn't the correct behavior.

@10kkm
Copy link
Author

10kkm commented Aug 5, 2023

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
Copy link
Owner

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 c1d4d44

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

@10kkm 10kkm closed this as completed Aug 7, 2023
@10kkm
Copy link
Author

10kkm commented Aug 7, 2023

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 10kkm reopened this Aug 7, 2023
@10kkm
Copy link
Author

10kkm commented Aug 7, 2023

any chance to fix this?

@NIKDISSV-Forever
Copy link
Owner

С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
Copy link
Author

10kkm commented Aug 8, 2023

it occurs with any

@NIKDISSV-Forever
Copy link
Owner

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

@10kkm
Copy link
Author

10kkm commented Aug 15, 2023

its okay i can just use windows server

@10kkm
Copy link
Author

10kkm commented Sep 5, 2023

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

@NIKDISSV-Forever
Copy link
Owner

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
Copy link
Author

10kkm commented Sep 9, 2023

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 10kkm closed this as completed Sep 9, 2023
@10kkm 10kkm reopened this Sep 9, 2023
@10kkm
Copy link
Author

10kkm commented Sep 9, 2023

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
Copy link
Author

10kkm commented Sep 9, 2023

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

@NIKDISSV-Forever
Copy link
Owner

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

@10kkm
Copy link
Author

10kkm commented Sep 15, 2023

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

@10kkm
Copy link
Author

10kkm commented Dec 31, 2023

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

@NIKDISSV-Forever
Copy link
Owner

Fixed af16c0f. Update to version 3.2.0.

@10kkm
Copy link
Author

10kkm commented Jan 12, 2024

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
Copy link
Owner

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
Copy link
Author

10kkm commented Jan 13, 2024

do u have discord??

@NIKDISSV-Forever
Copy link
Owner

nikdissv#4299

@10kkm
Copy link
Author

10kkm commented Jan 19, 2024

will u accept the friend request?

@Gokujo
Copy link

Gokujo commented Feb 13, 2024

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
Copy link
Owner

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 (#3) or VPN, and tell me later if you succeeded.
Also make sure that you have access to the stream through the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants