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: urlopen() got an unexpected keyword argument 'cafile' #128

Open
bramhaag opened this issue Jan 3, 2025 · 4 comments · May be fixed by #129
Open

TypeError: urlopen() got an unexpected keyword argument 'cafile' #128

bramhaag opened this issue Jan 3, 2025 · 4 comments · May be fixed by #129

Comments

@bramhaag
Copy link

bramhaag commented Jan 3, 2025

Trying to use this with Python 3.13 results in the following error when trying to play anything:

Exception occurred during processing of request from ('127.0.0.1', 42716)
Traceback (most recent call last):
  File "/usr/lib/python3.13/socketserver.py", line 692, in process_request_thread
    self.finish_request(request, client_address)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/socketserver.py", line 362, in finish_request
    self.RequestHandlerClass(request, client_address, self)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/http/server.py", line 672, in __init__
    super().__init__(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/socketserver.py", line 761, in __init__
    self.handle()
    ~~~~~~~~~~~^^
  File "/usr/lib/python3.13/http/server.py", line 436, in handle
    self.handle_one_request()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/http/server.py", line 424, in handle_one_request
    method()
    ~~~~~~^^
  File "/usr/lib/python3.13/site-packages/plex_mpv_shim/client.py", line 199, in do_GET
    self.handle_request("GET")
    ~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/usr/lib/python3.13/site-packages/plex_mpv_shim/client.py", line 177, in handle_request
    getattr(self, handler)(path, query)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/plex_mpv_shim/client.py", line 317, in playMedia
    media = Media(url, media_type=parsed_media_type, play_queue=playQueue)
  File "/usr/lib/python3.13/site-packages/plex_mpv_shim/media.py", line 560, in __init__
    XMLCollection.__init__(self, url)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/plex_mpv_shim/media.py", line 537, in __init__
    self.tree       = et.parse(urllib.request.urlopen(get_plex_url(url), cafile=certifi.where()))
                               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: urlopen() got an unexpected keyword argument 'cafile'

The cafile parameter was removed, and should be passed using the context parameter instead.

@regroup6405
Copy link

2025-01-05 11:30:05,963 [   DEBUG] urllib3.connectionpool: Starting new HTTP connection (1): ~~(LOCAL_IP)~~:32500
2025-01-05 11:30:06,023 [   DEBUG] urllib3.connectionpool: http://~~(LOCAL_IP)~~:32500 "POST /:/timeline HTTP/1.1" 200 None
2025-01-05 11:30:06,963 [   DEBUG] timeline: TimelineManager::SendTimelineToSubscribers updating all subscribers
2025-01-05 11:30:06,963 [   DEBUG] timeline: TimelineManager::SendTimelineToSubscriber sending timeline to http://~~(LOCAL_IP)~~:32500/:/timeline
2025-01-05 11:30:06,964 [   DEBUG] urllib3.connectionpool: Starting new HTTP connection (1): ~~(LOCAL_IP)~~:32500
2025-01-05 11:30:06,964 [   ERROR] utils: Error opening URL 'https://~~(LOCAL_PLEX_DIRECT)~~:32400/:/timeline?location=fullScreenVideo&state=playing&type=video&time=1201784&autoPlay=1&audioStreamID=149926&subtitleStreamID=149928&subtitleSize=100&subtitlePosition=bottom&subtitleColor=%23ffffff&ratingKey=14245&key=%2Flibrary%2Fmetadata%2F14245&containerKey=...:  urlopen() got an unexpected keyword argument 'cafile'
2025-01-05 11:30:07,051 [   DEBUG] urllib3.connectionpool: http://~~(LOCAL_IP)~~:32500 "POST /:/timeline HTTP/1.1" 200 None
2025-01-05 11:30:07,097 [   DEBUG] player: PlayerManager::stop stopping playback of <plex_mpv_shim.media.Video object at 0x7faa59c40440>
2025-01-05 11:30:07,149 [   DEBUG] timeline: TimelineManager::SendTimelineToSubscribers updating all subscribers
2025-01-05 11:30:07,150 [   ERROR] utils: Error opening URL 'https://~~(LOCAL_PLEX_DIRECT)~~:32400/:/timeline?location=&state=stopped&type=video&ratingKey=14245&key=%2Flibrary%2Fmetadata%2F14245&containerKey=....:  urlopen() got an unexpected keyword argument 'cafile'
2025-01-05 11:30:07,150 [   DEBUG] timeline: TimelineManager::SendTimelineToSubscriber sending timeline to http://~~(LOCAL_IP)~~:32500/:/timeline
2025-01-05 11:30:07,150 [   DEBUG] urllib3.connectionpool: Starting new HTTP connection (1): ~~(LOCAL_IP)~~:32500
2025-01-05 11:30:07,179 [   DEBUG] urllib3.connectionpool: http://~~(LOCAL_IP)~~:32500 "POST /:/timeline HTTP/1.1" 500 None

I was getting the same error as OP and unable to play anything. I cloned the mentioned pull request and can play media but the logs still show the errors above regarding the timeline every second or so. Tested on Fedora 41, cloned repo and using run.py.

@Zharkan
Copy link

Zharkan commented Jan 5, 2025

@regroup6405 Could try again, I've just made a change to utils.py, let me know if you still got the same error ?

@regroup6405
Copy link

Yes that change solves the error, I made the same change and made a pull request against your fork a couple min ago so I removed that and all is well. That should be all occurrences of this "cafile" error in the repo.

@Zharkan
Copy link

Zharkan commented Jan 5, 2025

Now, let's give @iwalton3 some time to check this, and hopefully, it will get merged if everything looks good.

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

Successfully merging a pull request may close this issue.

3 participants