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

Base64-encoded headers are getting destroyed; license server returns HTTP error 400 #1076

Closed
1 of 7 tasks
sunsettrack4 opened this issue Dec 10, 2022 · 1 comment
Closed
1 of 7 tasks

Comments

@sunsettrack4
Copy link

Bug report

Describe the bug

The header values are encoded in base64. Inputstream adds the custom headers, but special characters just like "=" or "+" are getting removed automatically.

Expected Behavior

The original base64-encoded strings are used to send the authorization headers to the license server => HTTP 200.

Actual Behavior

The behavior mentioned above results in invalid base64 strings being rejected by the license server. HTTP 400

Possible Fix

Please add an option to add the original header values instead.

To Reproduce

Steps to reproduce the behavior - please find my code below:

license_url = "https://licf-iptv.dmm.t-online.de/v1.0/WidevineLicenseAcquisition.ashx"
            
lapb = '<lapb version="2"><contentNo>' + c_no + '</contentNo><profile>sl-windows</profile><auth type="sts">' + session["access_token"] + '</auth><agent>WEB-MTV</agent><recovery allow="false"/><requestId>' + str(uuid4()) + '</requestId><serviceId>MAGENTATVAPP</serviceId></lapb>'            
lapb_encoded = b64encode(lapb.encode()).decode()

device_id = session["deviceId"]
device_id_encoded = b64encode(device_id.encode()).decode()

li.setProperty('inputstream.adaptive.license_key', license_url + "|" + f'CustomDeviceId={device_id_encoded}&LAPB={lapb_encoded}' + "|R{SSM}|")
li.setProperty('inputstream.adaptive.license_type', "com.widevine.alpha")

li.setProperty('inputstream', 'inputstream.adaptive')
li.setProperty('inputstream.adaptive.manifest_type', 'mpd')
li.setProperty("IsPlayable", "true")

Debuglog

The debuglog can be found here:

2022-12-10 23:47:18.769 T:15924   DEBUG <general>: AddOnLog: inputstream.adaptive: CDMMessage: 1 arrived!
2022-12-10 23:47:18.769 T:15924   DEBUG <general>: AddOnLog: inputstream.adaptive: SetSession: opened session with Id: 9B5E4AF56AD7C560C5C964DA1856DF30
2022-12-10 23:47:18.775 T:15924   DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'CustomDeviceId: NjUyYTEyZjgtNWM2Ni0zNDlmLWEwNTAtN2M4MzA2N2ExN2E2'
2022-12-10 23:47:18.775 T:15924   DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'Expect: '
2022-12-10 23:47:18.776 T:15924   DEBUG <general>: CurlFile::ParseAndCorrectUrl() adding custom header option 'LAPB: PGxhcGIgdmVyc2lvbj0iMiI PGNvbnRlbnRObz45MjIxNDM4MzQyOTQxMTUzNDEzPC9jb250ZW50Tm8 PHByb2ZpbGU c2wtd2luZG93czwvcHJvZmlsZT48YXV0aCB0eXBlPSJzdHMiPkVDRE1QejN1Q1Z0TlQ1RFRyc1lrVDlSWEFBRUhxQUFBQVlULU9LVWJBQUFCaFA2bWdoc0JBQWdBQUFHRV9qaWFNZGVCTXgxV3JQV1FrOGJlT05CZzZ3UlpJaGNTQVF3U0FFa0JBQUFBQXpGQ0JTUVRKUUJiQVFSbmRXbGtBQmd4TURBd05Ea3dNVGN6TURBd05Ea3pOVFV6TlRBd01ERUJCbTFvYTJSdWNnQUtOek13TURjNU5EWXpPQUVFYm1GdFpRQUhUbVYxYldGdWJnRUVkWE4wWVFBQk1RRUVlblZ6WVFBSVNtRnVMVXgxWTJFQkJuTjBjMTlsY3dBc2IxTkZVemxVU25ab0wyNUxNVVpKVDA1YVkycEhVSGN5TDFodVJFOWxZVWxNYWk5SGExSjVWVGw2T0QwQ0FTa0NBSEVDQUZFQ0JoY0NEcFlDQVVjQ0RvTUNqbjhDRHBjQ0RwUUNEZHdDRG1NQ0RvQUNqb1VDam9FQ0RtVUNBZ1VDQWdNQ0FnRUNBZ2NDRHBFQ0RsNENEbDBDRGxzQ0RoZ0NEamtDRG5ZQ0RqMENEbG9DRGg0Q0RoWUNEbTBDRG1zQ0RtOENEZUVDRGtRQ0RrTUNEaVFDQlZzQ0RnMENEZkVDRGZNQ0RmSUNEZVVDRGVRQ0RtUUNEaU1DRFlRQ0Rnd0NnaE1DZ2hFQ0RtWUNEaVlDRGc4Q0RZZ0NEaVVDRFpBQ0RnNENEWXdDam5nQ2pua0NEaWdDRGhBQ0RaZ0NEWlFDRG9rQ0RuSUNEaThDRGk0Q0RqY0NEaTBDRGl3Q0RqZ0NEaWtDRGVZQ0RmVUNEZWdDRGVjQ0RpY0NEWm9DRFp3Q0RtNENEbXdDQTgwQ0E3a0FBQT09PC9hdXRoPjxhZ2VudD5XRUItTVRWPC9hZ2VudD48cmVjb3ZlcnkgYWxsb3c9ImZhbHNlIi8 PHJlcXVlc3RJZD44M2MzNGM4OC01NWE0LTRmYjktYjhlZC0xYjRlMjdkOTc3NTc8L3JlcXVlc3RJZD48c2VydmljZUlkPk1BR0VOVEFUVkFQUDwvc2VydmljZUlkPjwvbGFwYj4'
2022-12-10 23:47:18.776 T:15924   DEBUG <general>: CurlFile::Open(0x16293e3ac40) https://licf-iptv.dmm.t-online.de/v1.0/WidevineLicenseAcquisition.ashx
2022-12-10 23:47:18.776 T:15924   DEBUG <general>: XCURL::DllLibCurlGlobal::easy_acquire - Created session to https://licf-iptv.dmm.t-online.de
2022-12-10 23:47:19.108 T:15924   ERROR <general>: CCurlFile::FillBuffer - Failed: HTTP returned error 400
2022-12-10 23:47:19.108 T:15924   ERROR <general>: CCurlFile::Open failed with code 400 for https://licf-iptv.dmm.t-online.de/v1.0/WidevineLicenseAcquisition.ashx:
                                                   
2022-12-10 23:47:19.108 T:15924   ERROR <general>: AddOnLog: inputstream.adaptive: License server returned failure

MPD/M3U8s/ISM

<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Unified Streaming Platform(version=1.8.4) -->
<MPD
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="urn:mpeg:dash:schema:mpd:2011"
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
  xmlns:cenc="urn:mpeg:cenc:2013"
  xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd"
  type="static"
  mediaPresentationDuration="PT2H41M30.400S"
  maxSegmentDuration="PT1M"
  minBufferTime="PT10S"
  profiles="urn:mpeg:dash:profile:isoff-live:2011,urn:com:dashif:dash264">
  <Period
    id="1"
    duration="PT2H41M30.400S">
    <BaseURL>dash/</BaseURL>
    <AdaptationSet
      id="1"
      group="1"
      contentType="audio"
      lang="de"
      segmentAlignment="true"
      audioSamplingRate="48000"
      mimeType="audio/mp4"
      codecs="mp4a.40.2"
      startWithSAP="1">
      <AudioChannelConfiguration
        schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011"
        value="2">
      </AudioChannelConfiguration>
      <!-- Common Encryption -->
      <ContentProtection
        schemeIdUri="urn:mpeg:dash:mp4protection:2011"
        value="cenc"
        cenc:default_KID="8B18D2F8-E317-46D9-98BB-2B0B131648B9">
      </ContentProtection>
      <!-- PlayReady -->
      <ContentProtection
        schemeIdUri="urn:uuid:9A04F079-9840-4286-AB92-E65BE0885F95"
        value="MSPR 2.0">
      </ContentProtection>
      <!-- Widevine -->
      <ContentProtection
        schemeIdUri="urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED">
      </ContentProtection>
      <!-- Marlin -->
      <ContentProtection
        schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
<mas:MarlinContentIds>
  <mas:MarlinContentId>urn:marlin:kid:8b18d2f8e31746d998bb2b0b131648b9</mas:MarlinContentId>
</mas:MarlinContentIds>
      </ContentProtection>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate
        timescale="48000"
        initialization="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$.dash?streamProfile=NGTV-OTT"
        media="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$-$Time$.dash?streamProfile=NGTV-OTT">
        <SegmentTimeline>
          <S t="0" d="96255" />
          <S d="96257" />
          <S d="96256" />
          .....
</SegmentTemplate>
      <Representation
        id="audio_deu_1=224000"
        bandwidth="224000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      id="3"
      group="1"
      contentType="audio"
      lang="en"
      segmentAlignment="true"
      audioSamplingRate="48000"
      mimeType="audio/mp4"
      codecs="ec-3"
      startWithSAP="1">
      <AudioChannelConfiguration
        schemeIdUri="urn:dolby:dash:audio_channel_configuration:2011"
        value="F801">
      </AudioChannelConfiguration>
      <!-- Common Encryption -->
      <ContentProtection
        schemeIdUri="urn:mpeg:dash:mp4protection:2011"
        value="cenc"
        cenc:default_KID="8B18D2F8-E317-46D9-98BB-2B0B131648B9">
      </ContentProtection>
      <!-- PlayReady -->
      <ContentProtection
        schemeIdUri="urn:uuid:9A04F079-9840-4286-AB92-E65BE0885F95"
        value="MSPR 2.0">
      </ContentProtection>
      <!-- Widevine -->
      <ContentProtection
        schemeIdUri="urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED">
      </ContentProtection>
      <!-- Marlin -->
      <ContentProtection
        schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
<mas:MarlinContentIds>
  <mas:MarlinContentId>urn:marlin:kid:8b18d2f8e31746d998bb2b0b131648b9</mas:MarlinContentId>
</mas:MarlinContentIds>
      </ContentProtection>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate
        timescale="48000"
        initialization="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$.dash?streamProfile=NGTV-OTT"
        media="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$-$Time$.dash?streamProfile=NGTV-OTT">
        <SegmentTimeline>
          <S t="0" d="96768" />
          <S d="95232" />
          <S d="96768" />
          .....
</SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="audio_eng_1=128000"
        bandwidth="128000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      id="5"
      group="3"
      contentType="text"
      lang="de"
      mimeType="application/mp4"
      codecs="stpp"
      startWithSAP="1">
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="subtitle" />
      <SegmentTemplate
        timescale="1000"
        initialization="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$.dash?streamProfile=NGTV-OTT"
        media="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$-$Time$.dash?streamProfile=NGTV-OTT">
        <SegmentTimeline>
          <S t="0" d="60000" r="155" />
          <S d="52240" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="textstream_deu=1000"
        bandwidth="1000">
      </Representation>
    </AdaptationSet>
    <AdaptationSet
      id="6"
      group="2"
      contentType="video"
      lang="de"
      par="25:14"
      minBandwidth="420377"
      maxBandwidth="9000228"
      maxWidth="1920"
      maxHeight="1080"
      segmentAlignment="true"
      sar="1:1"
      frameRate="25"
      mimeType="video/mp4"
      startWithSAP="1">
      <!-- Common Encryption -->
      <ContentProtection
        schemeIdUri="urn:mpeg:dash:mp4protection:2011"
        value="cenc"
        cenc:default_KID="8B18D2F8-E317-46D9-98BB-2B0B131648B9">
      </ContentProtection>
      <!-- PlayReady -->
      <ContentProtection
        schemeIdUri="urn:uuid:9A04F079-9840-4286-AB92-E65BE0885F95"
        value="MSPR 2.0">
      </ContentProtection>
      <!-- Widevine -->
      <ContentProtection
        schemeIdUri="urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED">
      </ContentProtection>
      <!-- Marlin -->
      <ContentProtection
        schemeIdUri="urn:uuid:5E629AF5-38DA-4063-8977-97FFBD9902D4">
<mas:MarlinContentIds>
  <mas:MarlinContentId>urn:marlin:kid:8b18d2f8e31746d998bb2b0b131648b9</mas:MarlinContentId>
</mas:MarlinContentIds>
      </ContentProtection>
      <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main" />
      <SegmentTemplate
        timescale="25"
        initialization="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$.dash?streamProfile=NGTV-OTT"
        media="The_Hateful_Eight-Main_Movie-9221571562372300096_deu_20_1300k_HD_H_264_ISMV-$RepresentationID$-$Time$.dash?streamProfile=NGTV-OTT">
        <SegmentTimeline>
          <S t="0" d="48" r="5046" />
          <S d="4" />
        </SegmentTimeline>
      </SegmentTemplate>
      <Representation
        id="video_deu=420377"
        bandwidth="420377"
        width="400"
        height="224"
        codecs="avc1.4D4014"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=768409"
        bandwidth="768409"
        width="640"
        height="360"
        codecs="avc1.4D401E"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=1300362"
        bandwidth="1300362"
        width="640"
        height="360"
        codecs="avc1.4D401E"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=2200372"
        bandwidth="2200372"
        width="768"
        height="432"
        codecs="avc1.4D401E"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=3400353"
        bandwidth="3400353"
        width="1280"
        height="720"
        codecs="avc1.4D4020"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=6000294"
        bandwidth="6000294"
        width="1920"
        height="1080"
        codecs="avc1.4D4028"
        scanType="progressive">
      </Representation>
      <Representation
        id="video_deu=9000228"
        bandwidth="9000228"
        width="1920"
        height="1080"
        codecs="avc1.4D4028"
        scanType="progressive">
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>

Additional context or screenshots (if appropriate)

Here is some additional context or explanation that might help:
I try to create a video addon for German Magenta TV - Megathek (VoD section).
Please note that the playback of movie trailers (without Widevine protection) works just fine within Kodi.

Your Environment

Used Operating system:

  • Android

  • iOS

  • tvOS

  • Linux

  • OSX

  • Windows

  • Windows UWP

  • Operating system version/name:

  • Kodi version: 19.4

  • inputstream.adaptive version: 19.0.7

@sunsettrack4 sunsettrack4 changed the title Base64-encoded headers are getting destroyed; license server returns HTTP 400 error Base64-encoded headers are getting destroyed; license server returns HTTP error 400 Dec 10, 2022
@sunsettrack4
Copy link
Author

I fixed the problem by using urllib.parse.quote(string).

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

1 participant