Wasted about 2 hours to derive the following working code/fix...
// Youtube NEW garbage handles to channel IDs
// https://stackoverflow.com/questions/75372496/how-can-i-get-youtube-channel-id-using-channel-name-url/75374713#75374713
// https://youtube.com/@AndreoBee
// https://stackoverflow.com/questions/74323173/how-to-map-youtube-handles-to-channel-ids
// One more time YouTube Data API v3 doesn't provide a basic feature.
// https://yt.lemnoslife.com/ Open Source YouTube API
/* sample JSON returned
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UC9rnrMdYzfqdjiuNXV7q8oQ"
}
]
}
*/
/// <summary>
/// Return Videos from ChannelId (derived from new Google garbage handle to channel)
/// 20230415
/// </summary>
/// <param name="UserName"></param>
/// <returns></returns>
public async Task<List<YouTubeInfo>> UserVideosViaNewHandleToChannelId(String UserName)
{
string URI = "https://yt.lemnoslife.com/channels?handle=" + UserName;
//
// https://swimburger.net/blog/dotnet/configure-servicepointmanager-securityprotocol-through-appsettings
// https://stackoverflow.com/questions/28286086/default-securityprotocol-in-net-4-5
// without the following Microsoft garbage now (httpClient.GetStringAsync(URI);) will crash.
System.Net.ServicePointManager.SecurityProtocol |=
SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//
// https://learn.microsoft.com/en-us/dotnet/csharp/tutorials/console-webapiclient
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json"));
httpClient.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter");
//
// "https://api.github.com/orgs/dotnet/repos"
var JSON_String = await httpClient.GetStringAsync(URI);
Console.Write(JSON_String);
// https://peterdaugaardrasmussen.com/2022/01/18/how-to-get-a-property-from-json-using-selecttoken/
var JSON_Object = JObject.Parse(JSON_String);
//
var ChannelId = JSON_Object["items"][0]["id"].ToString();
return await ChannelVideosInfo(ChannelId);
}