YouTube API chromeless player token expiration - youtube

Summary
I have a Youtube API chromeless player in my Flex/AS3 application. Sometimes I need the player to play movies from Youtube continuously (non-stop).
Issues
After playing for something like 12 or more hours the API token which was generated by the first player initialization request is getting expired.
http://www.youtube.com/apiplayer?version=3&modestbranding=1&autoplay=0
And the issue here is that the API call loadVideoById which is called again after the token is expired can't start playing video, because the token is not getting renewed automatically.
After playing our playlist (each item is getting played by calling to loadVideoById) for something like 4-5 or more hours the video sometimes starts to play and suddenly getting stuck. While no error event is dispatched.
Known Solutions
So for the first issue the solution is to renew the token each 12 hours by unloading the player and loading it again using the API call:
http://www.youtube.com/apiplayer?version=3&modestbranding=1&autoplay=0
For the second issue there are no ideas. Need your help.
The relevant source code
private function CreateYoutubePlayerSWF():void {
...
theYoutubeLoader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
theYoutubeLoader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3&modestbranding=1&autoplay=0"));
...
}
private function PlayPendingVideo():void {
...
theYoutubePlayer.loadVideoById(videoWaitingToPlayInfo.videoWaitingToPlay);
...
}
Requests & Responses
When the player stops playing this is what I get in the fiddler:
"request": {
"method": "GET",
"url": "http://www.youtube.com/get_video?cpn=Lj5HaLu7MzS5kG-T&fmt=35&splay=1&t=vjVQa1PpcFNwMVrYUDFOTTG-7co1uJFo3oyrB-qoP_k=&video_id=j-vJJSqw5Q4&eurl=http%3A%2F%2Fwatchitoo.com%2Fiframe.php%3Fid%3Dwwa-154%26scale%3Dfalse%26layout%3D14&asv=3&el=embedded&ps=chromeless&ptk=youtube_none&noflv=1",
...
"queryString": [
{
"name": "cpn",
"value": "Lj5HaLu7MzS5kG-T"
},
{
"name": "fmt",
"value": "35"
},
{
"name": "splay",
"value": "1"
},
{
"name": "t",
"value": "vjVQa1PpcFNwMVrYUDFOTTG-7co1uJFo3oyrB-qoP_k"
},
{
"name": "video_id",
"value": "j-vJJSqw5Q4"
},
{
"name": "eurl",
"value": "http%3A%2F%2Fwatchitoo.com%2Fiframe.php%3Fid%3Dwwa-154%26scale%3Dfalse%26layout%3D14"
},
{
"name": "asv",
"value": "3"
},
{
"name": "el",
"value": "embedded"
},
{
"name": "ps",
"value": "chromeless"
},
{
"name": "ptk",
"value": "youtube_none"
},
{
"name": "noflv",
"value": "1"
}
"response": {
"status": 410,
"statusText": "Gone",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Wed, 26 Jun 2013 16:32:37 GMT"
},
{
"name": "X-Content-Type-Options",
"value": "nosniff"
},
{
"name": "Server",
"value": "Apache"
},
{
"name": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"name": "Content-Type",
"value": "video/x-flv"
},
{
"name": "Cache-Control",
"value": "no-cache"
},
{
"name": "Content-Length",
"value": "0"
},
{
"name": "Expires",
"value": "Tue, 27 Apr 1971 19:44:06 EST"
}

Related

Paypal sandbox cancel webhook not working

The webhook for a subscription activation BILLING.SUBSCRIPTION.ACTIVATED in the Paypal's sandbox works very well.
Nevertheless, when I'm trying to cancel the subscription from a customer sandbox account, no webhook post is received.
It should be BILLING.SUBSCRIPTION.CANCELLED.
In fact, the status is "pending" from the sandbox admin account:
Does it wait until the subscription's end date in order to send the cancellation?
Or does it wait a few hours for safety reasons?
Here are the details from the paypal sandbox web site:
{
"id": "WH-3BV96304FY002321K-38Y64104YL460680C",
"create_time": "2022-07-04T17:51:34.874Z",
"resource_type": "subscription",
"event_type": "BILLING.SUBSCRIPTION.CANCELLED",
"summary": "Subscription cancelled",
"resource": {
"quantity": "1",
"subscriber": {
"email_address": "valid_adress#yahoo.fr",
"payer_id": "X3FWGFE2SAXUL",
"name": {
"given_name": "Anyname",
"surname": "Walker"
},
"shipping_address": {
"address": {
"address_line_1": "Great st 25",
"admin_area_2": "New York",
"admin_area_1": "NY",
"postal_code": "10002",
"country_code": "US"
}
}
},
"create_time": "2022-07-04T17:49:00Z",
"plan_overridden": false,
"shipping_amount": {
"currency_code": "USD",
"value": "0.0"
},
"start_time": "2022-07-04T17:46:51Z",
"update_time": "2022-07-04T17:51:25Z",
"billing_info": {
"outstanding_balance": {
"currency_code": "USD",
"value": "0.0"
},
"cycle_executions": [
{
"tenure_type": "REGULAR",
"sequence": 1,
"cycles_completed": 1,
"cycles_remaining": 0,
"current_pricing_scheme_version": 1,
"total_cycles": 0
}
],
"last_payment": {
"amount": {
"currency_code": "USD",
"value": "3.99"
},
"time": "2022-07-04T17:49:01Z"
},
"failed_payments_count": 0
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/billing/subscriptions/I-6BR7NSX98KLF",
"rel": "self",
"method": "GET",
"encType": "application/json"
}
],
"id": "I-6BR7NSX98KLF",
"plan_id": "P-5XR3459593FMK2CYGA",
"status": "CANCELLED",
"status_update_time": "2022-07-04T17:51:25Z"
},
"status": "PENDING",
"transmissions": [
{
"webhook_url": "https://www.myapp.com/webhook",
"http_status": 440,
"reason_phrase": "HTTP/1.1 200 Connection established",
"response_headers": {
"Server": "gunicorn",
"Connection": "keep-alive",
"Content-Length": "5",
"Date": "Mon, 04 Jul 2022 18:15:52 GMT",
"Content-Type": "text/html; charset=utf-8",
"Via": "1.1 google"
},
"transmission_id": "02cba350-fbc2-9abc-d537a3be4540",
"status": "PENDING",
"timestamp": "2022-07-04T17:52:03Z"
}
],
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3BV96304FY002321K-38Y64104YL460680C",
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-3BV96304FY002321K-38Y64104YL460680C/resend",
"rel": "resend",
"method": "POST",
"encType": "application/json"
}
],
"event_version": "1.0",
"resource_version": "2.0"
}
Pending means pending delivery to the subscribed webhook URL. The event ocurred, and delivery to the URL was attempted, but that URL did not respond with an HTTP 200 success message for the webhook to be marked as successfully delivered. In fact, according to the details logged in your question:
"webhook_url": "https://www.myapp.com/webhook",
"http_status": 440,
That URL instead responded with an HTTP 440 status
Assuming the URL is correct and that you changed it to "myapp" for this question, the issue is that you need to debug the endpoint/code at that URL so that it responds with a 200 success status when webhook deliveries are posted to it. Then their status will stop being Pending.

Time Series Insights not showing sub-object properties of a key/value pair

I have an application that is pushing data into IoT Hub which is being used as a data source for TSI. Below is an example message:
{
"EnqueuedTimeUtc": "2021-06-17T22:00:47.2170000Z",
"Properties": {},
"SystemProperties": {
"connectionDeviceId": "Device1",
"connectionAuthMethod": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
"connectionDeviceGenerationId": "637425408342887985",
"contentType": "application/json",
"contentEncoding": "utf-8",
"enqueuedTime": "2021-06-17T22:00:47.2170000Z"
},
"Body": {
"topic": {
"namespace": "spBv1.0",
"edgeNodeDescriptor": "Routed Group/E2",
"groupId": "Routed Group",
"edgeNodeId": "E2",
"deviceId": "D2",
"type": "DBIRTH"
},
"payload": {
"timestamp": "2021-06-17T22:00:47.082Z",
"metrics": [{
"name": "Ramp1",
"timestamp": "2021-06-17T22:00:47.082Z",
"dataType": "Int32",
"metaData": {},
"properties": {
"Quality": {
"type": "Int32",
"value": 192
},
"My Property": {
"type": "String",
"value": "{\"\":\"\"}"
}
},
"value": 77
}],
"seq": 1
}
}
}
I found documentation showing that my array of 'metrics' is supported as shown here:
https://learn.microsoft.com/en-us/azure/time-series-insights/concepts-json-flattening-escaping-rules
With this message, I can see 'Ramp1' show up in TSI with a value and timestamp as expected. However, the 'properties' under each metric do not show up. In this example that is 'Quality' and 'My Property'. Is there a way to get this data into TSI with an association to 'Ramp1'?

Pull Request Statuses - Added custom properties to a status aren't getting persisted by TFS

We are operating a TFS 2018 Update 2 in our enviroment.
We are sending the example json found here to our server and it is getting accepted successfully:
{
"properties": {
"sampleId": 7,
"customInfo": "Custom status information",
"startedDateTime": {
"$type": "System.DateTime",
"$value": "2017-09-19T14:50:26.7410146Z"
},
"weight": {
"$type": "System.Double",
"$value": 1.75
},
"bytes": {
"$type": "System.Byte[]",
"$value": "dGhpcyBpcyBzYW1wbGUgYmFzZTY0IGVuY29kZWQgc3RyaW5n"
},
"globalId": {
"$type": "System.Guid",
"$value": "1e788cb9-9d3d-4dc6-ac05-822092d17f90"
}
},
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1"
}
But the response doesn't look like in the documentation. Instead it looks like this:
{
"id": 6,
"state": "succeeded",
"description": "Sample status succeeded",
"context": {
"name": "sample-status-1",
"genre": "vsts-samples"
},
"creationDate": "2019-12-11T16:14:05.0574648Z",
"updatedDate": "2019-12-11T16:14:05.0574648Z",
"createdBy": {
"displayName": "...",
"url": "https://.../_apis/Identities/0b85e078-130d-4cb8-a450-17c5c7efccec",
"_links": {
"avatar": {
"href": "https://.../_api/_common/identityImage?id=0b85e078-130d-4cb8-a450-17c5c7efccec"
}
},
"id": "0b85e078-130d-4cb8-a450-17c5c7efccec",
"uniqueName": "...",
"imageUrl": "https://.../_api/_common/identityImage?id=0b85e078-130d-4cb8-a450-17c5c7efccec"
},
"targetUrl": "http://fabrikam-fiber-inc.com/CI/builds/1",
"_links": {
"self": {
"href": "https://.../_apis/git/repositories/35fe73eb-7af1-4bba-bf04-545611fcac1d/pullRequests/58/statuses/6"
},
"repository": {
"href": "https://.../_apis/git/repositories/35fe73eb-7af1-4bba-bf04-545611fcac1d"
}
}
}
The properties are gone. What could be wrong?
Could it be a somehow completely missleading documentation?
To troubleshoot your issue, please check the following items:
Check whether the Status updated on the pull request after running the POST request.
Press F12 in your browser, and send the POST request to check the statuses to see whether you can get properties in the response body.
Check your TFS edition by going to Administration Console -- Application Tier, or checking the About on the web portal. The issue can not be reproduced in TFS 2018.2 on our side.

How do I get browsermob-proxy to record ALL response bodies

I'm having trouble with browsermob-proxy and its har exporting feature. Some response bodies are not logged (the entire "text" field is missing)
My setup (using browsermob-proxy 2.1.4)
curl -X POST http://localhost:8080/proxy?port=9091
curl -X PUT "http://localhost:8080/proxy/9091/har?captureHeaders=true&captureCookies=true&captureContent=true"
Some responses are fine:
"response": {
"status": 201,
"statusText": "Created",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [{
"name": "Cache-Control",
"value": "max-age=0, no-cache, no-store"
}, {
"name": "Content-Type",
"value": "application/json"
}, {
"name": "Date",
"value": "Thu, 15 Feb 2018 13:07:39 GMT"
}, {
"name": "Location",
"value": ...
}, {
"name": "Pragma",
"value": "no-cache"
}, {
"name": "Render-Time",
"value": "8"
}, {
"name": "Server",
"value": "openresty"
}, {
"name": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains"
}, {
"name": "transfer-encoding",
"value": "chunked"
}, {
"name": "Connection",
"value": "keep-alive"
}],
"content": {
"size": 8607,
"mimeType": "application/json",
"text": "{ <actual json body> }",
"comment": ""
}, ...
But some are not (maybe it is the special content/mime type? or maybe it is the gzip content encoding?)
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"cookies": [],
"headers": [{
"name": "Cache-Control",
"value": "max-age=0, no-cache, no-store"
}, {
"name": "Content-Encoding",
"value": "gzip"
}, {
"name": "Content-Type",
"value": "application/some.custom.type-v1+json"
}, {
"name": "Date",
"value": "Thu, 15 Feb 2018 13:07:39 GMT"
}, {
"name": "Pragma",
"value": "no-cache"
}, {
"name": "Render-Time",
"value": "92"
}, {
"name": "Server",
"value": "openresty"
}, {
"name": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains"
}, {
"name": "Vary",
"value": "Accept-Encoding"
}, {
"name": "Content-Length",
"value": "1978"
}, {
"name": "Connection",
"value": "keep-alive"
}],
"content": {
"size": 7429,
"mimeType": "application/some.custom.type-v1+json",
"comment": ""
< there's nothing else here!! >
},
"redirectURL": "",
"headersSize": 444,
"bodySize": 1978,
"comment": ""
}, ...
Oh yea, both requests are over https, using MITM.
I think I found the answer to my own question
In BrowserMobHttpClient.java I found the following:
private boolean hasTextualContent(String contentType) {
return contentType != null && contentType.startsWith("text/") ||
contentType.startsWith("application/x-javascript") ||
contentType.startsWith("application/javascript") ||
contentType.startsWith("application/json") ||
contentType.startsWith("application/xml") ||
contentType.startsWith("application/xhtml+xml");
}
Looks like I'll have go make a custom build of browsermob-proxy to make it work.

Youtube API - limit without developer key

For a client of ours, we use the Youtube API v2 to fetch the newest video with a specific tag. We fetched the response of the URL without a developer key. Up until a few days ago, this worked perfectly. Suddenly, we got no results back. Instead of getting an error, we just got 0 results.
After a bit of puzzling, we found out that this is because we probably went over a limit of requests. This is a conclusion based on the fact that when we went to the same URL with a mobile device on 3G as a laptop connected with WiFi, we got results.
My question is this:
Is it possible to get an error in our request if we went over a limit?
What exactly is the limit when not using a developer key?
Is there a premium account available to fetch a much bigger amount of requests?
Thanks in advance!
[EDIT]
When we request the URL https://gdata.youtube.com/feeds/api/users/AEGON/uploads?category=2012Q4&alt=json, we get the following response in JSON:
(I removed some links because of reputation on Stack Overflow)
{
"version": "1.0",
"encoding": "UTF-8",
"feed": {
"xmlns": "",
"xmlns$openSearch": "",
"id": {
"$t": ""
},
"updated": {
"$t": "2013-03-12T08:35:47.226Z"
},
"category": [{
"scheme": "",
"term": ""
}],
"title": {
"$t": "Uploads by AEGON",
"type": "text"
},
"logo": {
"$t": ""
},
"link": [{
"rel": "related",
"type": "application/atom+xml",
"href": ""
},
{
"rel": "alternate",
"type": "text/html",
"href": ""
},
{
"rel": "",
"type": "application/atom+xml",
"href": ""
},
{
"rel": "",
"type": "application/atom+xml",
"href": ""
},
{
"rel": "self",
"type": "application/atom+xml",
"href": "https://gdata.youtube.com/feeds/api/users/AEGON /uploads?alt=json&start-index=1&max-results=25&category=%7Bhttp://gdata.youtube.com/schemas/2007/keywords.cat%7D2012Q4"
}],
"author": [{
"name": {
"$t": "AEGON"
},
"uri": {
"$t": ""
}
}],
"generator": {
"$t": "YouTube data API",
"version": "2.1",
"uri": ""
},
"openSearch$totalResults": {
"$t": 0
},
"openSearch$startIndex": {
"$t": 1
},
"openSearch$itemsPerPage": {
"$t": 25
}
}
}
Answer for your questions,
you'll receive an HTTP response with a code of 403 and a response
body that includes
[<errors><error><domain>yt:quota</domain><code>too_many_recent_calls</code></error></errors>]
for excessive request.
There is no such limit, you need to stop the request for 10 to 15 min. after receiving error.
No idea for this.
Reference: http://apiblog.youtube.com/2010/02/best-practices-for-avoiding-quota.html
According to youtube documentation, you will receive an error message letting you know that you exceeded the quota.
Check Operation limits

Resources