What kind of string does snippet.defaultLanguage take? - youtube

When I upload a video to my youtube channel, I'd like to be able to specify the defaultLanguage. However, the docs don't seem to be specify what kind of string I should put.
string This property is confidential to trusted testers.
The language of the text in the video resource's snippet.title and
snippet.description properties.
What kind of string does snippet.defaultLanguage take?
resource: {
snippet: {
defaultLanguage: "English" //<-- correct ?
}
}

"en" is the correct string to put to set the default language.

Related

How to get link to third party site in 'about channel' section via python

I want to display information about links in the YouTube profile in a text document, I tried to do it through the requests library, but Google gave links to privacy and security, I did not find information about this in the YouTube API documentation. Who knows, you can help with this
This isn't possible to get using the YouTube API, I actually found myself needing to do the same thing as yourself and was not able to because the YouTube API lacked the necessary functionality (Hopefully, It will be added soon!)
I see you mentioned Python, My only solution is in Node but I will do a large explanation and you can base your code off of it. In order to get the banner links without the YouTube API, we need to scrape the data, since YouTube uses client-side rendering we need to scrape the JSON configuration from the source.
There's a variable defined inside a script called ytInitialData which is a big JSON string with a massive amount of information about the channel, viewer, and YouTube configurations. We can find the banner links by parsing through this JSON link.
const request = require("request-promise").defaults({
simple: false,
resolveWithFullResponse: true
})
const getBannerLinks = async () => {
return request("https://www.youtube.com/user/pewdiepie").then(res => {
if (res.statusCode === 200) {
const parsed = res.body.split("var ytInitialData = ")[1].split(";</script>")[0]
const data = JSON.parse(parsed)
const links = data.header.c4TabbedHeaderRenderer.headerLinks.channelHeaderLinksRenderer
const allLinks = links.primaryLinks.concat(links.secondaryLinks || [])
const parsedLinks = allLinks.map(l => {
const url = new URLSearchParams(l.navigationEndpoint.commandMetadata.webCommandMetadata.url)
return {
link: url.get("q"),
name: l.title.simpleText,
icon: l.icon.thumbnails[0].url
}
})
return parsedLinks
} else {
// Error/ratelimit - Handle here
}
})
}
The way the links are scraped is as follows:
We make a HTTP request to the channel's URL
We parse the body to extract the JSON string that the banner links are inside using split
We parse the JSON string into a JSON object
We extract the links from their JSON section (It's a big JSON object data.header.c4TabbedHeaderRenderer.headerLinks.channelHeaderLinksRenderer
Because there are two types of links (Primary, the one that shows the text and secondary, links that don't show the text) we have to concatenate them together so we can map through them
We then map through the links and use URLSearchParams to extract the q query parameter since YouTube encrypts their outgoing links (Most likely for security reasons) and then extract the name and icon too using their appropriate objects.
This isn't a perfect solution, should YouTube update/change anything on their front end this could break your program easily. YouTube also has rate limits for their software if you're trying to mass scrape you'll run into 429/403 errors.

Double encoding of HTML with third party integration tool

We integrate a third-party app, using a javascript code that we need to send an email and name.
This email and name come from a previous step registration form.
Because we need to print on the page that email and name we encode it.
some.survey({
email: "test#test.pt",
name: "Mon & Sons",
properties: {"one":"123","two":"345"}
});
The issue is that the third party before printing is encoding again our string, showing in the browser like: "Mon & Sons".
Does anyone know how to get around this?
Here's a way (based on https://stackoverflow.com/a/784698):
function DecodeHTML(txt) {
var el = document.createElement("div");
el.innerHTML = txt;
return el.innerText;
};
DecodeHTML("Mon & Sons");
//"Mon & Sons"
Edit: watch out for XSS attacks, however. It is possible that the third-party app is doing this to escape any ' into &apos; and " into ", so you may want to build on the above idea to prevent this, depending on your needs. For example, if you're going to display this information on a HTML page, do so by only setting innerText of an element in that page, e.g. nameelement.innerText = nametext;
sbgib was almost right about how this would work. So, we now output the string as encoded, and decode it with Javascript, before sending it to the external service.
function DecodeHTML(txt) {
var el = document.createElement("div");
el.innerHTML = txt;
return el.innerText;
}
some.survey({
email: "test#test.pt",
name: DecodeHTML("Mon & Sons"),
properties: {"one":"123","two":"345"}
});

How to set %origin% in oauth2.json

In shindig, while configuring OAuth gadget details in OAuth2.json, we need to give %origin% and %context% as part of gadget url and redirect url.
Ex:
"%origin%%contextRoot%/gadgets/oauth2/oauth2_google_shared2.xml" : {
"googleAPI" : {
"clientName" : "googleApi_shared_client",
"allowModuleOverride" : "true"
}
},
"redirect_uri" : "%origin%%contextRoot%/gadgets/oauth2callback",
Can anybody help me is there any way to configure these values in SHINDIG so that these values will be applied for all the remaining entries in OAuth2.json file.
Those values are automatically replaced by the code in shindig. There is a filter in shindig which extracts the values from an incoming request and then uses them when needed.

How make WCF allow dots(.) in url?

I use WCF and have a method like this:
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "LoadProducts/{key}/{price}")]
XmlDocument LoadProducts(string key, string price= null);
price is string, inside LoadProducts I will try to parse it from string to double and do my other operations.
But in url, I can not get request any parameter for price like '24.25', '0.253' etc. It does not allow any value with dot.
localhost:13448/RestService.svc/LoadProducts/null/41.145
I get error "Please review the following URL and make sure that it is spelled correctly. "
How can I solve this?
Dots already have a meaning in a URL, they separate the target hostname, IP address or in the path they separate the resources from its extension. You will need to URL encode your request URL.
In .NET there is a method called UrlEncode to help you encode URLs. It is:
string url = "http://localhost/MyService/MyKey/24.25";
string encodedUrl = HttpUtility.UrlEncode(url);
Check out the MSN documentation for UrlEncode for more details.
I solved my issue. I switched server from Visual Studio Development Server to Local IIS Web Server, url took dot symbol inside parameter.

YouTube v3 API (.NET) - Get URI of newly posted video resource?

After scouring the v3 API documentation (and using the API explorer), I am not able to determine how to obtain the URI of a newly uploaded video resource (or any video resource).
I am aware that the video's ID is readily available and it is trivial to construct a URI from the ID. For example, I have this extension method:
public static Uri GetUri(this Video video)
{
var uriBuilder = new UriBuilder
{
Scheme = Uri.UriSchemeHttp,
Host = "youtu.be",
Path = video.Id,
};
return uriBuilder.Uri;
}
However, it seems strange that the video resource would not include a few different URLs (regular, shortened and embed-able come to mind).
I also recognize I am probably over thinking this because the only volatile part of the URL is the video ID. I guess I could always put the host name in a config file :)
Thoughts and comments are appreciated.
Regards,
You can get the video ID from the upload response once your request is executed.
YouTube API samples have a great upload example for this.
Once you have the video id, you can construct the full URL as
youtube.com/watch?v={video_id}
youtu.be/{video_id}

Resources