Jump to content

AutID

Active Members
  • Posts

    519
  • Joined

  • Last visited

About AutID

  • Birthday 04/29/1987

Profile Information

  • Location
    Somewhere in Europe
  • Interests
    Cats, guitar, sports, computers and of course cooking since it is my job ;)

Recent Profile Visitors

704 profile views

AutID's Achievements

  1. I am aware of your UDF and it the first thing I would do without a second thought if I could use Excel. Unfortunately it is not installed in every system we have. Look promising... I took a look and modified the UDF a bit. Will look in that better this weekend. Thank you.
  2. Hello, Is there a way to draw candlesticks like in the picture below? I need to draw them not use them as image.
  3. Hello, I have a string where I need to extract the time from it. I am currently doing it with StringSplit but I'd love to see other versions. Here is my way. Local $sText = '2016/10/14 07:31:09">07:31' Local $sSplit = StringSplit($sText, ':') MsgBox(0, "", StringRight($sSplit[1], 2) & ":" & $sSplit[2] & ":" & StringLeft($sSplit[3], 2)) Anyone who has time to share some other knowledge is welcome. Edit: I would like to see some regex version of it, not StringSplit versions Edit2: Another way here: Local $sText = '2016/10/14 07:31:09">07:31' Local $sSplit = _StringBetween($sText, ' ', '"')[0] MsgBox(0, "", $sSplit)
  4. sry my fault. Got this working. It was just a typo mistake. Please delete thread
  5. I am trying to get Spotify User's playlists via http requests using WinHTTP.au3. Now according to their site, application's requests authorization should look something like this. #include "WinHttp.au3" Local $hOpen = _WinHttpOpen('Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)') Local $sURL = "https://accounts.spotify.com/authorize/?" Local $ClientId = "26d287105e31491889f3cd293d85bfea" Local $ResponseType = "code" Local $sRedirectURI = "http://localhost:8000" Local $aState = "XSS" Local $aURL = $sURL & "client_id=" & $ClientId & "&response_type=" & $ResponseType & "&redirect_uri=" & $sRedirectURI & "&state=" & $aState & "&scope=playlist-read-private user-read-private user-read-email user-library-read user-follow-read user-read-birthdate" Local $hConnect = _WinHttpConnect($hOpen, $aURL) Local $sData = _WinHttpSimpleSSLRequest($hConnect) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ConsoleWrite($sData & @CRLF) This would work on a browser however I am not sure http requests support these kind of request. Normally on a browser at this point the user is asked to authorize the access by submitting his credentials in case they are not saved. He is then redirected to the Redirect uri and granted access. So my questions are simple. Before loosing too much time on this for nothing, is it possible to achieve what I'm trying to? If yes, what should my next step be?
  6. I have some nested async methods calling each other and it is confusing. I am trying to convert a project which downloads the files in an async download. On the click of the download button this is the method triggered: private async void enableOfflineModeToolStripMenuItem_Click(object sender, EventArgs e) { for(int i = 0; i < _playlists.Count; i++) { DoubleDimList.Add(new List<String>()); for(int j = 0; j < 5; j++) { string sMp3 = IniReadValue(_playlists[i], "Track " + j); DoubleDimList[i].Add(sMp3); } await Task.Run(() => _InetGetHTMLSearchAsyncs(DoubleDimList[i])); } } It creates a 2d List which at the end looks like this DoubleDimList[3][20]. At the end of each sublist I am doing an async download as you can see. The method looks like this private async Task _InetGetHTMLSearchAsyncs(List<string> urlList) { foreach (var url in urlList) { await Task.Run(() => _InetGetHTMLSearchAsync(url)); } } the _InetGetHTMLSearchAsync method looks like this and here is where it gets tricky private async Task _InetGetHTMLSearchAsync(string sTitle) { Runs++; if (AudioDumpQuery == string.Empty) { //return string.Empty; } string sResearchURL = "http://www.audiodump.biz/music.html?" + AudioDumpQuery + sTitle.Replace(" ", "+"); try { using (var client = new WebClient()) { client.Headers.Add("Referer", @"http://www.audiodump.com/"); client.Headers.Add("user-agent", "Mozilla / 5.0(Macintosh; Intel Mac OS X 10_9_3) AppleWebKit / 537.75.14(KHTML, like Gecko) Version / 7.0.3 Safari / 7046A194A"); client.DownloadStringCompleted += Client_DownloadStringCompleted; await Task.Run(() => client.DownloadStringAsync(new Uri(sResearchURL))); } } catch (Exception ex) { Console.WriteLine("Debug message: " + ex.Message + "InnerEx: " + ex.StackTrace); Console.WriteLine("Runs: " + Runs); //throw exception return; } } On Client_DownloadStringCompleted there is another async method called. Here it is private async void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { string[] sStringArray; string aRet = e.Result; string[] aTable = _StringBetween(aRet, "<BR><table", "table><BR>", RegexOptions.Singleline); if (aTable != null) { string[] aInfos = _StringBetween(aTable[0], ". <a href=\"", "<a href=\""); if (aInfos != null) { for (int i = 0; i < 1; i++) { sStringArray = aInfos[i].Split('*'); sStringArray[0] = sStringArray[0].Replace("&#39;", "'"); aLinks.Add(sStringArray[0]); } await Task.Run(() => DownloadFile(aLinks[FilesDownloaded])); } } } From there, surprise! Another async call. private async Task DownloadFile(string url) { try { using (var client = new WebClient()) { client.Headers.Add("Referer", @"http://www.audiodump.biz/"); client.Headers.Add("user-agent", "Mozilla / 5.0(Macintosh; Intel Mac OS X 10_9_3) AppleWebKit / 537.75.14(KHTML, like Gecko) Version / 7.0.3 Safari / 7046A194A"); client.DownloadFileCompleted += Client_DownloadFileCompleted; await Task.Run(() => client.DownloadFileTaskAsync(url, mp3Path + "\\" + count + ".mp3")); } } catch (Exception Ex) { Console.WriteLine("File download error: " + Ex.StackTrace); //throw exception } } Now the first part after the creation of the 2d List is to retrieve the download links of the mp3s. The second part is to download the mp3 as soon as a valid URL was provided. It works but in a bizarre way. Instead of downloading the file normally(1st, 2nd, 3rd...), it will download randomly the files(1st, 5th, 8th...). Where am I messing this up because I definitely am!?
  7. Try elevating you program. Add #RequireAdmin on the top of your script and run scite as admin. If the click is actually performed but it is not interacting with the window then know that you script has to have the same privileges as the window you are interacting, or higher.
  8. That was a really helpful post. I am using winhttp. I knew it has to do with the requests. Will get it worked and come back for feedback. Thank you
  9. Let me explain you. So normally in the site, to perform a search for U2(musical band) the url would be http://www.audiodump.biz/music.html?p=1&v=9ac3&q=u2 according to the way you are doing it. However that page doesn't give me the search results. It redirects me here: There are not infos to extract from that redirected link such as mp3 titles, urls etc...
  10. Hey again. It's been a while! As you remember I have taken some of the function you used to have. I want to update a project I had based on those function I took from you. I see that mp3skull and the other servers are not so reliable anymore so I came here and I see you have a lot of updates. It looks great btw. I visited audiodump.com manually to saw how the search engine works and it looks fine. However I have a question. How do you get the research url. In your code I see these two lines that give me some question: $sQuery = $aValue1[0] & '=' & $aValue2[0] & '&' & $aValue1[1] & '=' & $aValue2[1] & '&' & $aValue3[0] & '=' $sResearchUrl = 'http://www.audiodump.biz/music.html?' & $sQueryString & StringReplace ( $sDefault, ' ' , '+' )   Now the first one I understand. They way you get the query. Found that by myself as well. However the second line is difficult. How can you use a prefix "http://www.audiodump.biz/music.html?" + sQuery + artist? This "music.html?" part changes according to each artist. For example a search for adele would be http://www.audiodump.biz/lyrics.html?p=1&v=3af3&q=adele instead of http://www.audiodump.biz/music.html?p=1&v=3af3&q=adele How does it work for you? Edit: You are using Curl.au3 which I am not familiar at all. It could be the reason I am missing something here
  11. Try adding #RequireAdmin on the top of your script and see what it gives. If you are running scite as Admin then your script can interact with elevated windows that are running as Admin or require Admin. When you compile it, you might be loosing this privilege.
  12. Thanks for sharing. Let me share with you another example using WinHTTP.au3 > https://www.autoitscript.com/forum/topic/84133-winhttp-functions/ A friend gave this code to me a while ago while helping me. #include "WinHttp.au3" ; Download some gif ;~ http://33.media.tumblr.com/dd3ffab90cc338666f192fd86f6a4f8f/tumblr_n0pefhIpss1swyb6ao1_500.gif ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, "http://33.media.tumblr.com") ; Specify the reguest $hRequest = _WinHttpOpenRequest($hConnect, Default, "dd3ffab90cc338666f192fd86f6a4f8f/tumblr_n0pefhIpss1swyb6ao1_500.gif") ; Send request _WinHttpSendRequest($hRequest) ; Wait for the response _WinHttpReceiveResponse($hRequest) ;~ ConsoleWrite(_WinHttpQueryHeaders($hRequest) & @CRLF) ProgressOn("Downloading", "In Progress...") Progress(_WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_CONTENT_LENGTH)) Local $sData ; Check if there is data available... If _WinHttpQueryDataAvailable($hRequest) Then While 1 $sChunk = _WinHttpReadData_Ex($hRequest, Default, Default, Default, Progress) If @error Then ExitLoop $sData &= $sChunk Sleep(20) WEnd Else MsgBox(48, "Error", "Site is experiencing problems (or you).") EndIf Sleep(1000) ProgressOff() ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Do whatever with data, write to some file or whatnot. I'll just print it to console here: ConsoleWrite($sData & @CRLF) Local $hFile = FileOpen(@DesktopDir & "\test.gif", 26) FileWrite($hFile, $sData) FileClose($hFile) Func Progress($iSizeAll, $iSizeChunk = 0) Local Static $iMax, $iCurrentSize If $iSizeAll Then $iMax = $iSizeAll $iCurrentSize += $iSizeChunk Local $iPercent = Round($iCurrentSize / $iMax * 100, 0) ProgressSet($iPercent, $iPercent & " %") EndFunc Func _WinHttpReadData_Ex($hRequest, $iMode = Default, $iNumberOfBytesToRead = Default, $pBuffer = Default, $vFunc = Default) __WinHttpDefault($iMode, 0) __WinHttpDefault($iNumberOfBytesToRead, 8192) __WinHttpDefault($vFunc, 0) Local $tBuffer, $vOutOnError = "" If $iMode = 2 Then $vOutOnError = Binary($vOutOnError) Switch $iMode Case 1, 2 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("byte[" & $iNumberOfBytesToRead & "]") EndIf Case Else $iMode = 0 If $pBuffer And $pBuffer <> Default Then $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]", $pBuffer) Else $tBuffer = DllStructCreate("char[" & $iNumberOfBytesToRead & "]") EndIf EndSwitch Local $sReadType = "dword*" If BitAND(_WinHttpQueryOption(_WinHttpQueryOption(_WinHttpQueryOption($hRequest, $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_PARENT_HANDLE), $WINHTTP_OPTION_CONTEXT_VALUE), $WINHTTP_FLAG_ASYNC) Then $sReadType = "ptr" Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpReadData", _ "handle", $hRequest, _ "struct*", $tBuffer, _ "dword", $iNumberOfBytesToRead, _ $sReadType, 0) If @error Or Not $aCall[0] Then Return SetError(1, 0, "") If Not $aCall[4] Then Return SetError(-1, 0, $vOutOnError) If IsFunc($vFunc) Then $vFunc(0, $aCall[4]) If $aCall[4] < $iNumberOfBytesToRead Then Switch $iMode Case 0 Return SetExtended($aCall[4], StringLeft(DllStructGetData($tBuffer, 1), $aCall[4])) Case 1 Return SetExtended($aCall[4], BinaryToString(BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4]), 4)) Case 2 Return SetExtended($aCall[4], BinaryMid(DllStructGetData($tBuffer, 1), 1, $aCall[4])) EndSwitch Else Switch $iMode Case 0, 2 Return SetExtended($aCall[4], DllStructGetData($tBuffer, 1)) Case 1 Return SetExtended($aCall[4], BinaryToString(DllStructGetData($tBuffer, 1), 4)) EndSwitch EndIf EndFunc Now this is how you download a file with progessbar
×
×
  • Create New...