Youtube debug info field details - youtube

I am just doing a r&d on youtube video details. When we play a video in youtube and if we do right click, then we can see an option called copy debug info. If we copy that then there are lot of fields comes as below, I am just curious to know the details of these below fields.
{
"ns": "yt",
"el": "detailpage",
"cpn": "TA1LSqRVROm9Q2rb",
"docid": "tPDj7FhbUso",
"ver": 2,
"referrer": "https://www.youtube.com/feed/history",
"cmt": "208.944",
"ei": "Ups5X-iDO8ng4-EP7o6KwAg",
"fmt": "247",
"fs": "0",
"rt": "151.471",
"of": "yuFWq23SkzutVGx461bO4g",
"euri": "",
"lact": 7,
"cl": "326301777",
"mos": 0,
"state": "4",
"vm": "CAEQARgEKiBsUmpoTXRxc1czUTVHZ2RJbmktOXBNdnY3X3JnV3ItNjoyQUdiNlo4T3BuV0tmTXhwbW5wWDZjUDA3X3JPYU5PXzVSd1Bha2szZE9jNEhCY0ZQTkE",
"volume": 100,
"subscribed": "1",
"cbr": "Chrome",
"cbrver": "84.0.4147.125",
"c": "WEB",
"cver": "2.20200814.00.00",
"cplayer": "UNIPLAYER",
"cos": "Macintosh",
"cosver": "10_15_6",
"hl": "en_US",
"cr": "IN",
"len": "268.121",
"fexp": "23744176,23804281,23839597,23856950,23857950,23858057,23859802,23862346,23868323,23880389,23882502,23883098,23884386,23890960,23895671,23900945,23907595,23911055,23915993,23916148,23918272,23918598,23927906,23928508,23930220,23931938,23934047,23934090,23934970,23936412,24631210,3300107,3300133,3300161,3313321,3316358,3316377,3317374,3317643,3318816,3318887,3318889,3319024,9405957,9449243",
"afmt": "251",
"inview": "NaN",
"vct": "208.944",
"vd": "268.121",
"vpl": "207.000-208.944",
"vbu": "204.000-268.121",
"vpa": "1",
"vsk": "0",
"ven": "0",
"vpr": "1",
"vrs": "4",
"vns": "2",
"vec": "null",
"vemsg": "",
"vvol": "1",
"vdom": "1",
"vsrc": "1",
"vw": 1159,
"vh": 652,
"creationTime": 158827.80500000808,
"totalVideoFrames": 128,
"droppedVideoFrames": 0,
"corruptedVideoFrames": 0,
"lct": "208.944",
"lsk": false,
"lmf": false,
"lbw": "993748.652",
"lhd": "0.057",
"lst": "0.000",
"laa": "itag=251,type=3,seg=26,range=3299085-3408885,time=260.0-268.1,off=0,len=109801,end=1,eos=1",
"lva": "itag=247,type=3,seg=53,range=17411843-17472031,time=264.0-268.1,off=0,len=60189,end=1,eos=1",
"lar": "itag=251,type=3,seg=26,range=3299085-3408885,time=260.0-268.1,off=0,len=109801,end=1,eos=1",
"lvr": "itag=247,type=3,seg=53,range=17411843-17472031,time=264.0-268.1,off=0,len=60189,end=1,eos=1",
"lab": "200.001-268.121",
"lvb": "204.000-268.080",
"ismb": 3000000,
"relative_loudness": "-5.140",
"optimal_format": "720p",
"user_qual": "auto",
"debug_videoId": "tPDj7FhbUso",
"0sz": false,
"op": "",
"yof": false,
"dis": "",
"gpu": "Intel(R)_UHD_Graphics_630",
"cgr": true,
"debug_playbackQuality": "hd720",
"debug_date": "Mon Aug 17 2020 02:19:46 GMT+0530 (India Standard Time)"
}
For an example - docid filed is known for the video Id of youtube. Like that I wanna know other field details. If anyone can help me with, that would be great..

I doubt there is a easy way to do this - (AFAIK, no YouTube Data API exposes such values), but, if you really want to check, you can enter to view-source:https://www.youtube.com/watch?v=<VIDEO_ID> - where <VIDEO_ID> is the id of the YouTube video.
There are some values obtained from the copy debug info - but not all of them, I'm affraid.

Related

Using data from the first response in the body of the second

I'm trying to combine requests from two services in one endpoint.
The first returns the list of users, like this:
{
"data": [
{ "id": 1, "name": "first", "photo": "employee_photos/key1.png" },
{ "id": 2, "name": "second", "photo": null },
{ "id": 3, "name": "third", "photo": "employee_photos/key3.png" }
]
}
The second is supposed to receive the POST request with the JSON listing photo keys to get the required version URLs.
Request:
{
"keys": [ "employee_photos/key1.png", "employee_photos/key3.png" ],
"versions": [ "small", "large" ]
}
I created a small Lua script to process the response of the first request and collect the list of keys. It looks like this:
function post_employees(request, employeesResponse)
local resp = employeesResponse.load()
local data = resp:data():get("data")
local photo_keys = {}
for i = 0, data:len() - 1, 1 do
local rec = data:get(i)
local id = rec:get("id")
local photo = rec:get("photo")
if photo then
table.insert(photo_keys, photo)
end
end
resp:data():set("photos", table.concat(photo_keys, ","))
end
But then... I can't find a way to use this list of keys in the second request. Is it even possible?

How to properly query Postgresql JSONB array of hashes on Ruby on Rails 6?

This is my column:
[
{ id: 1, value: 1, complete: true },
{ id: 2, value: 1, complete: false },
{ id: 3, value: 1, complete: true }
]
First, is there a "correct" way to work with a jsonb scheme? should I redesign to work with a single json instead of the array of hashes?
I have about 200 entries on the database, the column status has 200 of those itens.
How would I perform a query to get the count of true/false?
How can I query for ALL complete itens? I can query for the database rows in which the json has an item complete, but I can't query for all the itens, in all rows of the database that are complete.
Appreciate the help, thank you
Aha! I found it here:
https://levelup.gitconnected.com/how-to-query-a-json-array-of-objects-as-a-recordset-in-postgresql-a81acec9fbc5
Say your dataset is like this:
[{
"productid": "3",
"name": "Virtual Keyboard",
"price": "150.00"
}, {
"productid": "1",
"name": "Dell 123 Laptop Computer",
"price": "1300.00"
},
{
"productid": "8",
"name": "LG Ultrawide Monitor",
"price": "190.00"
}]
The proper way to count it, is like this:
select items.name, count(*) as num from
purchases,jsonb_to_recordset(purchases.items_purchased) as items(name text)
group by items.name
order by num Desc
Works like a charm and is extremely fast.
To do it in Rails, you need to use Model.find_by_sql(....) and indicate your select therem. I'm sure there are probably better ways to do it.

LUA: add values in nested table

I have a performance issue in my application. I would like to gather some ideas on what I can do to improve it. The application is very easy: I need to add values inside a nested table to get the total an user wants to pay out of all the pending payments. The user chooses a number of payments and I calculate how much it is they will pay.
This is what I have:
jsonstr = "{ "name": "John",
"surname": "Doe",
"pending_payments": [
{
"month": "january",
"amount": 50,
},
{
"month": "february",
"amount": 40,
},
{
"month": "march",
"amount": 45,
},
]
}"
local lunajson = require 'lunajson'
local t = lunajson.decode(jsonstr)
local limit -- I get this from the user
local total = 0;
for i=1, limit, 1 do
total = total + t.pending_payments[i].amount;
end;
It works. At the end I get what I need. However, I notice that it takes ages to do the calculation. Each JSON has only twelve pending payments (one per month). It is taking between two to three seconds to come up with a result!. I tried in different machines and LUA 5.1, 5.2., 5.3. and the result is the same.
Can anyone please suggest how I can implement this better?
Thank you!
For this simple string, try the test code below, which extracts the amounts directly from the string, without a json parser:
jsonstr = [[{ "name": "John",
"surname": "Doe",
"pending_payments": [
{
"month": "january",
"amount": 50,
},
{
"month": "february",
"amount": 40,
},
{
"month": "march",
"amount": 45,
},
]
}]]
for limit=0,4 do
local total=0
local n=0
for a in jsonstr:gmatch('"amount":%s*(%d+),') do
n=n+1
if n>limit then break end
total=total+tonumber(a)
end
print(limit,total)
end
I found the delay had nothing to do with the calculation in LUA. It was related with a configurable delay in the retrieval of the limit variable.
I have nothing to share here related to the question asked since the problem was actually in an external element.
Thank #lfh for your replies.

Create Nested Build for object rails

My JSON API is like below,
{ "schedule_id": "1",
"latitude" : 17.4327,
"longitude" : 78.4302,
"device_id": "123test",
"audit_compliances":[
{
"value": "Yes",
"score": 10,
"remarks": "some remarks",
"private_remarks": "some remarks",
"check_point_id": 1,
"audit_compliance_documents":[{
"score": 10,
"remarks": "some remarks",
}]
}]
i have a relations for that DB i want to save all this records at once so i want to initialize the object with details and build inner objects along with that. Started building like this but how can i build inner build for documents.
submission = Submission.new(audit_schedule_id: params[:schedule_id],
latitude: params[:latitude], longitude: params[:longitude],
device_id: params[:device_id])
params[:audit_compliances].each do |audit_compliance|
submission.audit_compliances.build(
value: audit_compliance[:value],
score: audit_compliance[:score],
remarks: audit_compliance[:remarks],
private_remarks: audit_compliance[:private_remarks],
check_point_id: audit_compliance[:check_point_id])
end
pass your json param in submission params directly
like this
params[:submission] = json_params;
Submission.create(params[:submission]);
It will create both if your mapping is correct........

custom_variables value not in quotes

I have just downloaded a get_survey_details.json and note that the question_id value is not quoted. I would have expected "623478675" Is this a change?
{"status": 0, "data": {"custom_variables": [{"variable_label": "User Agent", "question_id": 623478675}

Resources