Spaces:
				
			
			
	
			
			
		Build error
		
	
	
	
			
			
	
	
	
	
		
		
		Build error
		
	| import gradio as gr | |
| import requests | |
| from requests_toolbelt import MultipartEncoder | |
| def put_video(video_url, page_id, access_token, description, title): | |
| video_file_name = title | |
| local_video_file = video_url | |
| path = f"{page_id}/videos" | |
| fb_url = f"https://graph-video.facebook.com/{path}?access_token={access_token}" | |
| print(fb_url) | |
| m = MultipartEncoder( | |
| fields={ | |
| "description": description, | |
| "title": title, | |
| "comment": "postvideo", | |
| "file_url": video_url, | |
| } | |
| ) | |
| r = requests.post( | |
| fb_url, headers={"Content-Type": m.content_type}, data=m | |
| ) | |
| if r.status_code == 200: | |
| j_res = r.json() | |
| facebook_video_id = j_res.get("id") | |
| print("facebook_video_id = {0}".format(facebook_video_id)) | |
| print("uploaddone, after 1,2 min will show ur profile") | |
| else: | |
| print("Facebook upload error: {0}".format(r.text)) | |
| print(video_url) | |
| def facebook_video_uploader(video_url, page_id, access_token, description, title): | |
| put_video(video_url, page_id, access_token, description, title) | |
| return "Video upload completed!" | |
| inputs = [ | |
| gr.inputs.Textbox("Video URL"), | |
| gr.inputs.Textbox("Page ID"), | |
| gr.inputs.Textbox("Access Token"), | |
| gr.inputs.Textbox("Description"), | |
| gr.inputs.Textbox("Title"), | |
| ] | |
| output = gr.outputs.Textbox() | |
| gr.Interface( | |
| fn=facebook_video_uploader, | |
| inputs=inputs, | |
| outputs=output, | |
| title="Facebook Video Uploader", | |
| description="Upload your videos to Facebook with this uploader.", | |
| theme="light", | |
| ).launch() | |