how to Wrapping License Requests to drmtoday server via python - wrapper

i'm trying to simulate drm media playing in python so i start with this demo from castlab "https://demo.castlabs.com/" and the video that i'm testing it is in MPEG-DASH format and drm system is widevine provided via cenc (if is that how to say it) , here is the url of the video
https://demo.cf.castlabs.com/media/msspr/Manifest?v=5.1.38
key id is :
8bdf77c0-5665-46c5-8ec8-422e571fc000
and the pssh is :
AAAAVHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADQIARIQi993wFZlRsWOyEIuVx/AABoIY2FzdGxhYnMiEIvfd8BWZUbFjshCLlcfwAAqAlNE
schemeIdUri (widevine) is :
edef8ba9-79d6-4ace-a3c8-27dcd51d21ed
and the drm server url :
https://lic.staging.drmtoday.com/license-proxy-widevine/cenc/
the drm server need an custom header witch is :
dt-custom-data: eyJ1c2VySWQiOiJwdXJjaGFzZSIsInNlc3Npb25JZCI6InAwIiwibWVyY2hhbnQiOiJzaXgifQ==
and never change its base64 encoded from :
{"userId":"purchase","sessionId":"p0","merchant":"six"}
and it also need the body request or payload request , and thats where my problem is
i was able to catch the body request in arraybuffer from chrom developer tool and converted to base64 an this is what i find
CAESyR8STApKCjQIARIQi993wFZlRsWOyEIuVx/AABoIY2FzdGxhYnMiEIvfd8BWZUbFjshCLlcfwAAqAlNEEAEaEO9+id0bff5JFPIQdYcCqRoYASDtl+rzBTAVQu4eChJzdGFnaW5nLmdvb2dsZS5jb20SEChwNFTACPY2GK3nRD22xMgasByr1bNXgrfr+XFlzU+UcctZsvWfVXNmF9vKXmkIBD7/Ivlx6fq7KNVx/izq28XI3axu6FPqPgb4NUTURq0SeuJnYzLLPItXccgCeZrgpqBbXoxLy716wO10/mIMTyb4pIMNoPVHdnm08MD+vKIYY0Xm7ZQ4ZYSljcDolY8tePvDD+hsJSZ+BDLJiQ57PQHSsrjAH90F6N3TIK0RgEAXk+Sm9oe1qQa4W9QQQQq6SUsLqAL/mtdFDkK6m3m3Wn9ArUUwiytpsM+FPrsgmRkMnGKxLPtX9iQdQAc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5hb12sXWfg0nqd/m7OB7giBncDH3B/4qTMP8saCR3p3WKf8M0bEoDYLRnKHULbke7n+B4GzPM4iwqSxT1WJaydKgdQdsD3zmLXwTVTXD+k669JtxP0hxFT9jK+NAOOaUV/3ITCGzO5H2CetI534549s8HY+CYLZdofc4Ozzi8u3C3ix8AA+7oc73+uNhr8Nj7Z6jTsrlvOXoevW7UVVB0CzVufK9gfnzAodK+CO2tWzyIQLn7uNn6/Yd4XwCkDQPR4qCqAAiZNMFcg8nC83o6ZkZC5ofOoVkHs+zwpHS2fQ/dBj8BqJqAxjmnOnKS+vX3rZ8u4C/6VRIa3sqhMjbnQgEVO6NJ4kKKBk/9saU34eBXkEKLH3Trcph9KUxyt7FG0XcPc6QcmSrtPPu17Az7ght5GpAhk02DSq3s6jAKx3C6JlunHEr/HhBclL83n8BNia76ArZ7Hs291kd68sysS5edaw4plPyN9hL9wgBc1D79wFVC9yYlgP7z/XOdSiF4N1z35G5nl6UxBvtdqYTLYCw2+LG3Vhznf7GdCel5keCoM/g5doWyi2FqRyTshYdcfk2jseYJ96tC3BE64UwT20WlSYwwagAKSEYJ37jGNCidW/AJHF4H3gKxhNVWSAqun5aY2ZJum9y6R20zlDr269U496Fplcb1wEWgLWBJVgd1yVpbhPR8JbaIPMenOsPO4h/XlKHq/LxsqFL9J/X5V1kwjerBkFdHneb93HCe1nTdyczNMwPymkm1LxinLMG1eJ7Y8YDlWWlFVXQJN7hIH2TUuozxDZTnC9XFfSRdNIjagWu2fujKrZjV+KjqD7VztIocL5LaYLnxPobQsSNGDqTih6qwU6EhHv90e2e1BT5G0yW7RIMYfe83SfW1lyoXWxq/YZieapVolSTY1rQ6zNVcsG0GmBDzm2ZVVKS5PCOuZiW6t4q+T
i really don't know how this code was formed i know that it converted to arraybuffer "Unit8 and "int8" and used as body request to the server , i coped this base64 code and try to decoded in this site "https://tools.axinom.com/decoders/LicenseRequest" and it give me information about the license request like Certificate and Serial Number and the signature plus the pssh data and content id , algorithm (AES-CTR)
now since most of the information that are stored in that base64 code are in my hand (pssh,kid,system id), i want to know how to create\build\wrapper the request in the same way that base64 code was build to use it in python

The request is generated by interacting with the CDM in the browser via the EME API: https://w3c.github.io/encrypted-media/. You can learn more by using this: https://chrome.google.com/webstore/detail/eme-call-and-event-logger/cniohcjecdcdhgmlofniddfoeokbpbpb
Maybe this helps to call Chromium from Python: Python - how to load Google Chrome or Chromium browser in the gtk.Window like webkit.WebView()?
You would also need to take care to enable Widevine in CEF, and there might be limitations associated with that because of some signature verification process. See
https://bitbucket.org/chromiumembedded/cef/src/master/include/cef_web_plugin.h#lines-168
and look for "VMP" here: https://github.com/castlabs/electron-releases

Related

Can't send a binary attachment to Slack using LogicApp

I'm trying to use a logicapp to get the content of an email and post it to slack. By content I mean:
the body of the email and other elements like From:, Subject:
any attachment in the email (which usually are binary like PDF, Excel, image)
the email itself saved in a blob as .eml file
Slack chat.postMessage API works without any problem to send any text element. This API has some attachment argument but doesn't seemto be designed or binary files (or not for files at all, only strings)
I've tried slack files.upload one but couldn't figure out the syntax, especially the syntax using a regular HTTP POST. Could find examples online using curl, Python, JS and C# SDK but I don't know how to translate them to HTTP POST just like I do with chat.PostMessage
I've tried the API on SOAP UI, using file as argument as per the documentation, and I've used it in different sections: in the header, in the body, and using the Attachment Tab, none of the work and always the same error message : no_file_data
Unfortuatelly slack documentation lacks of details. Here's what it says about files.upload:
You must provide either a file or content parameter.
The content of the file can either be posted using an enctype of multipart/form-data (with the file parameter named file), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var called content. The latter should be used for creating a "file" from a long message/paste and forces "editable" mode.
In both cases, the type of data in the file will be intuited from the
filename and the magic bytes in the file, for supported formats.
I could use alternatives like just saving the attachments in blobs and use Azure functions to send the file, but I want to understand what's the limitations before changing the method.
Any clue?

How to implement XML-safe private Amazon S3 URLs?

On my photography website, I am storing photos on Amazon S3. To actually display them on the website, I am using signed URLs. This means that image URLs expire. Only the web application itself is able to generate valid image file URLs.
An example URL would look like this:
http://media.jungledragon.com/images/1849/21346_small.JPG?AWSAccessKeyId=05GMT0V3GWVNE7GGM1R2&Expires=1411603210&Signature=9MMO3zEXECtvB0w%2FuMEN8obt1ow%3D
Note that by the time you read this, that URL may have already expired. That's ok, the question is about the format.
Whilst the above URL format works fine on the website, it breaks XML files. The reason for this is the & character, which should be escaped.
For example, I'm trying to implement Windows 8.1 live tiles for the website, which you can link to an RSS feed. My RSS feed is here:
http://www.jungledragon.com/all/rss/promoted
That feed will work in most RSS readers, however, the Windows 8 tile builder (http://www.buildmypinnedsite.com/en) is particularly strict about the XML being valid. Here you can see the error it throws on said feed:
http://notifications.buildmypinnedsite.com/?feed=http://www.jungledragon.com/all/rss/promoted&id=1
Now, my simple thinking was to encode the & that are part of the signed URLs, by & or &. Whilst that may make the XML valid, unfortunately S3 does not accept & to be encoded. When used like that, the image will no longer load.
I'm wondering whether I am in a circular problem that cannot be solved?
I have had many similar problems with RSS feeds. XML documents should always use & (or an equivalent like & or &). If a reader is not capable of extracting the URL properly, then the reader is the culprit, not you. But I can tell you that reader programmers will disagree with you.
If you are a programmer, you could fix the problem by having a redirect, but that's a bit of work. So you'd retrieve the URL from S3, save that in your database and create a URL on your website such as http://www.jungledragon.com/images/123 and link the S3 URL with your images/123 page. Now when someone goes to page images/123, you retrieve the URL you saved from your S3 server.
Actually, if the URL http://www.jungledragon.com/images/123 is a reference to your image, you can get the S3 URL at that time and do the redirect on the fly!

Get request headers to validate analytics in a website

I have to perform testing through selenium webdriver(java) on Site analytics of a website. All the attributes, values are sent to the analytics toold via URL header request. I would like to capture the request alone so that I can perform my manipulations and extract the attributes and their values.
I tried BrowserMob tool. It's getting me the entire traffic in the form of HAR file. is there a way to extract the request alone?
I tried server.setCaptureHeaders(true); but it didn't help much as I see a whole bunch of URLs in the HAR. I'm interested in only one that is sent to the analytics website. There is a URL thats sent as a request behind the scene. Few analytics plugin are able to exactly get the request URL and extract the attribute values but I can't automate through those plugins.
Or is there a way to rip off only certain requests from HAR?
BMP is a great tool. You can only create a new har before the request is sent and read it after this. You can iterate through the dict it returns and find the request you need

OAuth 1.0 binary data upload with RESTful api

I have a DESKTOP application which interacts with a web service through their RESTful api and OAuth 1.0. I can use all the resources fine, authentication, get/post calls to retrieve and send simple text data etc, no problems there.
However, I'm struggling to send binary data. The service allows sending pictures. For one part, they have a non-OAuth api through which you can also send a file in plain binary, simply pass some params in the URL and put the entire binary file in the post.
Now to do this through the OAuth api, becomes an issue:
The service specifies the post needs 2 parameters (not to be included in the URL since this is REST, but in the POST parameters):
image A binary file, base64 data, or a URL
type The type of file that's being sent in. Accepted values: file, base64, url
So we have 2 parameters: image contains the file itself, and type would be "file" to specify binary. But how am I supposed to include this through OAuth? given that the -image- and -type- parameters (and their values) must be used to generate the base string for the signature, which is matched against the parameters included in the POST.. I can't include the entire binary there as a value for the image parameter; so how is it done in this case?
nvm, their OAuth api expects the file as multipart/form-data with the variables there, and none in the base string for the signature (their non-OAuth api instead doesn't need multipart, so I expected their OAuth wouldn't either; their documentation is a bit lacking in this area).

Requesting header information of a file

is there anyway I can request only the header information of any media. For example I just want to request header information of any video file so as to find its video length. I tried using ffmpeg -i {video_url} and did the work but I noticed that it actually downloads the given media in local storage and returns back the header information which obviously increases roundtrip time.
So I would really appreciate if there is any idea for finding the length of media in a fly. BTW I have a ruby on rails application where I need to implement this.
You could try with ffprobe -show_format. ffprobe comes with ffmpeg, and should have been compiled and installed along with it.
You can also try mediainfo. you can download it from: http://mediainfo.sourceforge.net/en.
There is also a wrapper gem for mediainfo but it didn't work well for me. I just used:
response = '#{mediainfo_path} #{source.path} --output=json 2>&1'
and you can then search the response for the properties you want such as "duration" etc.