BrettF Posted August 11, 2009 Share Posted August 11, 2009 (edited) I've been working on getting the Youtube API into Autoit specifically to make an uploader. I'm having trouble with this part- uploading the actual video file.Link to the API:http://code.google.com/apis/youtube/2.0/...l_direct_uploading.html#Direct_uploadingCode I'm trying:youtube_test.au3You'll need to change this line:$auth_token = _YouTube_Login("", "", $Descriptor)to have a correct username and password in the form of:$auth_token = _YouTube_Login("Username", "Password", $Descriptor).Also the developerkey is my personal one, so if you plan on using this code for you own project, get your own.Sorry if its massively long and makes no sense... >_<Ideas?Cheers,Brett Edited August 12, 2009 by BrettF 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...
monoceres Posted August 12, 2009 Share Posted August 12, 2009 (edited) I don't have time to take a close look, but here's a possible error: When you're including the binary into the request you're just conjugating it with the '&' operator, this will the binary look like this: "0xDEADBEEF" while I guess youtube wants it like this: "DEADBEEF". Just a guess. Edit: Btw, your avatar aint working. Edited August 12, 2009 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
BrettF Posted August 12, 2009 Author Share Posted August 12, 2009 (edited) Tried that and nothing... >_< New function is: expandcollapse popupFunc _YouTube_Upload($auth_token, $developer_key, $szPath, $sXML) If $internet == 0 Then MsgBox(0, "Error", "Setup Error") EndIf $boundary_string = _RandString(8) $file_name = StringRight($szPath, StringLen($szPath) - StringInStr($szPath, "\", 0, -1)) $ext = StringRight ($file_name, StringLen ($file_name) - StringInStr ($file_name, ".", 1, -1)) MsgBox (0, "", $ext) $file_mime = _FIleGetMimeType($ext) If $file_mime = -1 Then $file_mime = "application/octet-stream" $fHandle = FileOpen($szPath, 16) $file_binary = FileRead($fHandle) FileClose($fHandle) $content = "--" & $boundary_string & @CRLF $content &= "Content-Type: application/atom+xml; charset=UTF-8" & @CRLF $content &= @CRLF $content &= $sXML & @CRLF $content &= "--" & $boundary_string & @CRLF $content &= "Content-Type: " & $file_mime & @CRLF $content &= "Content-Transfer-Encoding: binary" & @CRLF $content &= @CRLF $content &= StringTrimLeft ($file_binary, 2) & @CRLF $content &= "--" & $boundary_string & "--" & @CRLF $content &= @CRLF $length = StringLen($content) $header = "Authorization: AuthSub token=""" & $auth_token & """" & @CRLF $header &= "GData-Version: 2" & @CRLF $header &= "X-GData-Key: key=" & $developer_key & @CRLF $header &= "Slug: " & $file_name & @CRLF $header &= "Content-Type: multipart/related; boundary=""" & $boundary_string & """" & @CRLF $header &= "Content-Length: " & $length & @CRLF $header &= "Connection: close" & @CRLF & @CRLF $host = "uploads.gdata.youtube.com" $internetconnect = _WinINet_InternetConnect($internet, $INTERNET_SERVICE_HTTP, $host, 443) If @error Then MsgBox(0, "Error", "Error 2") $httprequest = _WinINet_HttpOpenRequest($internetconnect, "POST", "/feeds/api/users/default/uploads", $INTERNET_FLAG_SECURE) $addheader = _WinINet_HttpAddRequestHeaders($httprequest, $header, $HTTP_ADDREQ_FLAG_ADD) $sendrequest = _WinINet_HttpSendRequest($httprequest, Default, StringToBinary ($content)) Local $readfile = Binary("") Do $readfile &= _WinINet_InternetReadFile($httprequest, 5000) Until @error <> 0 Or Not @extended $ret = BinaryToString($readfile) _WinINet_InternetCloseHandle($internetconnect) Return $ret EndFunc ;==>_YouTube_Upload It seems that the _WinINet_HttpSendRequest line is failing. _WinAPI_GetLastError() is returning 0- I'm not sure what that means... EDIT: OH THANKS! I decided to add a redirect from http://signa5.com to http://www.signa5.com... seemed to have missed that CHEERS! Edited August 12, 2009 by BrettF 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...
BrettF Posted August 13, 2009 Author Share Posted August 13, 2009 Bump for ideas... >_ 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...
BrettF Posted August 15, 2009 Author Share Posted August 15, 2009 Bump for ideas... >_ 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...
Carlo84 Posted August 17, 2009 Share Posted August 17, 2009 (edited) Im working on the same thing, figured id first check forum to see if theres something about it yet, but its all downloaders nothing about this. I only just finnished the login bit >_< $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "https://www.google.com/youtube/accounts/ClientLogin" , False) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send("Email=USERNAME=PASSWORD&service=youtube&source=Upload") $oReceived = $oHTTP.ResponseText ;checking if its working MsgBox(0, 0, $oReceived) Anyways, will post here also if find a working solution or notice why yours isnt working. =] oh and BUMP Edited August 17, 2009 by Hellstrong _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
BrettF Posted December 3, 2009 Author Share Posted December 3, 2009 Oh and bump. Anyone got ideas? I've still got nothing... Code is virtually the same too. 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...
BrettF Posted December 4, 2009 Author Share Posted December 4, 2009 Hey I forgot... Bump! 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...
BrettF Posted December 10, 2009 Author Share Posted December 10, 2009 Gah bump. Really don't get why this doesn't work! 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...
stereospeaker Posted August 6, 2012 Share Posted August 6, 2012 (edited) Hope you don´t mind that I revive this topic. But I also don´t get my Youtube Uploader to work and I guess it´s for the same reason BrettF failed. (At first, because he managed to get it running, see )I have 2 problems at the moment and I guess both have the same source: The ANSII - UTF-8 encoding.I tried several versions of the YouTube API in hope that one would work flawless. But sofaso farave 2 Versions of my uploader. One uses Browser based Upload (https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading) the other Resumable Upload (https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads)Both programs LogIn via oAuth.Problems with the Browser based UploadThis program works fine, till it has to renew its accesstoken via the refreshtoken. The Post response from youtube is: error : invalid_grantI did some research and it seems that the problem is relayed to the mentioned encoding.See some references:http://stackoverflow.com/questions/8433990/when-authenticating-with-oauth-and-youtube-always-get-error-invalid-grant-onhttps://groups.google.com/forum/#!searchin/oauth2-dev/invalid_grant/oauth2-dev/eaOa6THER0k/z4eO-taUFxgJIt seems like the Data i´m Iassing to Youtube must be URLEncoded. So my question is: How do i doIthat with AutoIt?Problems with Resumable UploadThis Program works so far, that a File is Uploaded to youtube (Source File is an .Avi). Youtube recireceives XML which define things like the Name and DiscDescription properly assiassignt to the Uploaded file. Unfortunately, youtube dispdisplays "Upload abgebrochen" (Upload CancCanceledwhen i´m Iogged in my Youtube account to check my recently Uploaded videos.I guess the Problem again, is wrong encoding. Youtube expects a file in Binary-Utf8 and I feed it....well I´m not perfectly sure.I open the File as Binary:$Dateihwnd = FileOpen("Movie.avi",16)$binaryRead = FileRead($Dateihwnd)and tried hundhundredferent combinations including binary(), stringtobinary, binarytostring and so on. All with the same result->Upload Canceled.Since this is my first Post, i apIlogize if i caIe in confconflicth the autoscript terms of proper behabehaviorso I´m very (very very) sorry for my grammar. I´m german but(!) I used online spellcheck...I really hope you guys (BrettF and MiserableLife) can help me by sharing your solution. That problem consumed till now way too much of my free time and gave me headaches... Edited August 6, 2012 by stereospeaker Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 6, 2012 Moderators Share Posted August 6, 2012 stereospeaker,Welcome to the AutoIt forum. Could I just point out that BrettF has not been online for nearly a year so I would not expect an answer any time soon! In general we frown on posting in threads as old as this one - mainly because the language has changed a lot over the years and as a result the code may no longer be correct, or even needed. So please do not make a habit of it in future. i apIlogize if i caIe in confconflicth the autoscript terms of proper behabehaviorNo need to apologise - but for future reference the Forum Rules are here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
stereospeaker Posted August 6, 2012 Share Posted August 6, 2012 Thank you for the quick response Melba23. To bad BrettF is not longer active. I was sure he has the key to this problem... So would you suggest that I close this topic and start a new one regarding my Issuses with the Youtube API? Or shall i wait a few days to see if someone posts something helpfull here? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 6, 2012 Moderators Share Posted August 6, 2012 stereospeaker, As the thread is now on the first page, wait a few days and see if you get any replies. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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