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

Different results between Windows and Linux #405

Closed
spacys opened this issue Mar 26, 2020 · 26 comments
Closed

Different results between Windows and Linux #405

spacys opened this issue Mar 26, 2020 · 26 comments

Comments

@spacys
Copy link

spacys commented Mar 26, 2020

I have implemented inputstream.adaptive as descriped in my Kodi addon on my Linux machines and it works fine (playback is possible). Also on other Linux machines is everything fine. But the same code does not work on Win10 machines.
After a check all information like header, cookie (encoding) looks same on both platforms but still reveiving "Bad Request" on Win10.
Is there something which needs to be considered on Win10 machines?

All machines are 64Bit, addon has unicode directive.

@glennguy
Copy link
Contributor

Is there something which needs to be considered on Win10 machines?

Depends, there can be.

Can we have a look at your code? The only thing I can think of is certain modules have different/changed/missing functionality like the os module eg. os.path.join uses different path separators, and os.uname() doesn't exist on Windows

@spacys
Copy link
Author

spacys commented Mar 28, 2020

Sure, the code can be found here
In the meanwhile I will check your hint.
Edit: I have something like that "'{}/song.{}'" ...will fix and test.

@spacys
Copy link
Author

spacys commented Mar 28, 2020

Path separators are fixed now, getting license looks good, so a step further. Thx for the hint.
But now there is another issue:
ERROR: AddOnLog: InputStream Adaptive: Invalid mpdURL: / expected () ERROR: AddOnLog: InputStream Adaptive: Cannot download ERROR: AddOnLog: InputStream Adaptive: Could not open / parse mpdURL (C:\tmp\song.mpd)

Is there maybe a path rule behind in regards to slash and backslash?

@glennguy
Copy link
Contributor

I think / expected explains it. Can you try C:/tmp/song.mpd ?

@spacys
Copy link
Author

spacys commented Mar 28, 2020

I've tested a bit, here are the results:

  • path must have a slash
  • my previous statement regarding license is wrong...due to missing slash in the path, inputstream stopped. I didn't recognize it before.
  • with slashes in the path inputstream starts the request to amazon
    DEBUG: Curl::Debug - HEADER_IN: HTTP/1.1 400 Bad Request ERROR: CCurlFile::Open failed with code 400 for https://music.amazon.de/EU/api/dmls/: {"__type":"com.amazon.digitalmusiclocator#DrmLicenseDeniedException","DrmType":"WIDEVINE","denialReason":"VMP_VALIDATION_FAILED","message":"WIDEVINE license denied (DrmLicenseDeniedException VMP_VALIDATION_FAILED) request-id: <id> music-agent: <agent>"}
    and replaced

@glennguy
Copy link
Contributor

So you're running into VMP issues in Windows but not Linux (non-Android)?

@spacys
Copy link
Author

spacys commented Mar 29, 2020

I received some more feedback from the users:

  • Windows -> VMP issue
  • LibreElec -> fail
  • Mac -> fail
  • OSMC -> fail
  • RPI -> fail

Successful so far:

  • Xiaomi MiBox Android 8
  • Ubuntu
  • other Android devices
  • NV shield

Try to reproduce with LibreElec and try to get more details about the issues on those systems.

@spacys
Copy link
Author

spacys commented Mar 30, 2020

In the very first step I think it make sense to focus on the VMP issue on Windows 10 systems.

@spacys
Copy link
Author

spacys commented Apr 2, 2020

Is there a way to get more details about this issue on Windows systems, I mean in addition to the debug mode of kodi?

@spacys
Copy link
Author

spacys commented Apr 5, 2020

Maybe one step further in the analysis...the Python code in Kodi looks like this:
li = xbmcgui.ListItem(path=song) li.setProperty('inputstreamaddon', 'inputstream.adaptive') li.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') li.setProperty('inputstream.adaptive.manifest_type', 'mpd') li.setProperty('inputstream.adaptive.license_key', lic) li.setInfo('video', '') li.setMimeType('application/dash+xml') li.setContentLookup(False) xbmcplugin.setResolvedUrl(self.addonHandle, True, listitem=li)

On Linux systems li.setInfo('video', '') is invoking inputstream.adaptive and afterwards the communication with Amazon will start.
But on Windows systems inputstream.adaptive will not start the communication with Amazon, no license request sent. Instead of the license I see this:
NOTICE: VideoPlayer::OpenFile: plugin://plugin.audio.amazonmedia/?asin=B07PLP2F67&mode=getTrack DEBUG: CApplication::OnPlayBackStarted: CApplication::OnPlayBackStarted DEBUG: Thread VideoPlayer start, auto delete: false NOTICE: Creating InputStream INFO: CUtil::ScanPathsForAssociatedItems: found associated file C:\Users\<user>\AppData\Roaming\Kodi\userdata\addon_data\plugin.audio.amazonmedia\song.mpd DEBUG: CUtil::ScanForExternalSubtitles: Searching for subtitles... DEBUG: CUtil::ScanForExternalSubtitles: END (total time: 0 ms) NOTICE: Creating Demuxer ERROR: CDVDDemuxFFmpeg::Open - error probing input format, C:\Users\<user>\AppData\Roaming\Kodi\userdata\addon_data\plugin.audio.amazonmedia\song.mpd

If I try to do the same with: Right click on Song -> Play using... -> PAPlayer, inpustream.adaptive is starting the communication with Amazon but with "Bad Request" response.
So it looks like inpustream.adaptive is handling the same request different on Linux and Windows.

@spacys spacys changed the title Question: Different results between Windows and Linux Different results between Windows and Linux Apr 5, 2020
@glennguy
Copy link
Contributor

glennguy commented Apr 6, 2020

It's hard to say without seeing a full log. Best guess based on your snippet is that inputstream.adaptive is not present, not loading or is disabled.

Also li.setInfo('video', '') should be `li.setInfo('video', {})

@spacys
Copy link
Author

spacys commented Apr 6, 2020

Thanks glennguy for the feedback. I tried it with {}, but same results. Attached you can find the log.
Please let me know if you need more information.
Inputstream is installed and active.

Kodi actions was:

  • navigate to the song, left click (PAPlayer default action)
  • right click on the song -> Play using... -> PAPlayer selected

Only with 2nd action the communication to Amazon was started.

win_kodi.log

@glennguy
Copy link
Contributor

glennguy commented Apr 6, 2020

Looks like IA was invoked correctly compared to the snippet above - license request is happening.

VMP cannot be overcome... You mention that users report it's working in Ubuntu though - you need to check this yourself I think.

VMP error isn't the fault of inputstream adaptive or Kodi. Unless there's a different endpoint from Amazon that will provide a playlist and license that has VMP disabled you'll be limited to Android devices :(

@spacys
Copy link
Author

spacys commented Apr 6, 2020

I guess VMP is just an result, not the root cause. I have Ubuntu and Win10 and can compare both systems. So the same code is running fine on Ubuntu but not on Win10. Default action on Win10 to play a song will not invoke IA, this looks strange to me and I dont know why. Maybe this has something to do with Kodi itself.
On the other hand I assume IA is converting the parameters in a different way than on Ubuntu. Is there a chance to see what IA will send to Amazon? Like comparison of input and output parameter, especially the header.
Feedback of Amazon is "Bad Request", means there was something changed in between.

@glennguy
Copy link
Contributor

glennguy commented Apr 6, 2020

Sorry I misread you earlier post...

I find the easiest way is to run Kodi traffic through mitmproxy. You'll need to add the mitmproxy cacert to program files\kodi\system\certs\cacert.pem . I'm running Windows 10 as well, and have an Ubuntu VM set up for this. You can then inspect the communication with the widevine license server.

The data payload will always be different but yes maybe the headers are slightly different.

Just get mitmproxy up and running on you ubuntu machine, start it with the -k option, download the cert to your windows machine and get it added to Kodi's certs, then set Kodi proxy to ubuntu machine. You need to restart Kodi for the changes to fully take effect.

@spacys
Copy link
Author

spacys commented Apr 6, 2020

So it is up and running but I receive
SSL: CERTIFICATE_VERIFY_FAILED
How can I resolve this?

@yoshimo
Copy link

yoshimo commented Apr 6, 2020

Sounds like you didn't properly mark it as trusted in kodi.

@spacys
Copy link
Author

spacys commented Apr 6, 2020

That is exactly my question...how to do this. The cacert is added to cacert.pem. Is there something more to do?

@glennguy
Copy link
Contributor

glennguy commented Apr 6, 2020

Ah yes in python if you're using requests you'll also need to set 'verify=False' for your requests and/or Session. Not sure how it's done for urllib2. Or you could point requests to use the cacert.pem in the Kodi folder

@spacys
Copy link
Author

spacys commented Apr 7, 2020

Now I was able to capture the communication (nice tool) and compared every parameter. Looks good, all parameters (Header, Cookie, Body) are 100% identical.
But I identified two issues:

  1. VMP validation error on Windows
  2. Kodi is not invoking IA correctly with default action for playback (as described above)

I suggest to focus on the VMP validation error first.

@glennguy
Copy link
Contributor

glennguy commented Apr 7, 2020

  1. I don't think the issue is with inputstream adaptive - Kodi is responsible for setting/invoking inputstream add-ons. Most likely an issue with the add-on code. You'll get a lot more eyes on it if you post about it in the Kodi Forum.

  2. No idea! I don't know if VMP can be set per platform on widevines side. But there's no way to bypass it for users.

@spacys
Copy link
Author

spacys commented Apr 8, 2020

Regarding my point "Kodi invoking IA" I fully agree and will check this separately.

Your 2nd point I not fully understood and I do not have deep insides of IA. What I see all my parameters are fully transfered and the only change is the licensechallenge. I saw differences in the platform identifier and the widevine version and maybe there are some more.

Edit:
I found this widevine news with the comment:
"All Widevine browser-based integrations (platforms and applications) must support VMP. VMP support is NOT available for Linux platforms."

Sound this is the reason why it works under Linux. Is there a chance to parametrize the platform identifier?

And in addition to take the payload of the certifcate in consideration like this?

@glennguy
Copy link
Contributor

Is there a chance to parametrize the platform identifier?

The challenge is generated from the CDM so no unfortunately.

And in addition to take the payload of the certifcate in consideration like this?

You can supply the server certificate with the inputstream.adaptive.server_certificate listitem property

@spacys
Copy link
Author

spacys commented May 1, 2020

The Windows issue is related to VMP but I dont know why it's not working on Libreelec. Maybe it is the same root cause.
Nevertheless I dont believe it has something to do with inputstream.adaptive. Therefore I will close this issue. Thanks for the support.

@MPParsley
Copy link

Hi @spacys, I could not find an issue in the spacys/mediathek issue queue, did you manage to solve this issue?

I noticed you commented out this line:

            #li.setProperty('inputstream.adaptive.server_certificate', scert)

Also, what certificate value is supposed to be used here (one from the manifest)?

@spacys
Copy link
Author

spacys commented Feb 7, 2021

@MPParsley, it is working on Linux systems and the restictions are mentioned in the readme file as known issues. In my case a separate certificate is not necessary, therefore it's commented out. I still believe it's related to VMP validation, see few comments above.

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

4 participants