Untitled

 avatar
unknown
plain_text
2 years ago
7.0 kB
11
Indexable
 public string UploadVideoPage(string PageID, string video, string waterfall_id, string entry = "reel_composer_default_sfv_banner")
        {
            try
            {
                if (string.IsNullOrEmpty(Fb_dtsg))
                {
                    Get("https://www.facebook.com").Wait();
                }
                #region Load 1
                RestRequest request = new RestRequest($"https://business.facebook.com/ajax/video/upload/requests/start/?av={PageID}&__a=1");
                //request.Timeout = -1;
                request.AddHeader("sec-fetch-site", "same-origin");
                request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                request.AddHeader("x-fb-lsd", LSD);
                request.AddHeader("x_fb_video_waterfall_id", waterfall_id);
                request.AddHeader("User-Agent", UA);
                request.AddParameter("fb_dtsg", Fb_dtsg);
                request.AddParameter("LSD", LSD);
                request.AddParameter("file_size", new FileInfo(video).Length);
                request.AddParameter("file_extension", "mp4");
                request.AddParameter("target_id", PageID);
                request.AddParameter("__user", UID);
                request.AddParameter("__a", "1");
                request.AddParameter("waterfall_id", waterfall_id);
                request.AddParameter("source", "composer");
                request.AddParameter("composer_entry_point_ref", entry);
                request.AddParameter("supports_chunking", "true");
                request.AddParameter("supports_file_api", "true");
                request.AddParameter("partition_start_offset", "0");
                request.AddParameter("partition_end_offset", new FileInfo(video).Length);
                request.AddParameter("has_file_been_replaced", "false");
                request.AddParameter("composer_dialog_version", "V2");
                request.AddParameter("video_publisher_action_source[product]", "creator_studio");
                request.AddParameter("video_publisher_action_source[feature]", "page_video_composer");
                request.AddParameter("video_publisher_action_source[entry_point]", entry);
                request.Method = Method.Post;
                var response = Client.ExecuteAsync(request).Result;
                var result = response.Content;
                string video_id = RegexMatch(result, "\"video_id\":\"(\\d+)").Groups[1].Value;
                #endregion

                if (string.IsNullOrEmpty(video_id)) return "";
                request = new RestRequest($"https://business.facebook.com/api/graphql/");
                //request.Timeout = -1;
                request.AddHeader("sec-fetch-site", "same-origin");
                request.AddHeader("User-Agent", UA);
                request.AddParameter("fb_dtsg", Fb_dtsg);
                request.AddParameter("LSD", LSD);
                request.AddParameter("variables", "{\"source_type\":\"composer\"}");
                request.AddParameter("doc_id", "5166149316783263");
                request.Method = Method.Post;
                response = Client.ExecuteAsync(request).Result;
                result = response.Content;
                string link = RegexMatch(result, "\"targeted\":{\"service_name\":\"(.*?)\"").Groups[1].Value;
                if (string.IsNullOrEmpty(link)) link = "rupload-lax3-2.up";
                #region Load 2
                request = new RestRequest($"https://{link}.facebook.com/fb_video/{RandomString(32)}??__user={UID}&__a=1&fb_dtsg={Fb_dtsg}");
                //request.Timeout = -1;
                request.AddHeader("sec-fetch-site", "same-origin");
                request.AddHeader("offset", "0");
                request.AddHeader("product_media_id", video_id);
                request.AddHeader("x-entity-length", new FileInfo(video).Length.ToString());
                request.AddHeader("x-entity-name", HttpUtility.UrlEncode(RegexEscape(new FileInfo(video).Name)));
                request.AddHeader("x-entity-type", "video/mp4");
                request.AddHeader("composer_session_id", waterfall_id);
                request.AddHeader("x-total-asset-size", new FileInfo(video).Length.ToString());
                request.AddHeader("Content-Type", "video/mp4");
                request.AddHeader("User-Agent", UA);
                request.AddParameter("video/mp4", File.ReadAllBytes(video), ParameterType.RequestBody);
                request.Method = Method.Post;
                response = Client.ExecuteAsync(request).Result;
                result = response.Content;
                string h = RegexMatch(result, "\"h\":\"(.*?)\"").Groups[1].Value;
                string[] list = h.Split(new[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
                #endregion
                request = new RestRequest($"https://business.facebook.com/ajax/video/upload/requests/receive/?av={PageID}&__a=1");
                //request.Timeout = -1;
                request.AddHeader("sec-fetch-site", "same-origin");
                request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                request.AddHeader("x_fb_video_waterfall_id", waterfall_id);
                request.AddHeader("x-fb-lsd", LSD);
                request.AddHeader("User-Agent", UA);
                request.AddParameter("fb_dtsg", Fb_dtsg);
                request.AddParameter("__a", "1");
                request.AddParameter("waterfall_id", waterfall_id);
                request.AddParameter("source", "composer");
                request.AddParameter("composer_entry_point_ref", entry);
                request.AddParameter("supports_chunking", "true");
                request.AddParameter("supports_file_api", "true");
                request.AddParameter("partition_start_offset", "0");
                request.AddParameter("partition_end_offset", new FileInfo(video).Length.ToString());
                request.AddParameter("start_offset", "0");
                request.AddParameter("end_offset", new FileInfo(video).Length.ToString());
                request.AddParameter("has_file_been_replaced", "false");
                request.AddParameter("upload_speed", "0");
                request.AddParameter("fbuploader_video_file_chunk", string.Join("\n", list));
                request.AddParameter("target_id", PageID);
                request.AddParameter("__user", UID);
                request.AddParameter("video_id", video_id);
                request.Method = Method.Post;
                response = Client.ExecuteAsync(request).Result;
                result = response.Content;
                if (Regex.IsMatch(result, "\"start_offset\":(\\d+),\"end_offset\":(\\d+)"))
                    return video_id;
                else return "";
            }
            catch { return ""; }

        }
       
Editor is loading...