MiserableLife Posted April 4, 2010 Share Posted April 4, 2010 (edited) Hello everyone...I've been writing code to upload my videos to YouTube automatically butI don't understand what some of the header means...Content-Length: <content_length> [solved]Which part of the POST should I start counting?The size that puts into $obj.Send()WWW.W3.ORG<Binary File Data>What happens if I want to send the data separately? How do I do that?From Google Code :POST /feeds/api/users/default/uploads HTTP/1.1 Host: uploads.gdata.youtube.com Authorization: AuthSub token="<authentication_token>" GData-Version: 2 X-GData-Key: key=<developer_key> Slug: <video_filename> Content-Type: multipart/related; boundary="<boundary_string>" Content-Length: <content_length> Connection: close --<boundary_string> Content-Type: application/atom+xml; charset=UTF-8 API_XML_request --<boundary_string> Content-Type: <video_content_type> Content-Transfer-Encoding: binary <Binary File Data> --<boundary_string>--Here's my half-finished functionFunc UploadVid($username, $token, $title, $des, $keywd, $filepath) $url = "http://uploads.gdata.youtube.com/feeds/api/users/"& $username &"/uploads" $filename = StringSplit($filepath,'\') $filename = $filename[$filename[0]] $boundaryStr = '91C1C186' $data = "--"& $boundaryStr & @LF $data &="Content-Type: application/atom+xml; charset=UTF-8"& @LF $tmp_f = FileRead(@ScriptDir & '\upload.xml') $tmp_f = StringReplace($tmp_f, '---Title---',$title) $tmp_f = StringReplace($tmp_f, '---description---',$des) $tmp_f = StringReplace($tmp_f, '---KEYWORD---',$keywd) $data &= $tmp_f & @LF $data &= "--"& $boundaryStr & @LF $data &= "Content-Type: video/mpeg"& @LF $data &= "Content-Transfer-Encoding: binary"& @LF $hFile = FileOpen($filepath, 16) $data &= FileRead($hFile) FileClose($hFile) $data &= "--"& $boundaryStr &"--" $obj = ObjCreate ("WinHttp.WinHttpRequest.5.1") $obj.Open("POST", $URL, false) $obj.SetRequestHeader("Authorization","GoogleLogin "& $token) $obj.SetRequestHeader("GData-Version","2") $obj.SetRequestHeader("X-GData-Key","key=" & $dev_key) $obj.SetRequestHeader("Slug","application/x-www-form-urlencoded") $obj.SetRequestHeader("Content-Type","multipart/related; boundary=" & $boundaryStr) $obj.SetRequestHeader("Content-Length","") $obj.SetRequestHeader("Connection","close") $obj.Send($data) EndFunc Edited April 5, 2010 by MiserableLife Link to comment Share on other sites More sharing options...
BrettF Posted April 4, 2010 Share Posted April 4, 2010 Hahaha. I tried this a while back, uploading never worked however. Try searching for what I managed to create. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
MiserableLife Posted April 4, 2010 Author Share Posted April 4, 2010 I'm going through http://www.w3.org/ for details Link to comment Share on other sites More sharing options...
MiserableLife Posted April 4, 2010 Author Share Posted April 4, 2010 (edited) Can someone give me an example on DllCall() with this WinAPI function,please?WinHttpOpen FunctionEdit:Besides the return type, am I doing this right?Should I put HANDLE in HINTERNET?MSDN - HINTERNETDllCall("Winhttp.dll","HINTERNET","WinHttpOpen", _ "wstr", $userAgent, "DWORD", $AccessType, _ "wstr", $ProxyName, "wstr", $ProxyBypass, "DWORD", $Flags) Edited April 4, 2010 by MiserableLife Link to comment Share on other sites More sharing options...
MiserableLife Posted April 5, 2010 Author Share Posted April 5, 2010 (edited) Could some body please help me here? I've made the code to upload the file but the server gives me "406 Not Acceptable", what to do? I already made sure that my headers and my bodies are correct(including new lines). Now I'm just not sure if my parameters are correct in the functions. Please do help me, I just need this one more step to complete. :) Edit: attachment remove (I'll open a new post about this Youtube Uploader when I'm finnish) Edited April 6, 2010 by MiserableLife Link to comment Share on other sites More sharing options...
MiserableLife Posted April 5, 2010 Author Share Posted April 5, 2010 Problem found!!!After doing some more search on Google... I managed to capture my package..when I first saw my package,I was thinking....why "Accept:" is in my header. I haven't insert that into my script.and now, I am sure it has something to do with my "406 - Not Acceptable" error! :) why is this happening :) POST /feeds/api/users/default/uploads HTTP/1.1 Accept: Authorization: GoogleLogin Auth=DQAAAJsAAACXPl3r8sHrxJqmoygNIuzcVRiSl7QyfAIt7n9caAxi5mPgMbpMo3fZLWaWxVxwZkaFCD4WKTAbRt106_XMu-xIFm1xooNRjeoaoI94bJQpFbDYtbwg2FbZMrl32d3zgA2LNtxNQnT-f9i6FSQkqkaIL6D2dncoW0X-gukY7rpPFG0COSO063GlxyNqSZBYfOoY5nOcQIOHM7m3mXyvJPDe GData-Version: 2 X-GData-Key: key=AI39si5XOGX3DxWiELQJf_-36sJB4MEWPcF4LjtUSh711r541DfHMNr771t4Q8eIiOv_ePhEGkbAc0hTEJzHF7O6OBUX-I8Y1Q Slug: MassEffect2.mp4 Content-Type: multipart/related; boundary="boundary" Content-Length: 10550 Connection: close User-Agent: Test Host: uploads.gdata.youtube.com --boundary Content-Type: application/atom+xml; charset=UTF-8 <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><media:group><media:title type="plain">Test upload</media:title><media:description type="plain">Just a upload test. Nothing to watch.</media:description><media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category><media:keywords>Upload</media:keywords></media:group></entry> --boundary Content-Type: video/mp4 Content-Transfer-Encoding: binary masseffect2.mp4_in_binary --boundary-- Link to comment Share on other sites More sharing options...
MiserableLife Posted April 5, 2010 Author Share Posted April 5, 2010 (edited) Problem Solved. Just add "Accept: text/*" to the header. :) what a stupid thing to do Edited April 5, 2010 by MiserableLife Link to comment Share on other sites More sharing options...
trancexx Posted April 5, 2010 Share Posted April 5, 2010 That shouldn't be the only problem with your script. All works with only that change? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
MiserableLife Posted April 5, 2010 Author Share Posted April 5, 2010 (edited) YES !!!!! I see my new video uploaded in youtube.com. replace line 42 with $Main_header = 'Accept: text/*' & @CRLF & _ Edit: = =" I for got to say.I added $WINHTTP_ADDREQ_FLAG_ADD to _WinHttpAddRequestHeaders().Sorry~ Edited April 5, 2010 by MiserableLife Link to comment Share on other sites More sharing options...
BrettF Posted April 5, 2010 Share Posted April 5, 2010 Nice one Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
trancexx Posted April 5, 2010 Share Posted April 5, 2010 YES !!!!! I see my new video uploaded in youtube.com. replace line 42 with $Main_header = 'Accept: text/*' & @CRLF & _ Edit: = =" I for got to say.I added $WINHTTP_ADDREQ_FLAG_ADD to _WinHttpAddRequestHeaders().Sorry~ You should post in examples. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Tin2tin Posted July 28, 2010 Share Posted July 28, 2010 Is there a working script on how you did this somewhere? DVD slideshow GUI Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now