Advertisement
Learning000001

Untitled

May 28th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. alreadyGotUrls = false;
  2. CheckVideoUrlAndExtractThevideoId(youtubeUrl);
  3. WWWForm form = new WWWForm();
  4. //string ag = "";
  5. string f = "{\"context\": {\"client\": {\"clientName\": \"ANDROID\",\"clientVersion\": \"17.31.35\",\"androidSdkVersion\": \"30\",\"hl\": \"en\"}},\"videoId\": \"" + youtubeVideoID + "\",}";
  6. string fweb = "{\"context\": {\"client\": {\"clientName\": \"WEB\",\"clientVersion\": \"2.20220801.00.00\"}},\"videoId\": \"" + youtubeVideoID + "\",}";
  7. byte[] bodyRaw = Encoding.UTF8.GetBytes(f);
  8. //UnityWebRequest request = UnityWebRequest.Post("https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8", form);
  9. UnityWebRequest request = UnityWebRequest.Post("https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w", form);
  10. request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
  11. request.SetRequestHeader("Content-Type", "application/json");
  12. //request.SetRequestHeader("Origin","https://www.youtube.com");
  13. //request.SetRequestHeader("X-YouTube-Client-Name", "ANDROID");
  14. //request.SetRequestHeader("X-YouTube-Client-Version", "17.31.35");
  15. string userAgentTemporary = "com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip";
  16. //request.SetRequestHeader("Accept", "*/*");
  17. //request.SetRequestHeader("Accept-Encoding", "gzip, deflate");
  18. request.SetRequestHeader("User-Agent", userAgentTemporary);
  19. yield return request.SendWebRequest();
  20. request.uploadHandler.Dispose();
  21.  
  22. if (request.error != null)
  23. {
  24. Debug.Log("Error: " + request.error);
  25. }
  26. else
  27. {
  28. if (decryptionNeeded)
  29. {
  30. requestResult = JObject.Parse(request.downloadHandler.text);
  31.  
  32.  
  33. if (debug) Debug.Log("want to write log?");
  34. //WriteLog("kelvinsxx", request.downloadHandler.text);
  35. IEnumerable<ExtractionInfo> downloadUrls = ExtractDownloadUrls(requestResult);
  36. youtubeVideoInfos = GetVideoInfos(downloadUrls, videoTitle).ToList();
  37. videoTitle = GetVideoTitle(requestResult);
  38. is360 = false;
  39. alreadyGotUrls = true;
  40. UrlsLoaded();
  41. }
  42.  
  43.  
  44. //WriteLog("v", request.downloadHandler.text);
  45.  
  46. if ((request.downloadHandler.text.Contains("EQUIRECTANGULAR") || request.downloadHandler.text.Contains("MESH")))
  47. {
  48. is360 = true;
  49. if (debug)
  50. Debug.Log("Possible 360 video");
  51. //videoPlayer.renderMode = VideoRenderMode.RenderTexture;
  52. //videoPlayer.aspectRatio = VideoAspectRatio.NoScaling;
  53. }
  54. else
  55. {
  56. is360 = false;
  57. RenderSettings.skybox = skyboxMaterialNormal;
  58. if (!dontForceFullscreen && videoPlayer != null)
  59. {
  60. videoPlayer.renderMode = VideoRenderMode.CameraFarPlane;
  61. videoPlayer.aspectRatio = VideoAspectRatio.FitInside;
  62. videoPlayer.targetCamera = mainCamera;
  63. }
  64. if (debug)
  65. Debug.Log("No 360 video!");
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement