devine-dl/pywidevine

ClientIdentification returns empty object, halting create-device

Closed this issue · 4 comments

Describe the bug

When running create-device, it raises an exception. I've been fiddling around and it's because at the Device __init__ step, the function ClientIdentification returns an almost empty object.

The original code is this:

def  __init__(...):
  ...
  self.client_id = ClientIdentification()

After that instruction, self.client_id prints as an empty string, its ByteSize method returns 0, the ClientCapabilities prints as an empty string, and the __sizeof__() is 64.

To Reproduce
I've run this command:

pywidevine create-device -t CHROME -l 3 -k ./my/key -c my/client_blob -v ./my/vmp_blob -o dv

The same happens when the -v argument is ommited.

Expected behavior
A .wvd file should be created.

Hi,

You have not provided a exception or error log to see what error you are actually facing.
You say it's something to do with the client_id class instance variable, but this is unlikely.

However, I have noticed one possible issue with your CLI call that may have caused it to fail. Please see the commit 29693be and try with that change.

Sorry for skipping the traceback, I started digging around and forgot to add it.
It's here, using the code cloned after the new commit:

INFO:root:pywidevine version 1.5.3 Copyright (c) 2022-2023 rlaphoenix
INFO:root:https://github.com/rlaphoenix/pywidevine
Traceback (most recent call last):
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/pywidevine/device.py", line 112, in __init__
    self.client_id.ParseFromString(client_id)
google.protobuf.message.DecodeError: Error parsing message

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/username/mambaforge/envs/wide3/bin/pywidevine", line 8, in <module>
    sys.exit(main())
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/pywidevine/main.py", line 203, in create_device
    device = Device(
  File "/home/username/mambaforge/envs/wide3/lib/python3.9/site-packages/pywidevine/device.py", line 116, in __init__
    raise DecodeError(f"Failed to parse client_id as a ClientIdentification, {e}")
google.protobuf.message.DecodeError: Failed to parse client_id as a ClientIdentification, Error parsing message

I'll try to explain myself better: after seeing the traceback, I looked into device.py, and by adding a few debug lines I saw that the self.client_id object is empty: no client capabilites, _str_ returns an empty string, ByteSize returns 0, I think that's why the ParseFromString method fails. I did not touch the script that contains ClientIdentification because of its format.

My installation method is from the source code, using pip install ., in case it's relevant. I have to say that after installing like this (or from pip's repository) I have to manually install pyYAML, so maybe I'm missing something?

The error you are getting is simply not an error with this project. Your Client Identification file/blob is invalid or corrupt.

Also, what you are referring to regarding the state of the Device object, __str__, the self.client_id being "empty" e.t.c, is all normal for a newly initialized object. Since it is failing for you when parsing your client ID blob file to the self.client_id, it is never "initialized" and therefore __str__ cannot resolve to anything.

Ah , I see. Thank you, I'll try to see into that,