How to add query string to <BaseURL> in mpeg-dash? - mpeg-dash

I am trying to play the video with mpeg-dash, indeed, the source video must be accessed with signed query strings , so I appended query strings to <BaseURL> tag like the following dash file , but it does not work well.
<AdaptationSet id="1" contentType="video" maxWidth="1280" maxHeight="720" frameRate="90000/3750" subsegmentAlignment="true" par="16:9">
<Representation id="1" bandwidth="1168165" codecs="avc1.64000d" mimeType="video/mp4" sar="1:1" width="320" height="180">
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="41b2cf69-7a0e-46bb-9b56-45ac2e775a26"/>
<ContentProtection schemeIdUri="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
<cenc:pssh>AAAANXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABUiEzUyODU4OTA3OTMxMTczOTkzNDk=</cenc:pssh>
</ContentProtection>
<BaseURL>1.mp4?t=5d662215&sign=e2ec251dd73ac43afd377ddf849ba81d</BaseURL>
<SegmentBase indexRange="1133-1944" timescale="90000">
<Initialization range="0-1132"/>
</SegmentBase>
</Representation>
</AdaptationSet>
So how can I make the player access 1.mp4 with query strings t and sign ?Thanks for your help.

You need to escape the '&' in you query string with '&'.
So try:
<BaseURL>1.mp4?t=5d662215&sign=e2ec251dd73ac43afd377ddf849ba81d</BaseURL>
Guidelines for Implementation: DASH-IF Interoperability Points (Version 4.3)
Give an example for the use of query parameters:
5.3.3.2.1.2. Example 2: Stateful cue translation
The operator targets separately male and female audiences. Hence, the generator derives this from
the information it has regarding the requesting client (see 5.1.3.6), and inserts an XLink URL with
the query parameter ?gender=male for male viewers, and ?gender=female for the female viewers.

Related

How can I decode/recreate Google Flights Search URLs?

The Problem
On Google Flights, search information is encoded in a URL parameter, presumably so users can share flight searches with each other easily.
The URL format looks like this:
https://www.google.com/travel/flights/search?tfs=CBwQAhoeagcIARIDSE5MEgoyMDIxLTA5LTEzcgcIARIDU0ZPGh5qBwgBEgNTRk8SCjIwMjEtMDktMTdyBwgBEgNITkxwAYIBCwj___________8BQAFIAZgBAQ
I am trying to write a program that can generate flight search URLs given flight information (origin, destination, flight dates, passengers, etc). To do this I need know how the information is encoded in the URL so I can recreate it.
What I've tried
I know that the flight info is encoded in base64 or some variant of it (I've been using base64decode.org for testing). For a round-trip flight from HNL-SFO on 2021-09-13 - 2021-09-17, Google Flights has this URL:
https://www.google.com/travel/flights/search?tfs=CBwQAhoeagcIARIDSE5MEgoyMDIxLTA5LTEzcgcIARIDU0ZPGh5qBwgBEgNTRk8SCjIwMjEtMDktMTdyBwgBEgNITkxwAYIBCwj___________8BQAFIAZgBAQ
The part of the tfs query parameter before the underscores decodes to
jHNL
2021-09-13rSFOjSFO
2021-09-17rHNLp
which contains some (but not all) recognizable flight info. What I don't understand is the whitespace between the recognizable information. Using this site, I learned that the whitespace is a mix of characters:
U+0008 : <control> BACKSPACE [BS]
U+001C : <control> INFORMATION SEPARATOR FOUR {file separator (FS)}
U+0010 : <control> DATA LINK ESCAPE [DLE]
U+0002 : <control> START OF TEXT [STX]
U+001A : <control> SUBSTITUTE [SUB]
U+001E : <control> INFORMATION SEPARATOR TWO {record separator (RS)}
U+006A : LATIN SMALL LETTER J
U+0007 : <control> BELL [BEL]
U+0008 : <control> BACKSPACE [BS]
U+0001 : <control> START OF HEADING [SOH]
U+0012 : <control> DEVICE CONTROL TWO [DC2]
U+0003 : <control> END OF TEXT [ETX]
U+0048 : LATIN CAPITAL LETTER H
U+004E : LATIN CAPITAL LETTER N
U+004C : LATIN CAPITAL LETTER L
...
This suggests that I'm not decoding the data properly. I've tried some other variants of base64, but haven't had any luck.
Does anyone know how this info is encoded? Another thing I haven't been able to figure out is how the information after the underscores (8BQAFIAZgBAQ) is encoded. Based on the behavior of the Google Flights site, I think it encodes passenger information, but it base64 decodes to only whitespace characters.
Additional Context
Two years ago I made a working version of the program which produced URLs like
https://www.google.com/flights?hl=en#flt=ORD.MCO.2021-07-16*MCO.ORD.2021-07-19;c:USD;e:1;px:2,2,0,0;sd:1;t:f
Several months ago Google changed the format they use from the above to the encoded version. I want to figure out how to recreate the encoded URLs so I can update my program instead of retiring it.
You can have your program output flight URLs in query format using the q URL param. No need to encode/decode the URL.
For example:
https://www.google.com/travel/flights?q=Flights%20to%20SFO%20from%20HNL%20on%202022-09-13%20through%202022-09-17
Which leads to the results page: HNL <> SFO Flight Results
I miss having the ability to encode a query and have the same question. Nice work with finding out it's in base64.
I think reverse engineering is the only way to find out how things are encoded. For example, the stuff after the underlines is most likely binary-encoded.
See the below for economy:
11101111 10111111 10111101 00010100 00000000 00010100 11101111 10111111 10111101 00011001 11101111 10111111 10111101 00010000 00010000
And the same query but for for business class
11101111 10111111 10111101 00010100 00000000 00010100 11101111 10111111 10111101 00101001 11101111 10111111 10111101 00010000 00010000
As you can see the 10th byte goes from 00011001 to 10111101

Use custom parameters in JSON Layout [Log4j 2]

I'm confused about the meaning of property substitution, lookups and layout parameters in Log4j 2. The documentation mentions that JSON layout supports custom fields. However it doesn't seem to support conversion patterns like %d{ISO8601}, %m, %l and the like. it does however support Lookups.
Thus when I define in the xml:
<JsonLayout complete="false" compact="false">
<KeyValuePair key="#timestamp" value="%d{ISO8601}" />
<KeyValuePair key="message" value="%message" />
<KeyValuePair key="process.thread.name" value="%tn" />
</JsonLayout >
As output I simply get the strings %d{ISO8601}, %message... instead of the values.
What I'm trying to achieve is a JSON layout where I can include parameters similar to Pattern Layout where I simply write <pattern>%d %p %C{1.} [%t] %m%n</pattern> to get what I want. Or, alternatively, should I use the Pattern layout and stitch together a string in JSON Format, making use of the Pattern Layout's JSON encoding %enc{%m}{JSON}?
The GelfLayout currently supports a messagePattern attribute that will format just the message field in the JSON using the patternLayout. I have planned to add this to the JSONLayout as well but have not done it yet. There is a new JsonTemplateLayout that is in the final stages of being merged into Log4j 2 that will also support this. You could either work from the current pull request to get the Layout or wait for the Log4j 2.14.0 release when likely both options will be available.

Copy elements using xsl:copy-of without attributes

I have a xml like shown below
<?xml version="1.0" encoding="UTF-8"?>
<schools>
<city>Marshall</city>
<state>Maryland</state>
<highschool>
<schoolname>Marshalls</schoolname>
<department id="1">
<deptCode seq="1">D1</deptCode>
<deptName seq="2">Chemistry</deptName>
<deptHead seq="3">Henry Carl</deptHead>
<deptRank seq="4">L</deptRank>
</department>
<department id="2">
..
..
..
</highschool>
</schools>
In XSL i am copying the contents from department based on deptCode using
<xsl:copy-of select="*">
This produces result with all the attributes in the element tags.
Is it possible to ignore the attributes while using xsl:copy-of?
The desired result is like shown below
<deptCode>D1</deptCode>
<deptName>Chemistry</deptName>
<deptHead>Henry Carl</deptHead>
<deptRank>L</deptRank>
xsl:valueOf is working as required but i am trying to know if it
can be done with in xsl:copy-of? As a note, in my requirement, there are nearly 5 or 6 attributes for each element. Can someone please help? Thanks in Advance..
regards
Udayakiran
xsl:valueOf is working as required but i am trying to know if it can
be done with in xsl:copy-of?
No. xsl:copy-of is a package deal, you cannot pick and choose. To avoid repetitive coding, use a template matching department/*.

How to create XML in Google custom search Autocomplete?

I try to use the structure at https://developers.google.com/custom-search/docs/queries but it can't upload successfully.
<Autocompletions>
<Autocompletion term="cake" type="1" language=""/>
<Autocompletion term="strawberry.*" type="2" match="2" language=""/>
<Autocompletion term="vanilla" type="2" language=""/>
<Autocompletion term="apple" type="3" language="">
<Promotion id="1" queries="dessert" title="Apple pie for dessert!" url="http://www.example.com/applepieforsale"
start_date="" end_date="" image_url="" description="Apple pie is the best dessert ever!"/>
<Promotion id="2" queries="apple" title="Buy Apple pie" url="http://www.example.com/applepieforsale"
start_date="" end_date="" image_url="" description="We stock the best apple pie in the world, right here."/>
</Autocompletion>
</Autocompletions>
My website is using wordpress; I get the title of posts and want to use it as string query for google custom search.
Please help me figure out how to create XML for autocomplete.
It's not liking the description attributes. It you remove those, then it will work.
Leave all terms in XML like that:
<Autocompletion term="%term-title%" type="%type%" language=""/>
Be careful with the length of the terms, I found that if it is 3 or less words, Google will accept it fine. There is also no big restriction on ammount of entries you're adding (I added 9000 entries in one go). And I added them in Russian, so there are no problems with encoding either.
The final format should be like that:
<Autocompletions>
<Autocompletion term="%term-title%" type="%type%" language=""/>
...
<Autocompletion term="%term-title%" type="%type%" language=""/>
</Autocompletions>
Not terribly well documented by Google, so you have to waste time reading this. Hope it helps :)

Parsing Tableau xml does not preserve original file

I try to work programmatically on Tableau desktop file (which are just xml file in spite of their .twb extension). I have many problem with lxml which doesn't preserve original content. To facilitate the explanation, imagine you have a test.xml file which contain the following text:
<column caption='Choix Découpage' name='[Aujourd&apos;Hui Parameter (copy 2)]'>
<member name='Nb d&apos;annulations' default-format='n#,##0.00" annulations";-#,##0.00" annulations"' />
<run>
:</run>
<calculation formula='iif([FAC_TYPE] = &apos;Avoir&apos; , [Calculation_1378101492427309057], null)' />
<alias key='"Billetterie Ferroviaire"' value='Train ticketing' />
</column>
Now let's parse it:
tree = etree.parse('test.xml')
root = tree.getroot()
print(etree.tostring(root,pretty_print=True,).decode("utf-8"))
When you run the code we can notice:
' becomes "
é becomes é Edit: resolved for this part
&apos; becomes '
How could i preserve the original ? (It would help me a lot when i try to check the diff with git in spite of showing all the useless change that are operated automatically)
Edit: I notice an other problem, when i run the folowing code:
[node.attrib['key'] for node in root.xpath("//alias")]
I got the result: ['"Billetterie Ferroviaire"'] and I am now unable to query with xpath if i am looking for the node whose attribute "key" is the original "Billetterie Ferroviaire" (root.xpath('//[#key="Billetterie Ferroviaire"]) doesn't work)

Resources