wakillon Posted August 11, 2010 Author Posted August 11, 2010 (edited) Yes, it is exactly that i want , but if i can to have the in the beginning of each line the Number (0 to 100) please? 01 - Song Title - Songer Name 02 - Song2 Title - Songer2 Name 03 - Song3 Title - Songer3 Name Thanks Did you have tested RideRunner and WebRadio ? Sorry Not yet Your Solution : $_LastUkTopChartsListArray = _GetLastUkTopChartsListArray ( $_LastChartPageSourceCode ) $_TxtFilePath = @TempDir & "\WebRadio.txt" For $_I = 1 To UBound ( $_LastUkTopChartsListArray ) $_LastUkTopChartsListArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_LastUkTopChartsListArray[$_I] Next _FileWriteFromArray ( $_TxtFilePath, $_LastUkTopChartsListArray, 1 ) ShellExecute ( $_TxtFilePath ) A skiny Update expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Radio.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : Wakillon Title : TinyUKChartsStreamPlayer Script Fonction : Listen Last 100 Uk Top Charts singles like a radio in random order and without advertising by getting charts List on charts website and search song's list on youtube. _ ESC for Quit _ WebSite http://www.chartstats.com/chart.php is updated weekly #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <GUIStatusBar.au3> #Include <GuiListView.au3> #include <String.au3> #include <File.au3> #include <Misc.au3> #include <Date.au3> #include <IE.au3> HotKeySet ( "{ESC}", "_Terminate" ) If Not _Singleton ( @ScriptName, 1 ) Then Exit Dim $Sec, $Min, $Hour, $Time, $_ButtonWidth = 120, $_X=368, $_PicSize=120, $_Spaces=' ' Dim $_Text= @Crlf & $_Spaces & '_ ESC for Quit' Dim $_DurationDiff, $_DurationMs, $_GetItem, $_RandomMode=1, $oIE, $_PicPathOld Dim $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyUKChartsStreamPlayer" Dim $_RegKeySettings = "HKEY_CURRENT_USER\Software\TinyUKChartsStreamPlayer\Settings" Global $_LastUkTopChartsListArray[1], $_ImagesUrlArray[1], $_RandomArray[1], $_DurationArray[1] Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( ) Global $_StatusBar, $_Loop=0 Global $_StatusParts[1] = [500], $_TempStatus[1] = [""] Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]] Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) $_RegReadFirstStart = RegRead ( $_RegKeySettings, "FirstStart" ) If $_RegReadFirstStart ='' Then DirRemove ( @TempDir & '\TUKCSP\Pics', 1 ) RegDelete ( "HKEY_LOCAL_MACHINE\SOFTWARE\TinyUKChartsStreamPlayer\Singles-Chartstats" ) EndIf Opt ( "TrayMenuMode", 1 ) TraySetIcon ( "Shell32.dll", -129 ) TraySetToolTip ( " TinyUKChartsStreamPlayer" & @Crlf & StringStripWS ( $_Text, 7 ) ) TraySetState ( 4 ) AdlibRegister ( "__Slide_CheckHover", 100 ) OnAutoItExitRegister ( "_OnAutoItExit" ) _FileInstall ( ) Do Sleep ( 1000 ) ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 ) Until _IsConnected ( ) ToolTip ( '' ) $_SubKey = 'Singles-Chartstats' $_LastChartsUrl = 'http://www.chartstats.com/chart.php' $_UpdateDate = _GetUpdateDate ( $_LastChartsUrl ) $_RegUpdateDate = RegRead ( $_Key & '\' & $_SubKey, 'UpdateDate' ) If $_UpdateDate <> $_RegUpdateDate Then ToolTip ( $_Spaces & 'Searching Last 100 Uk Top Charts List...' & @Crlf & @Crlf & $_Text, @DesktopWidth/2-100, 0, 'Tiny UK Charts Stream Player', 1, 4 ) RegDelete ( $_Key & '\' & $_SubKey ) $_LastUkTopChartsListArray = _GetLastUkTopChartsListArray ( $_LastChartPageSourceCode ) ToolTip ( '' ) Else For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_SubKey, $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_SubKey, $_Value ) _ArrayAdd ( $_LastUkTopChartsListArray, $_RegRead ) EndIf Next EndIf $_LastUkTopChartsListArray[0] = UBound ( $_LastUkTopChartsListArray )-1 If _IsArrayEmpty ( $_LastUkTopChartsListArray ) Then Exit MsgBox ( 0, 'Error', 'Sorry Uk Top Charts List Not Found !', 5 ) _GetPics ( $_ImagesUrlArray ) Dim $_ListViewItem[$_LastUkTopChartsListArray[0]+1] Dim $_GuiTitle='Tiny UK ' & $_SubKey & ' Stream Player ' & $_UpDateDate Opt ( "GuiOnEventMode", 1 ) $_Gui = GUICreate ( $_GuiTitle, 500, 330, @DesktopWidth-507, @DesktopHeight - 360, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) _Skin ( ) GUISetBkColor ( 0xFFD900 ) GUISetIcon ( "Shell32.dll", -129 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Terminate" ) $_ListView = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 340, 260 ) _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER ) For $_G = 1 To UBound ( $_LastUkTopChartsListArray ) - 1 $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_LastUkTopChartsListArray[$_G], $_ListView ) Next $_RandomButton = GUICtrlCreateButton ( "Disable Random Mode", $_X, 149, $_ButtonWidth, 24 ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetState ( $_RandomButton, $GUI_DISABLE ) $_NextButton = GUICtrlCreateButton ( "Next Random Song", $_X, 185, $_ButtonWidth, 24 ) GUICtrlSetOnEvent ( $_NextButton, "_NextSong" ) $_SelectButton = GUICtrlCreateButton ( "Listen Selected Song", $_X, 221, $_ButtonWidth, 24 ) GUICtrlSetOnEvent ( $_SelectButton, "_SelectSong" ) GUICtrlSetBkColor ( $_SelectButton, 0xFFFF00 ) GUICtrlSetColor ( $_SelectButton, 0xff0000 ) GUICtrlSetState ( $_SelectButton, $GUI_DISABLE ) $_ExitButton = GUICtrlCreateButton ( "Exit", $_X, 257, $_ButtonWidth, 24 ) GUICtrlSetOnEvent ( $_ExitButton, "_Terminate" ) $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP ) _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 ) $_Icons = _WinAPI_LoadShell32Icon ( 128 ) _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons ) _Slide_WinSetSlide ( $_Gui, "top" ) _Slide_SlideSetOnHover ( $_Gui ) GUISetState ( @SW_SHOW ) While 1 If $_RandomMode Then $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) $_Text2 = $_LastUkTopChartsListArray[$_R] _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & ' Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] & ' official' ) If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then $_Loop=1 $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 GUICtrlSetState ( $_RandomButton, $GUI_ENABLE ) $_PicPath = @TempDir & '\TUKCSP\Pics\' & $_LastUkTopChartsListArray[$_R] & '.jpg' GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) Else $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) EndIf GUICtrlSetState ( $_Pic, $GUI_SHOW ) DLLCall ( "user32.dll", "int", "InvalidateRect", "hwnd", $_Gui, "int", 0, "int", 0 ) _WinSetOnTopOneTime ( $_GuiTitle ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_LastUkTopChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 ) _WinSetOnTopOneTime ( $_GuiTitle ) Sleep ( 2000 ) EndIf EndIf $_PicPath = @TempDir & '\TUKCSP\Pics\' & $_Text2 & '.jpg' If $_PicPath <> $_PicPathOld Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_PicPathOld = $_PicPath $_PicPath='' GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then $_ProcessListArray = ProcessList ( "iexplore.exe" ) For $i = 1 to $_ProcessListArray[0][0] _ReduceMemory ( $_ProcessListArray[$i][1] ) Next EndIf While $_Loop If $_DurationDiff > $_DurationMs Then _IEQuit ( $oIE ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) ExitLoop EndIf Sleep ( 20 ) If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) $_DurationMs = $_Duration * 1000 If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) ) _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec ) If $_Text2 Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then $_ProcessListArray = ProcessList ( "iexplore.exe" ) For $i = 1 to $_ProcessListArray[0][0] _ReduceMemory ( $_ProcessListArray[$i][1] ) Next EndIf WEnd WEnd Func _GetPics ( $_PicsArray ) If Not FileExists ( @TempDir & '\TUKCSP\Pics' ) Then DirCreate ( @TempDir & '\TUKCSP\Pics' ) For $_P = 1 To UBound ( $_PicsArray ) -1 $_PicPath = @TempDir & '\TUKCSP\Pics\' & $_LastUkTopChartsListArray[$_P] & '.jpg' If Not FileExists ( $_PicPath ) Then InetGet ( $_PicsArray[$_P], $_PicPath, 1, 0 ) If Not FileExists ( $_PicPath ) Then FileCopy ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_PicPath ) EndIf Next EndFunc ;==> _GetPics ( ) Func _SelectSong ( ) If $_Loop Then _IEQuit ( $oIE ) $_GetItem = _GetItem ( ) ConsoleWrite ( "$_GetItem : " & $_GetItem & @Crlf ) If $_GetItem Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_GetItem & ' official' ) $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 $_PicPath = @TempDir & '\TUKCSP\Pics\' & $_GetItem & '.jpg' ConsoleWrite ( "$_PicPath : " & $_PicPath & @Crlf ) If FileExists ( $_PicPath ) Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) $_Pic = GUICtrlCreatePic ( $_PicPath, $_X, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf $_Text2 = $_GetItem $_Loop =1 EndIf EndFunc ;==> _SelectSong ( ) Func _RandomMode ( ) If $_Loop Then _IEQuit ( $oIE ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) GUICtrlSetState ( $_RandomButton, $GUI_HIDE ) If $_RandomMode = 1 Then $_RandomMode=0 GUICtrlSetState ( $_SelectButton, $GUI_ENABLE ) GUICtrlSetState ( $_NextButton, $GUI_DISABLE ) $_RandomButton = GUICtrlCreateButton ( "Enable Random Mode", $_X, 149, $_ButtonWidth, 24 ) Else $_RandomMode = 1 GUICtrlSetState ( $_SelectButton, $GUI_DISABLE ) GUICtrlSetState ( $_NextButton, $GUI_ENABLE ) $_RandomButton = GUICtrlCreateButton ( "Disable Random Mode", $_X, 149, $_ButtonWidth, 24 ) EndIf $_Text2='' GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) EndFunc ;==> _RandomMode ( ) Func _NextSong ( ) _IEQuit ( $oIE ) $_Loop=0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) EndFunc ;==> _NextSong ( ) Func _InvertColorButton ( $_GuiCtrl ) If $_Invert Then GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 ) GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) $_Invert=False Else GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 ) GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 ) $_Invert=True EndIf EndFunc ;==> _InvertColorButton ( ) Func _EachXseconds ( $_Interval ) $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 ) If $_TimerDiff >= $_Interval Then $_InvertTimerInit = TimerInit ( ) Return 1 Else Return 0 EndIf EndFunc ;==> _EachXseconds ( ) Func _GetItem ( ) $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) If $_Select Then $_SelectSplit = StringSplit ( $_Select, '|' ) If Not @error Then $_R=$_SelectSplit[1] $_Select = $_SelectSplit[2] If $_Select Then Return $_Select EndIf EndIf EndFunc ;==> _GetItem ( ) Func _GetUpdateDate ( $_LastChartsUrl ) Local $_UpDateDate $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl ) $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '<title>Chart Stats - Singles Chart For ', "<" ) If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )' Return $_UpDateDate EndFunc ;==> _GetUpdateDate ( ) Func _GetLastUkTopChartsListArray ( $_SourceCode ) Local $_NamesArray[1], $_Add $_SourceCodeSplitArray = StringSplit ( $_SourceCode, @CRLF ) For $_I = 1 To UBound ( $_SourceCodeSplitArray ) -1 If StringInStr ( $_SourceCodeSplitArray[$_I], ';padding:none">' ) <> 0 Then $_String = $_SourceCodeSplitArray[$_I] ExitLoop EndIf Next $_StringInstrArrayOfLine = _StringInstrArrayOfLine ( $_String, ';padding:none"' ); $_StringBetweenArrayByStringInstrArray = _StringBetweenArrayByStringInstrArray ( $_String, $_StringInstrArrayOfLine, 'href="', '" width' ) For $_I = 1 To UBound ( $_StringBetweenArrayByStringInstrArray ) -1 $_StringBetween = _StringBetween ( $_StringBetweenArrayByStringInstrArray[$_I], 'img src="', '"' ) If Not @error Then If StringInStr ( $_StringBetweenArrayByStringInstrArray[$_I], 'artistinfo.php?id=' ) = 0 Then _ArrayAdd ( $_ImagesUrlArray, 'http://www.chartstats.com/' & $_StringBetween[0] ) Else _ArrayAdd ( $_ImagesUrlArray, '' ) EndIf EndIf $_StringBetween = _StringBetween ( $_StringBetweenArrayByStringInstrArray[$_I], 'title="', '' ) If Not @error Then If StringInStr ( $_StringBetweenArrayByStringInstrArray[$_I], 'artistinfo.php?id=' ) = 0 Then $_Name = _CleanHtmlName ( _CleanVideoName ( $_StringBetween[0] ) ) _ArrayAdd ( $_NamesArray, $_Name ) $_Add = $_Add + 1 RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name ) Else $_StringBetween = _StringBetween ( $_StringBetweenArrayByStringInstrArray[$_I], '">', '</a></td' ) If Not @error Then $_Remove = _StringBetween ( $_StringBetween[0], '</a>', '">' ) $_Name = _CleanHtmlName ( _CleanVideoName ( StringReplace ( $_StringBetween[0], '</a>' & $_Remove[0] & '">', ' - ' ) ) ) _ArrayAdd ( $_NamesArray, $_Name ) $_Add = $_Add + 1 RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name ) EndIf EndIf EndIf Next $_ImagesUrlArray[0]=UBound ( $_ImagesUrlArray ) -1 $_NamesArray[0]=UBound ( $_NamesArray ) -1 RegWrite ( $_Key & '\' & $_SubKey, 'UpdateDate', "REG_SZ", $_UpdateDate ) Return $_NamesArray EndFunc ;==> _GetLastUkTopChartsListArray ( ) Func _YoutubeSearch ( $_Query ) Dim $_WordOfQuery[1] $_QuerySplit = StringSplit ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_Query, 'è', 'e' ), 'é', 'e' ), "\W", " " ) , 7 ), ' ' ) For $_I = 1 To UBound ( $_QuerySplit ) - 1 If StringLen ( $_QuerySplit[$_I] ) > 1 Then _ArrayAdd ( $_WordOfQuery, StringReplace ( $_QuerySplit[$_I], ',', ' ' ) ) Next $_WordOfQuery[0] = UBound ( $_WordOfQuery ) - 1 $_Query = StringReplace ( $_Query, " ", "+" ) $_Query = StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace _ ( StringReplace ( StringStripWS ( $_Query, 7 ), ',', '%2C' ), '&', '%26' ), '(', '%28' ), ')', '%29' ), "'", '%27' ), 'è', 'e' ), 'é', 'e' ), '«', ' ' ), '»', ' ' ) $_SourceCode = _GetSourceCode ( "http://www.youtube.com/results?search_query=" & $_Query ) $_SourceCodeSplit = StringSplit ( $_SourceCode, @CRLF ) Dim $_Watch[1], $_DurationArray[1] For $_I = 1 To UBound ( $_SourceCodeSplit )-1 If StringInStr ( $_SourceCodeSplit[$_I], '/watch?v=' ) <> 0 And StringInStr ( $_SourceCodeSplit[$_I], 'video-long-title' ) <> 0 Then _ArrayAdd ( $_Watch, $_SourceCodeSplit[$_I] ) If StringInStr ( $_SourceCodeSplit[$_I-17], 'video-time">' ) <> 0 Then $_VideoTime = _StringBetween ( $_SourceCodeSplit[$_I-17], 'video-time">', '<' ) If Not @error Then $_DurationSplit = StringSplit ( $_VideoTime[0], ':' ) $_DurationSplit[0]=UBound ( $_DurationSplit ) -1 $_Duration = $_DurationSplit[1]*60 + $_DurationSplit[$_DurationSplit[0]] _ArrayAdd ( $_DurationArray, $_Duration ) Else _ArrayAdd ( $_DurationArray, 240 ) EndIf Else _ArrayAdd ( $_DurationArray, 240 ) EndIf EndIf Next For $_I = 1 To UBound ( $_Watch )-1 $Titles = _StringBetween ( $_Watch[$_I], 'title="', '" rel=' ) If Not @error Then If Not _OneOfThisStringInStr ( $Titles[0], 'Karaok|Singing|parod|Fête' ) Then $Link = _StringBetween ( $_Watch[$_I], 'href="', '"' ) If Not @error Then If StringInStr ( $Link[0], 'http://www.youtube.com' ) = 0 Then $_UrlToExtract = "http://www.youtube.com" & $Link[0] Else $_UrlToExtract = $Link[0] EndIf $_Duration = $_DurationArray[$_I] Return $_UrlToExtract EndIf EndIf EndIf Next Endfunc ;==> _YoutubeSearch ( ) Func _OneOfThisStringInStr ( $_InStr, $_String ) $_StringArray = StringSplit ( $_String, '|' ) If @error Then Return 0 For $_I = 1 To UBound ( $_StringArray ) -1 $_StringInStr = StringInStr ( $_InStr, $_StringArray[$_I] ) If $_StringInStr <> 0 Then Return 1 Next Return 0 EndFunc ;==> _OneOfThisStringInStr ( ) Func _StringBetweenArrayByStringInstrArray ( $_String, $_StringInStrArray, $_Start, $_End ) Dim $_ArrayAdd[1] For $_I = 1 To UBound ( $_StringInStrArray ) -1 $_StringRight = StringRight ( $_String, StringLen ( $_String ) - $_StringInStrArray[$_I] +1 ) Local $_StringBetween = _StringBetween ( $_StringRight, $_Start, $_End ) If Not @error Then _ArrayAdd ( $_ArrayAdd, $_StringBetween[0] ) Next Return $_ArrayAdd EndFunc ;==> _StringBetweenArrayByStringInstrArray ( ) Func _StringInstrArrayOfLine( $_String, $_StringToFind ) Dim $_ArrayAdd[1] For $_I = 1 To StringLen ( $_String ) $_StringInStr = StringInStr ( $_String, $_StringToFind, 0, $_I ) If $_StringInStr = 0 Then $_ArrayAdd[0] = UBound ( $_ArrayAdd ) -1 Return $_ArrayAdd Else _ArrayAdd ( $_ArrayAdd, $_StringInStr ) EndIf Next EndFunc ;==> _StringInstrArrayOfLine( ) Func _CleanVideoName ( $_Name ) $_Name2 = StringRegExpReplace ( $_Name, '(")|(")|(quot;)|(&)|(amp;)|(<)|(lt;)|(>)|(gt;)|(#39;)', '' ) $_Name2 = StringReplace ( $_Name2, 'ç', 'c' ) $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' ) $_Name2 = StringReplace ( $_Name2, '€', '€' ) $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' ) $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' ) $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' ) $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' ) $_Name2 = StringReplace ( $_Name2, '\', '' ) $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' ) $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' ) Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) ) EndFunc ;==> _CleanVideoName ( ) Func _CleanHtmlName ( $_Name ) $_Name2 = StringReplace ( $_Name, '%2C', ',' ) $_Name2 = StringReplace ( $_Name2, '%82', ',' ) $_Name2 = StringReplace ( $_Name2, '%27', "'" ) $_Name2 = StringReplace ( $_Name2, '&039', "'" ) Return $_Name2 EndFunc ;==> _CleanHtmlName ( ) Func _Randomize ( $_Max=100 ) Do $_Random = Random ( 1, $_Max, 1 ) Until Not _AlreadyInArray ( $_RandomArray, $_Random ) _ArrayAdd ( $_RandomArray, $_Random ) $_RandomArray[0] = UBound ( $_RandomArray ) -1 If $_RandomArray[0] >= $_Max Then ReDim $_RandomArray[1] Return $_Random EndFunc ;==> _Randomize ( ) Func _AlreadyInArray ( $_SearchArray, $_Item ) $_Index = _ArraySearch ( $_SearchArray, $_Item ) If @error Then Return False Else If $_Index <> 0 Then Return True Else Return False EndIf EndIf EndFunc ;==> _AlreadyInArray ( ) Func _GetSourceCode ( $_Url ) $_InetRead = InetRead ( $_Url ) If Not @Error Then $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode ( ) Func _IsArrayEmpty ( $_EmptyArray ) Local $_V = UBound ( $_EmptyArray ) -1, $_P If $_V = 0 Then Return True For $_F = 1 To $_V If $_EmptyArray[$_F] = '' Then $_P = $_P + 1 Next If $_P = $_V Then Return True Else Return False EndIf EndFunc ;==> _IsArrayEmpty ( ) Func _IsConnected ( ) $_SrcFilePath = _TempFile ( @TempDir & "\", '~google_', ".src", 7 ) Local $IsConnected = InetGet ( "http://www.google.com", $_SrcFilePath, 1, 1 ) Local $_Info Do $_Info = InetGetInfo ( $IsConnected ) Sleep ( 50 ) Until $_Info[2] = True InetClose ( $IsConnected ) _Delete ( $_SrcFilePath ) If $_Info[3] <> True Then Return 0 Else Return 1 EndIf EndFunc ;==> _IsConnected ( ) Func _IsValidUrl ( $_IsValidUrl ) $_Size = InetGetSize ( $_IsValidUrl ) If $_Size <> 0 Then Return 1 Endfunc ;==> _IsValidUrl ( ) Func _Delete ( $_FullPath ) $_DeleteInit = TimerInit ( ) While FileExists ( $_FullPath ) If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then DirRemove ( $_FullPath, 1 ) Else FileDelete ( $_FullPath ) EndIf If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0 WEnd Return 1 EndFunc ;==> _Delete ( ) Func _WinSetOnTopOneTime ( $_WinTitle ) WinWait ( $_WinTitle, "", 2 ) WinSetOnTop ( $_WinTitle, "", 1 ) Sleep ( 250 ) WinSetOnTop ( $_WinTitle, "", 0 ) WinActivate ( $_WinTitle, "" ) EndFunc ;==> _WinSetOnTopOneTime ( ) Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 ) If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $iMode Case 1 ReDim $__SLIDE_aGUI[$iUbound + 1][5] $__SLIDE_aGUI[$iUbound][0] = $hWnd $__SLIDE_aGUI[$iUbound][1] = $sSide $__SLIDE_aGUI[$iUbound][2] = True $__SLIDE_aGUI[$iUbound][3] = False $__SLIDE_aGUI[$iUbound][4] = False _Slide_SlideOut ( $hWnd ) GUISetState ( @SW_SHOWNOACTIVATE, $hWnd ) Case 0 For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then For $j = $i To UBound($__SLIDE_aGUI) - 2 $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0] $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1] $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2] $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3] $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4] ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5] _Slide_SlideIn ( $hWnd ) GUISetState ( @SW_HIDE, $hWnd ) Next EndIf Next EndSwitch EndFunc ;==> _Slide_WinSetSlide ( ) Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $sMode Case True For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = True EndIf Next Case False For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = False EndIf Next EndSwitch EndFunc ;==> _Slide_SlideSetOnHover ( ) Func _Slide_SlideOut ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = False Return SetError ( 0, 0, 1 ) Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideOut ( ) Func _Slide_SlideIn ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If Not $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = True Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideIn ( ) Func __Slide_WinSlide ( $hWnd, $sMode, $sSide ) Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) ) Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" ) Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" ) WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _ + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _ + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _ , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _ + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _ + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ) ) $aWPos = WinGetPos ( $hWnd ) Switch $sSide Case "left", "right" Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _ - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP For $i = $aWPos[0] To $TO Step $STEP WinMove ( $hWnd, "", $i, $aWPos[1] ) Sleep ( 10 ) Next Case "top", "bottom" Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _ - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP If $STEP > 0 Then $TO = $TO -25 For $i = $aWPos[1] To $TO + 25 Step $STEP ; WinMove ( $hWnd, "", $aWPos[0], $i ) Sleep ( 10 ) Next EndSwitch EndFunc ;==> __Slide_WinSlide ( ) Func __Slide_CheckHover ( ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][4] Then If Not $__SLIDE_aGUI[$i][3] Then If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] ) Else If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] ) EndIf EndIf EndIf Next EndFunc ;==> __Slide_CheckHover ( ) Func __Slide_UnloadDLL ( ) DllClose ( $__SLIDE_hDLL ) EndFunc ;==> __Slide_UnloadDLL ( ) Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" ) Local $aResult, $aWPos = WinGetPos ( $hWnd ) If @error Then Return Local $aMPos = MouseGetPos ( ) If @error Then Return Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" ) Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3] Local $iX = $aMPos[0], $iY = $aMPos[1] DllStructSetData ( $tRect, "Left", $iLeft ) DllStructSetData ( $tRect, "Top", $iTop ) DllStructSetData ( $tRect, "Right", $iLeft + $iWidth ) DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight ) $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY ) If @error Then Return SetError ( @error, 0, False ) Return $aResult[0] <> 0 EndFunc ;==> __Slide_WinIsHovered ( ) Func _Skin ( ) $Dll = DllOpen ( @TempDir & "\TUKCSP\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TUKCSP\skin\QQ2008.she", "str", "mhgd" ) DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _Skin ( ) Func _FileInstall ( ) DirCreate ( @TempDir & "\TUKCSP\skin" ) FileInstall ( "SkinH_EL.dll", @TempDir & "\TUKCSP\skin\SkinH_EL.dll" ) FileInstall ( "QQ2008.she", @TempDir & "\TUKCSP\skin\QQ2008.she" ) EndFunc ;==> _FileInstall ( ) Func _ReduceMemory ( $_PID ) Local $hPsAPIdll = "psapi.dll", $hKernel32dll = "kernel32.dll" If $_PID <> -1 Then Local $aHandle = DllCall ( $hKernel32dll, "int", "OpenProcess", "int", 0x1f0fff, "int", False, "int", $_PID ) Local $aReturn = DllCall ( $hPsAPIdll, "int", "EmptyWorkingSet", "long", $aHandle[0] ) DllCall ( $hKernel32dll, "int", "CloseHandle", "int", $aHandle[0] ) Endif EndFunc ;==>_ReduceMemory ( ) Func _Terminate ( ) RegWrite ( $_RegKeySettings, "FirstStart", "REG_SZ", 'done' ) _IEQuit ( $oIE ) Exit EndFunc ;==> _Terminate ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " TrayTip ( "TinyUKChartsStreamPlayer", $_Space & "by wakillon...", 1, 1 ) Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( ) Edited August 21, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
pierrotm777 Posted August 11, 2010 Posted August 11, 2010 (edited) Sorry Not yet Your Solution : $_LastUkTopChartsListArray = _GetLastUkTopChartsListArray ( $_LastChartPageSourceCode ) $_TxtFilePath = @TempDir & "\WebRadio.txt" For $_I = 1 To UBound ( $_LastUkTopChartsListArray ) $_LastUkTopChartsListArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_LastUkTopChartsListArray[$_I] Next _FileWriteFromArray ( $_TxtFilePath, $_LastUkTopChartsListArray, 1 ) ShellExecute ( $_TxtFilePath ) I have added these lines on the line 83 of your TinyUKChartsStreamPlayer7 !!! I obtain this error ! D:\Program Files\Ride Runner\Skins\Carwings_Dynamic_pm_new\Scripts\WebRadio\Orig\TinyUKChartsStreamPlayer7\TinyUKChartsStreamPlayer7.au3 (87) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $_LastUkTopChartsListArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_LastUkTopChartsListArray[$_I] ^ ERROR Edited August 11, 2010 by pierrotm777
wakillon Posted August 11, 2010 Author Posted August 11, 2010 (edited) Sorry I forgot the "-1" Try For $_I = 1 To UBound ( $_LastUkTopChartsListArray ) -1 It work fine ! Have you seen my new Topic ? Edited August 12, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted August 12, 2010 Author Posted August 12, 2010 (edited) Hi pierrotm777 !Oups, I made another mistake ! A better solution :Dim $_WebRadioArray[$_LastUkTopChartsListArray[0]+1] $_TxtFilePath = @TempDir & "\WebRadio.txt" For $_I = 1 To UBound ( $_LastUkTopChartsListArray ) -1 $_WebRadioArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_LastUkTopChartsListArray[$_I] Next _FileWriteFromArray ( $_TxtFilePath, $_WebRadioArray, 1 ) ShellExecute ( $_TxtFilePath )Otherwise $_LastUkTopChartsListArray was changed ! Edited August 12, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
pierrotm777 Posted August 13, 2010 Posted August 13, 2010 I have an issue with the pics files who are not downloaded , and i can't see the album art . I have this issue with the all version (3 to 7). An idea ?
pierrotm777 Posted August 13, 2010 Posted August 13, 2010 Ok, I have found my error (around the register keys).
wakillon Posted August 21, 2010 Author Posted August 21, 2010 (edited) A big update and I rename TinyUKChartsStreamPlayer in TinyChartsJukebox A first part : TinyChartsJukeboxexpandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Jukebox.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : wakillon Title : TinyChartsJukebox Script Fonction : Listen Last 100 Uk Top Charts singles like a radio in random order and without advertising by getting charts List on charts website and search song's list on youtube. _ WebSite http://www.chartstats.com/chart.php is update weekly _ Work with TinyYoutubeGrabber who download Youtube mp3. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <GUIStatusBar.au3> #Include <GuiListView.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> #include <Misc.au3> #include <Date.au3> #include <IE.au3> If Not _Singleton ( @ScriptName, 1 ) Then Exit Global $Sec, $Min, $Hour, $Time, $_ButtonWidth = 120, $_ButtonHeight=36, $_X=368, $_PicSize=118, $_ListView, $_Spaces=' ' Global $_DurationDiff, $_DurationMs, $_GetItem, $_RandomMode=1, $_RandomChoice, $_GenreTitle, $_Genre, $_DoubleClick, $_DoubleClickOld Global $oIE, $_PicPathOld, $_Dll, $_PID = ProcessExists ( @ScriptName ), $_YoutubeSearch, $_Text2 Global $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyChartsJukebox" Global $_LastUkTopChartsListArray[1],$_ChartsListArray[1], $_ImagesUrlArray[1], $_RandomArray[1] Global $_DurationArray[1], $_GenreButton[4+1], $_PidsArray[1], $_BlacklistArray[1], $_YoutubeUrlArray[1] Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( ) Global $_StatusBar, $_Loop=0, $_DownloadMode, $_TitleKey = 'TinyChartsJukebox' Global $_StatusParts[1] = [500], $_TempStatus[1] = [""] Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]] Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) Opt ( "GuiOnEventMode", 1 ) Opt ( "TrayOnEventMode", 1 ) Opt ( "TrayMenuMode", 1 ) TraySetIcon ( "Shell32.dll", -129 ) TraySetToolTip ( "Tiny Charts Jukebox" & @Crlf & "- LeftClick to Set Window On Top" & @Crlf & "- RightClick to Traymenu" ) TraySetOnEvent ( $TRAY_EVENT_PRIMARYUP, "_WinSetOnTopOneTime" ) TraySetIcon ( @TempDir & "\TYD\Youtube.ico" ) $_StartItem = TrayCreateItem ( "Start With Windows" ) $_RegRead = RegRead ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) If $_RegRead <> '' Then TrayItemSetState ( $_StartItem, $TRAY_CHECKED ) TrayItemSetOnEvent ( $_StartItem, "_StartWithWindows" ) TrayCreateItem ( "" ) $_AboutItem = TrayCreateItem ( "About" ) TrayItemSetOnEvent ( -1, "_About" ) TrayCreateItem ( "" ) $_YoutubeItem = TrayCreateItem ( "Open Youtube" ) TrayItemSetOnEvent ( -1, "_OpenYoutube" ) TrayCreateItem ( "" ) $_OutputItem = TrayCreateItem ( "Open Download Directory" ) TrayItemSetOnEvent ( -1, "_OpenDownloadDirectory" ) TrayCreateItem ( "" ) $_ExitItem = TrayCreateItem ( "Exit" ) TrayItemSetOnEvent ( -1, "_Terminate" ) TraySetClick ( 16 ) TraySetState ( 4 ) AdlibRegister ( "__Slide_CheckHover", 100 ) OnAutoItExitRegister ( "_OnAutoItExit" ) _FileInstall ( ) _WaitUntilConnected ( ) _Init ( ) _GetBlacklist ( ) Dim $_ListViewItem[UBound ( $_ChartsListArray )] Dim $_GuiTitle='Tiny Charts ' & $_GenreTitle[$_RandomChoice] & ' Jukebox ' & $_UpDateDate $_Gui = GUICreate ( $_GuiTitle, 635, 340, @DesktopWidth-507, @DesktopHeight - 360, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) _GuiSkin ( ) GUISetBkColor ( 0xFFD900 ) GUISetIcon ( "Shell32.dll", -129 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Terminate" ) _GUICtrlCreateListViewItems ( $_ChartsListArray ) $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_RandomButton = GUICtrlCreateButton ( "Enable Manual Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetState ( $_RandomButton, $GUI_DISABLE ) $_NextButton = GUICtrlCreateButton ( "Next Random Song", 502, 65, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_NextButton, "Listen an other songs of this List" ) GUICtrlSetOnEvent ( $_NextButton, "_NextSong" ) GUICtrlCreateGroup ( 'Select Genre', $_X+4, 149, 118, 130 ) _GUICtrlCreateRadioButtons ( UBound ( $_Genre ) -1 ) $_BlackListButton= GUICtrlCreateButton ( "Add To Blacklist", 502, 110, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_BlackListButton, "Add this Youtube Url To Blacklist, it will be not listened" ) GUICtrlSetOnEvent ( $_BlackListButton, "_AddToBlacklist" ) $_ResetButton = GUICtrlCreateButton ( "Reset BlackList", 502, 154, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ResetButton, "Reset BlackList Only for this Song" ) GUICtrlSetOnEvent ( $_ResetButton, "_ResetBlackList" ) $_DownloadButton = GUICtrlCreateButton ( "Download This mp3", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Download and Normalize this Mp3 Song to your Desktop download directory" ) GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) $_ExitButton = GUICtrlCreateButton ( "Exit", 502, 244, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ExitButton, "Goodbye..." ) GUICtrlSetOnEvent ( $_ExitButton, "_Terminate" ) $_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP ) _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 ) $_Icons = _WinAPI_LoadShell32Icon ( 128 ) _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons ) _Slide_WinSetSlide ( $_Gui, "top" ) _Slide_SlideSetOnHover ( $_Gui ) GUISetState ( @SW_SHOW ) If ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) While 1 If $_RandomMode Then $_R = _Randomize ( UBound ( $_ChartsListArray ) -1 ) $_Text2 = $_ChartsListArray[$_R] _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & ' Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_ChartsListArray[$_R] & ' official' ) If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then $_Loop=1 $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 GUICtrlSetState ( $_RandomButton, $GUI_ENABLE ) GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) $_PicPath = @TempDir & '\TCJ\Pics\' & $_ChartsListArray[$_R] & '.jpg' GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) Else $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) EndIf GUICtrlSetState ( $_Pic, $GUI_SHOW ) DLLCall ( "user32.dll", "int", "InvalidateRect", "hwnd", $_Gui, "int", 0, "int", 0 ) _WinSetOnTopOneTime ( ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_ChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 ) _WinSetOnTopOneTime ( ) Sleep ( 2000 ) EndIf EndIf $_PicPath = @TempDir & '\TCJ\Pics\' & $_Text2 & '.jpg' If $_PicPath <> $_PicPathOld Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_PicPathOld = $_PicPath $_PicPath='' GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then $_ProcessListArray = ProcessList ( "iexplore.exe" ) For $i = 1 to $_ProcessListArray[0][0] _ReduceMemory ( $_ProcessListArray[$i][1] ) Next EndIf While $_Loop If $_DurationDiff > $_DurationMs Then _IEQuit ( $oIE ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) ExitLoop EndIf Sleep ( 20 ) If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) $_DurationMs = $_Duration * 1000 If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) ) _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec ) If $_Text2 Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then For $_P = 1 To UBound ( $_PidsArray ) -1 _ReduceMemory ( $_PidsArray[$_P] ) Next EndIf If $_DownloadMode = 1 And Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then Sleep ( 2000 ) If Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) EndIf WEnd WEnd Func _DownloadMp3 ( ) GUICtrlSetState ( $_DownloadButton, $GUI_HIDE ) If $_DownloadMode = 1 Then $_DownloadMode=0 $_DownloadButton = GUICtrlCreateButton ( "Download This mp3", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Download this Mp3 Song to your Desktop" ) ProcessClose ( 'TinyYoutubeGrabber.exe' ) _WinClose ( ) Else $_DownloadMode = 1 $_DownloadButton = GUICtrlCreateButton ( "Cancel Download", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Cancel This Download" ) If $_YoutubeSearch <> '' And $_Text2 <> '' Then Run ( @TempDir & "\TCJ\TinyYoutubeGrabber.exe " & $_YoutubeSearch & ' ' & $_Text2 ) EndIf EndIf GUICtrlSetState ( $_DownloadButton, $GUI_SHOW ) GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) EndFunc ;==> _DownloadMp3 ( ) Func _ResetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) If $_StatusBarText = '' Then Return _GetBlacklist ( ) For $_J = 1 To 500 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) If _AlreadyInArray ( $_YoutubeUrlArray, $_RegRead ) Then RegDelete ( $_Key & '\Blacklist', StringFormat ( "%03i", $_J ) ) EndIf Next EndFunc ;==> _ResetBlacklist ( ) Func _GetBlacklist ( ) ReDim $_BlackListArray[1] For $_J = 1 To 500 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) _ArrayAdd ( $_BlackListArray, $_RegRead ) Next EndFunc ;==> _GetBlacklist ( ) Func _AddToBlacklist ( ) _GetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) If $_StatusBarText = '' Then Return If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeSearch ) Then RegWrite ( $_Key & '\Blacklist', StringFormat ( "%03i", UBound ( $_BlackListArray ) ), "REG_SZ", $_YoutubeSearch ) EndFunc ;==> _AddToBlacklist ( ) Func _GUICtrlCreateRadioButtons ( $_Ubound ) For $_G = 1 To $_Ubound $_GenreButton[$_G] = GUICtrlCreateRadio ( $_GenreTitle[$_G], $_X+20, 151+25*$_G, 80, 20 ) If $_G = $_RandomChoice Then GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) GUICtrlSetOnEvent ( $_GenreButton[$_G], "_ChangeGenre" ) Next EndFunc ;==> _GUICtrlCreateRadioButtons ( ) Func _ChangeGenre ( ) For $_G = 1 To 4 If GUICtrlRead ( $_GenreButton[$_G] ) = $GUI_CHECKED Then GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) $_GuiTitle='Tiny Charts ' & $_GenreTitle[$_G] & ' Jukebox ' & $_UpDateDate WinSetTitle ( $_Gui, "", $_GuiTitle ) _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) _IEQuit ( $oIE ) ReDim $_ChartsListArray[1] For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_Genre[$_G], $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_Genre[$_G], $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next $_ChartsListArray[0] = UBound ( $_ChartsListArray ) - 1 _GUICtrlCreateListViewItems ( $_ChartsListArray ) EndIf Next $_Loop =0 EndFunc ;==> _ChangeGenre ( ) Func _GUICtrlCreateListViewItems ( $_ListArray ) GUICtrlDelete ( $_ListView ) $_ListView = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 347, 260 ) _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER ) ReDim $_ListViewItem[UBound ( $_ListArray )] For $_G = 1 To UBound ( $_ListArray ) - 1 $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_ListArray[$_G], $_ListView ) Next GUICtrlSetTip ( $_ListView, "Double click for play a song of the List" ) GUICtrlSetState ( $_ListView, @SW_SHOW ) EndFunc ;==> _GUICtrlCreateListViewItem ( ) Func _WnNotify ( $_Wnd, $_Msg, $_WParam, $_LParam ) $_Tnmtv = DllStructCreate ( $tagNMTVDISPINFO, $_LParam ) $_Code = DllStructGetData ( $_Tnmtv, "Code" ) $_Index = _GUICtrlListView_GetSelectedIndices ( $_ListView ) If $_Code = $NM_DBLCLK And StringLen ( $_Index ) <> 0 Then $_DoubleClick = _GUICtrlListView_GetItemText ( $_ListView, Number ( $_Index ) ) If $_DoubleClick <> $_DoubleClickOld And Not $_RandomMode Then _SelectSong ( ) $_DoubleClickOld = $_DoubleClick EndFunc ;==> _WnNotify ( ) Func _GetPics ( $_PicsArray, $_ListArray ) If Not FileExists ( @TempDir & '\TCJ\Pics' ) Then DirCreate ( @TempDir & '\TCJ\Pics' ) For $_P = 1 To UBound ( $_PicsArray ) -1 $_PicPath = @TempDir & '\TCJ\Pics\' & $_ListArray[$_P] & '.jpg' If Not FileExists ( $_PicPath ) Then InetGet ( $_PicsArray[$_P], $_PicPath, 1, 0 ) If Not FileExists ( $_PicPath ) Then FileCopy ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_PicPath ) EndIf Next EndFunc ;==> _GetPics ( ) Func _SelectSong ( ) _IEQuit ( $oIE ) $_GetItem = _GetItem ( ) If $_GetItem Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_GetItem & ' official' ) $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 $_PicPath = @TempDir & '\TCJ\Pics\' & $_GetItem & '.jpg' If FileExists ( $_PicPath ) Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf $_Text2 = $_GetItem $_Loop =1 EndIf EndFunc ;==> _SelectSong ( ) Func _RandomMode ( ) _IEQuit ( $oIE ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) GUICtrlSetState ( $_RandomButton, $GUI_HIDE ) If $_RandomMode = 1 Then $_RandomMode=0 GUICtrlSetState ( $_NextButton, $GUI_DISABLE ) $_RandomButton = GUICtrlCreateButton ( "Enable Random Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUIRegisterMsg ( $WM_NOTIFY, "_WnNotify" ) Else $_RandomMode = 1 GUICtrlSetState ( $_NextButton, $GUI_ENABLE ) $_RandomButton = GUICtrlCreateButton ( "Enable Manual Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Choose Manualy a song" ) GUIRegisterMsg ( $WM_NOTIFY, "" ) EndIf $_Text2='' GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) EndFunc ;==> _RandomMode ( ) Func _NextSong ( ) _IEQuit ( $oIE ) $_Loop=0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) EndFunc ;==> _NextSong ( ) Func _InvertColorButton ( $_GuiCtrl ) If $_Invert Then GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 ) GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) $_Invert=False Else GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 ) GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 ) $_Invert=True EndIf EndFunc ;==> _InvertColorButton ( ) Func _EachXseconds ( $_Interval ) $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 ) If $_TimerDiff >= $_Interval Then $_InvertTimerInit = TimerInit ( ) Return 1 Else Return 0 EndIf EndFunc ;==> _EachXseconds ( ) Func _GetItem ( ) $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) If $_Select Then $_SelectSplit = StringSplit ( $_Select, '|' ) If Not @error Then $_R=$_SelectSplit[1] $_Select = $_SelectSplit[2] If $_Select Then Return $_Select EndIf EndIf EndFunc ;==> _GetItem ( ) Func _GetUpdateDate ( $_LastChartsUrl ) Local $_UpDateDate $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl ) $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '"date"> -', "<" ) If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )' Return $_UpDateDate EndFunc ;==> _GetUpdateDate ( ) Func _GetLastUkTopChartsListArray ( $_SourceCode, $_SubKey ) Local $_NamesArray[1], $_Add $_LastChartsArray = StringSplit ( $_SourceCode, @CRLF ) Local $_ChartsArray[1] For $_I = 1 To UBound ( $_LastChartsArray ) -1 If StringInStr ( $_LastChartsArray[$_I], '</h4>' ) <> 0 Then $_Title = _StringBetween ( $_LastChartsArray[$_I], '<h4>', '</h4>' ) If Not @error Then $_Artist = StringReplace ( $_LastChartsArray[$_I+2], '<br />', '' ) $_Name = _CleanVideoName ( $_Title[0] & ' - ' & $_Artist ) If Not _AlreadyInArray ( $_NamesArray, $_Name ) Then _ArrayAdd ( $_NamesArray, $_Name ) $_Add = $_Add + 1 RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name ) If $_I+43 < UBound ( $_LastChartsArray ) -1 Then For $_J = $_I-3 To $_I+3 $_ImagesUrl = _StringBetween ( $_LastChartsArray[$_J], 'coverimage" src="', '"' ) If Not @error Then $_ImagesUrl = $_ImagesUrl[0] If StringLeft ( $_ImagesUrl, 4 ) <> 'http' Then $_ImagesUrl = 'http://www.theofficialcharts.com' & $_ImagesUrl If Not _IsValidUrl ( $_ImagesUrl ) Then $_ImagesUrl='' _ArrayAdd ( $_ImagesUrlArray, $_ImagesUrl ) EndIf Next EndIf EndIf EndIf EndIf Next $_NamesArray[0] = UBound ( $_NamesArray ) -1 RegWrite ( $_Key & '\' & $_SubKey, 'UpdateDate', "REG_SZ", $_UpdateDate ) Return $_NamesArray EndFunc ;==> _GetLastUkTopChartsListArray ( ) Func _YoutubeSearch ( $_Query ) Dim $_WordOfQuery[1] $_QuerySplit = StringSplit ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_Query, 'è', 'e' ), 'é', 'e' ), "\W", " " ) , 7 ), ' ' ) For $_I = 1 To UBound ( $_QuerySplit ) - 1 If StringLen ( $_QuerySplit[$_I] ) > 1 Then _ArrayAdd ( $_WordOfQuery, StringReplace ( $_QuerySplit[$_I], ',', ' ' ) ) Next $_WordOfQuery[0] = UBound ( $_WordOfQuery ) - 1 $_Query = StringReplace ( $_Query, " ", "+" ) $_Query = StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace _ ( StringReplace ( StringStripWS ( $_Query, 7 ), ',', '%2C' ), '&', '%26' ), '(', '%28' ), ')', '%29' ), "'", '%27' ), 'è', 'e' ), 'é', 'e' ), '«', ' ' ), '»', ' ' ) $_SourceCode = _GetSourceCode ( "http://www.youtube.com/results?search_query=" & $_Query ) $_SourceCodeSplit = StringSplit ( $_SourceCode, @CRLF ) Dim $_Watch[1], $_DurationArray[1] For $_I = 1 To UBound ( $_SourceCodeSplit )-1 If StringInStr ( $_SourceCodeSplit[$_I], '/watch?v=' ) <> 0 And StringInStr ( $_SourceCodeSplit[$_I], 'video-long-title' ) <> 0 Then _ArrayAdd ( $_Watch, $_SourceCodeSplit[$_I] ) If StringInStr ( $_SourceCodeSplit[$_I-17], 'video-time">' ) <> 0 Then $_VideoTime = _StringBetween ( $_SourceCodeSplit[$_I-17], 'video-time">', '<' ) If Not @error Then $_DurationSplit = StringSplit ( $_VideoTime[0], ':' ) $_DurationSplit[0]=UBound ( $_DurationSplit ) -1 $_Duration = $_DurationSplit[1]*60 + $_DurationSplit[$_DurationSplit[0]] _ArrayAdd ( $_DurationArray, $_Duration ) Else _ArrayAdd ( $_DurationArray, 240 ) EndIf Else _ArrayAdd ( $_DurationArray, 240 ) EndIf EndIf Next _GetBlacklist ( ) Dim $_YoutubeUrlArray[1] For $_I = 1 To UBound ( $_Watch )-1 $Titles = _StringBetween ( $_Watch[$_I], 'title="', '" rel=' ) If Not @error Then If Not _OneOfThisStringInStr ( $Titles[0], 'Karaok|Singing|parod|Fête' ) Then $Link = _StringBetween ( $_Watch[$_I], 'href="', '"' ) If Not @error Then If StringInStr ( $Link[0], 'http://www.youtube.com' ) = 0 Then $_UrlToExtract = "http://www.youtube.com" & $Link[0] Else $_UrlToExtract = $Link[0] EndIf $_Duration = $_DurationArray[$_I] _ArrayAdd ( $_YoutubeUrlArray, $_UrlToExtract ) EndIf EndIf EndIf Next For $_I = 1 To UBound ( $_YoutubeUrlArray )-1 If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeUrlArray[$_I] ) Then $_Duration = $_DurationArray[$_I] Return $_YoutubeUrlArray[$_I] EndIf Next Endfunc ;==> _YoutubeSearch ( ) Func _OneOfThisStringInStr ( $_InStr, $_String ) $_StringArray = StringSplit ( $_String, '|' ) If @error Then Return 0 For $_I = 1 To UBound ( $_StringArray ) -1 $_StringInStr = StringInStr ( $_InStr, $_StringArray[$_I] ) If $_StringInStr <> 0 Then Return 1 Next Return 0 EndFunc ;==> _OneOfThisStringInStr ( ) Func _StringBetweenArrayByStringInstrArray ( $_String, $_StringInStrArray, $_Start, $_End ) Dim $_ArrayAdd[1] For $_I = 1 To UBound ( $_StringInStrArray ) -1 $_StringRight = StringRight ( $_String, StringLen ( $_String ) - $_StringInStrArray[$_I] +1 ) Local $_StringBetween = _StringBetween ( $_StringRight, $_Start, $_End ) If Not @error Then _ArrayAdd ( $_ArrayAdd, $_StringBetween[0] ) Next Return $_ArrayAdd EndFunc ;==> _StringBetweenArrayByStringInstrArray ( ) Func _StringInstrArrayOfLine( $_String, $_StringToFind ) Dim $_ArrayAdd[1] For $_I = 1 To StringLen ( $_String ) $_StringInStr = StringInStr ( $_String, $_StringToFind, 0, $_I ) If $_StringInStr = 0 Then $_ArrayAdd[0] = UBound ( $_ArrayAdd ) -1 Return $_ArrayAdd Else _ArrayAdd ( $_ArrayAdd, $_StringInStr ) EndIf Next EndFunc ;==> _StringInstrArrayOfLine( ) Func _CleanVideoName ( $_Name ) $_Name2 = StringRegExpReplace ( $_Name, '(")|(")|(quot;)|(&)|(amp;)|(<)|(lt;)|(>)|(gt;)|(#39;)', '' ) $_Name2 = StringReplace ( $_Name2, 'ç', 'c' ) $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' ) $_Name2 = StringReplace ( $_Name2, '€', '€' ) $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' ) $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' ) $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' ) $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' ) $_Name2 = StringReplace ( $_Name2, '\', '' ) $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' ) $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' ) Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) ) EndFunc ;==> _CleanVideoName ( ) Func _CleanHtmlName ( $_Name ) $_Name2 = StringReplace ( $_Name, '%2C', ',' ) $_Name2 = StringReplace ( $_Name2, '%82', ',' ) $_Name2 = StringReplace ( $_Name2, '%27', "'" ) $_Name2 = StringReplace ( $_Name2, '&039', "'" ) Return $_Name2 EndFunc ;==> _CleanHtmlName ( ) Func _Randomize ( $_Max=100 ) Do $_Random = Random ( 1, $_Max, 1 ) Until Not _AlreadyInArray ( $_RandomArray, $_Random ) _ArrayAdd ( $_RandomArray, $_Random ) $_RandomArray[0] = UBound ( $_RandomArray ) -1 If $_RandomArray[0] >= $_Max Then ReDim $_RandomArray[1] Return $_Random EndFunc ;==> _Randomize ( ) Func _AlreadyInArray ( $_SearchArray, $_Item ) $_Index = _ArraySearch ( $_SearchArray, $_Item ) If @error Then Return False Else If $_Index <> 0 Then Return True Else Return False EndIf EndIf EndFunc ;==> _AlreadyInArray ( ) Func _GetSourceCode ( $_Url ) $_InetRead = InetRead ( $_Url ) If Not @Error Then $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode ( ) Func _IsArrayEmpty ( $_EmptyArray ) Local $_V = UBound ( $_EmptyArray ) -1, $_P If $_V = 0 Then Return True For $_F = 1 To $_V If $_EmptyArray[$_F] = '' Then $_P = $_P + 1 Next If $_P = $_V Then Return True Else Return False EndIf EndFunc ;==> _IsArrayEmpty ( ) Func _IsConnected ( ) $_SrcFilePath = _TempFile ( @TempDir & "\", '~google_', ".src", 7 ) Local $IsConnected = InetGet ( "http://www.google.com", $_SrcFilePath, 1, 1 ) Local $_Info Do $_Info = InetGetInfo ( $IsConnected ) Sleep ( 50 ) Until $_Info[2] = True InetClose ( $IsConnected ) _Delete ( $_SrcFilePath ) If $_Info[3] <> True Then Return 0 Else Return 1 EndIf EndFunc ;==> _IsConnected ( ) Func _WaitUntilConnected ( ) Do Sleep ( 1000 ) ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny Charts Jukebox', 1, 4 ) Until _IsConnected ( ) ToolTip ( '' ) EndFunc ;==> _WaitUntilConnected ( ) Func _IsValidUrl ( $_IsValidUrl ) $_Size = InetGetSize ( $_IsValidUrl ) If $_Size <> 0 Then Return 1 Endfunc ;==> _IsValidUrl ( ) Func _Delete ( $_FullPath ) $_DeleteInit = TimerInit ( ) While FileExists ( $_FullPath ) If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then DirRemove ( $_FullPath, 1 ) Else FileDelete ( $_FullPath ) EndIf If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0 WEnd Return 1 EndFunc ;==> _Delete ( ) Func _WinSetOnTopOneTime ( ) WinWait ( $_GuiTitle, "", 2 ) WinSetOnTop ( $_GuiTitle, "", 1 ) Sleep ( 250 ) WinSetOnTop ( $_GuiTitle, "", 0 ) WinActivate ( $_GuiTitle, "" ) EndFunc ;==> _WinSetOnTopOneTime ( ) Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 ) If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $iMode Case 1 ReDim $__SLIDE_aGUI[$iUbound + 1][5] $__SLIDE_aGUI[$iUbound][0] = $hWnd $__SLIDE_aGUI[$iUbound][1] = $sSide $__SLIDE_aGUI[$iUbound][2] = True $__SLIDE_aGUI[$iUbound][3] = False $__SLIDE_aGUI[$iUbound][4] = False _Slide_SlideOut ( $hWnd ) GUISetState ( @SW_SHOWNOACTIVATE, $hWnd ) Case 0 For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then For $j = $i To UBound($__SLIDE_aGUI) - 2 $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0] $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1] $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2] $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3] $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4] ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5] _Slide_SlideIn ( $hWnd ) GUISetState ( @SW_HIDE, $hWnd ) Next EndIf Next EndSwitch EndFunc ;==> _Slide_WinSetSlide ( ) Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $sMode Case True For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = True EndIf Next Case False For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = False EndIf Next EndSwitch EndFunc ;==> _Slide_SlideSetOnHover ( ) Func _Slide_SlideOut ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = False Return SetError ( 0, 0, 1 ) Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideOut ( ) Func _Slide_SlideIn ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If Not $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = True Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideIn ( ) Func __Slide_WinSlide ( $hWnd, $sMode, $sSide ) Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) ) Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" ) Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" ) WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _ + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _ + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _ , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _ + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _ + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ) ) $aWPos = WinGetPos ( $hWnd ) Switch $sSide Case "left", "right" Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _ - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP For $i = $aWPos[0] To $TO Step $STEP WinMove ( $hWnd, "", $i, $aWPos[1] ) Sleep ( 10 ) Next Case "top", "bottom" Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _ - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP If $STEP > 0 Then $TO = $TO -25 For $i = $aWPos[1] To $TO + 25 Step $STEP WinMove ( $hWnd, "", $aWPos[0], $i ) Sleep ( 10 ) Next EndSwitch EndFunc ;==> __Slide_WinSlide ( ) Func __Slide_CheckHover ( ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][4] Then If Not $__SLIDE_aGUI[$i][3] Then If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] ) Else If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] ) EndIf EndIf EndIf Next EndFunc ;==> __Slide_CheckHover ( ) Func __Slide_UnloadDLL ( ) DllClose ( $__SLIDE_hDLL ) EndFunc ;==> __Slide_UnloadDLL ( ) Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" ) Local $aResult, $aWPos = WinGetPos ( $hWnd ) If @error Then Return Local $aMPos = MouseGetPos ( ) If @error Then Return Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" ) Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3] Local $iX = $aMPos[0], $iY = $aMPos[1] DllStructSetData ( $tRect, "Left", $iLeft ) DllStructSetData ( $tRect, "Top", $iTop ) DllStructSetData ( $tRect, "Right", $iLeft + $iWidth ) DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight ) $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY ) If @error Then Return SetError ( @error, 0, False ) Return $aResult[0] <> 0 EndFunc ;==> __Slide_WinIsHovered ( ) Func _Init ( ) $_Genre = StringSplit ( 'singles-chart|rock-and-metal-singles-chart|catalogue-singles-chart|dance-singles-chart', '|' ) $_GenreTitle = StringSplit ( 'Singles|Rock|Catalogue|Dance', '|' ) $_RandomChoice = Random ( 1, UBound ( $_Genre ) -1, 1 ) $_GenreRandomChoice = $_Genre[$_RandomChoice] $_UpdateDate = _GetUpdateDate ( 'http://www.theofficialcharts.com/' & $_Genre[$_RandomChoice] & '/' ) $_RegUpdateDate = RegRead ( $_Key & '\' & $_GenreRandomChoice, 'UpdateDate' ) Dim $_LastUkTopChartsListArray[UBound ( $_Genre )], $_GetSourceCode[UBound ( $_Genre )] If $_UpdateDate <> $_RegUpdateDate Or Not FileExists ( @TempDir & '\TCJ\Pics' ) Then ToolTip ( $_Spaces & 'Please Wait while Updating Last Top Charts Lists' & @Crlf & $_Spaces & 'and Downloading their Pics Cover...', @DesktopWidth/2-152, 0, 'Tiny Charts Jukebox', 1, 4 ) For $_K = 1 To UBound ( $_Genre ) -1 Redim $_ImagesUrlArray[1] RegDelete ( $_Key & '\' & $_Genre[$_K] ) $_GetSourceCode[$_K] = _GetSourceCode ( 'http://www.theofficialcharts.com/' & $_Genre[$_K] & '/' ) $_LastUkTopChartsListArray[$_K] = _GetLastUkTopChartsListArray ( $_GetSourceCode[$_K], $_Genre[$_K] ) If _IsArrayEmpty ( $_LastUkTopChartsListArray[$_K] ) Then Exit MsgBox ( 0, 'Error', 'Sorry ' & $_Genre[$_K] & ' List Not Found !', 5 ) _GetPics ( $_ImagesUrlArray, $_LastUkTopChartsListArray[$_K] ) Next ToolTip ( '' ) $_ChartsListArray=$_LastUkTopChartsListArray[$_RandomChoice] Else For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_GenreRandomChoice, $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_GenreRandomChoice, $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next EndIf EndFunc ;==> _Init ( ) Func _GuiSkin ( ) $Dll = DllOpen ( @TempDir & "\TCJ\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TCJ\skin\QQ2008.she", "str", "mhgd" ) DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _GuiSkin ( ) Func _FileInstall ( ) DirCreate ( @TempDir & "\TCJ\skin" ) FileInstall ( "SkinH_EL.dll", @TempDir & "\TCJ\skin\SkinH_EL.dll" ) FileInstall ( "QQ2008.she", @TempDir & "\TCJ\skin\QQ2008.she" ) FileInstall ( "TinyYoutubeGrabber.exe", @TempDir & "\TCJ\TinyYoutubeGrabber.exe", 1 ) EndFunc ;==> _FileInstall ( ) Func _ProcessClose ( $_ProcessName ) While ProcessExists ( $_ProcessName ) ProcessClose ( $_ProcessName ) WEnd EndFunc ;==> _ProcessClose ( ) Func _ReduceMemory ( $_PID ) Local $hPsAPIdll = "psapi.dll", $hKernel32dll = "kernel32.dll" If $_PID <> -1 Then Local $aHandle = DllCall ( $hKernel32dll, "int", "OpenProcess", "int", 0x1f0fff, "int", False, "int", $_PID ) Local $aReturn = DllCall ( $hPsAPIdll, "int", "EmptyWorkingSet", "long", $aHandle[0] ) DllCall ( $hKernel32dll, "int", "CloseHandle", "int", $aHandle[0] ) Endif EndFunc ;==>_ReduceMemory ( ) Func _About ( ) TrayItemSetState ( $_AboutItem, $TRAY_UNCHECKED ) Local $_ProgramName="Tiny Charts Jukebox", $_ProgramVersion='1.0.5' MsgBox ( 64 + 8192, "About", "Informations" & @CRLF & @CRLF & $_ProgramName & ' ' & $_ProgramVersion & @CRLF & @CRLF _ & "Hello! I hope this software will be useful for listening Hit Music Only !" & @CRLF _ & "Choose between Random Mode Or Manual Mode." & @CRLF _ & "In Manual Mode a double click on a song will start the music." & @CRLF _ & "You can select 4 genres of Music Singles, Rock, Catalogue, Dance" & @CRLF _ & "and you can Blacklisted Youtube Url that looks Bad !" & @CRLF _ & "Reset Blacklist song is possible too." & @CRLF _ & "For simplicity, english only and all mp3 arrive in a folder on your desktop, but same names are not overwritten." & @CRLF _ & "This program is free and is not protected by a Copyright." & @CRLF _ & "It can be distributed and copied, and may be modified and distributed under a different name." & @CRLF _ & "This program has been tested successfully on XP Sp3 32 bits." & @CRLF & @CRLF _ & "Thank's to use TinyChartsJukebox !" & @CRLF _ & "Thank's to YouTube, deturl.com, AutoIt Community and ( you've probably noticed ), Google Translate ..." & @CRLF & @CRLF _ & "wakillon." ) EndFunc ;==> _About ( ) Func _OpenDownloadDirectory ( ) TrayItemSetState ( $_OutputItem , $TRAY_UNCHECKED ) If Not FileExists ( @DesktopDir & '\TinyDownloads' ) Then DirCreate ( @DesktopDir & '\TinyDownloads' ) ShellExecute ( @DesktopDir & '\TinyDownloads' ) EndFunc ;==> _OpenDownloadDirectory ( ) Func _OpenYoutube ( ) TrayItemSetState ( $_YoutubeItem , $TRAY_UNCHECKED ) ShellExecute ( 'http://www.youtube.com' ) EndFunc ;==> _OpenYoutube ( ) Func _StartWithWindows ( ) $_ItemGetState = TrayItemGetState ( $_StartItem ) If $_ItemGetState = 64+1 Then RegWrite ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey, "REG_SZ", @ScriptFullPath ) Else RegDelete ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) EndIf EndFunc ;==> _StartWithWindows ( ) Func _WinClose ( ) Local $_WinListArray = WinList ( ) For $_W = 1 to $_WinListArray[0][0] If $_WinListArray[$_W][0] <> "" Then $_StringInStr1 = StringInStr ( $_WinListArray[$_W][0], 'deturl.com - download YouTube videos.' ) $_StringInStr2 = StringInStr ( $_WinListArray[$_W][0], 'Convert audio and video to MP3' ) If $_StringInStr1 + $_StringInStr2 <> 0 Then WinClose ( $_WinListArray[$_W][1] ) EndIf Next EndFunc ;==> _WinClose ( ) Func _Terminate ( ) _IEQuit ( $oIE ) Exit EndFunc ;==> _Terminate ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " TrayTip ( "TinyChartsJukebox", $_Space & "by wakillon...", 1, 1 ) Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( )A second part : TinyYoutubeGrabberexpandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Vinyl orange.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : wakillon Title : TinyYoutubeGrabber Script Fonction : Download youtube song by deturl.com who Grabb, Convert to mp3 and Normalize the Volume. Works well with IE7, but I had some bugs with IE8. ( Error message : 'This tab has been recovered website restore error', so I return to IE7 ) If IE error it restart itself. You can Cancel download by TinyChartsJukebox "Cancel Download" button. Download speed depends of mp3 filesize and number of users of the website used. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <String.au3> #include <File.au3> #include <Math.au3> #include <Misc.au3> #Include <Date.au3> #include <IE.au3> Global $_MessageOld='', $oIE, $_Title, $_YoutubeUrl, $ErrorOutput, $_FileSize, $_PerCent, $_PerCentMax=95, $_DownloadPercent=0, $_OldSize Global $_Message='Opening IE...', $_ProgressBarHeight=130, $_ProgressBarWidth=306, $_StderrRead='', $_AdlibRegisterTimer = 3000 Global $Sec, $Min, $Hour, $Time, $_TimerInit = TimerInit ( ), $_SavePath = @DesktopDir & '\TinyDownloads', $_ProgressBar, $_Gui, $_Label1 Sleep ( 2000 ) If Not _Singleton ( @ScriptName, 1 ) Then Exit ; Init _GetCmdLines ( ) _GetBetterTitle ( $_YoutubeUrl ) _Gui ( ) _IEErrorHandlerRegister ( "_MyErrFunc" ) If StringInStr ( $_YoutubeUrl, '//deturl.com/' ) =0 Then $_YoutubeUrl = StringReplace ( $_YoutubeUrl, '//', '//deturl.com/' ) $_FreeHeight = _GetFreeHeight ( ) OnAutoItExitRegister ( "_OnAutoItExit" ) _GuiSkin ( ) AdlibRegister ( '_Increase', $_AdlibRegisterTimer ) _AudioOnlineConvert ( _Deturl ( ) ) _Downloading ( _OnlineConvert ( ) ) ; Exiting AdlibUnRegister ( '_Increase' ) _TicksToTime ( TimerDiff ( $_TimerInit ), $Hour, $Min, $Sec ) GUICtrlSetData ( $_ProgressBar, 100 ) $_Label3 = GUICtrlCreateLabel ( "Downloaded succesfully in " & StringFormat ( "%02i:%02i", $Min, $Sec ) & ' !', 5, 52, 350, 20 ) Sleep ( 2500 ) GUICtrlDelete ( $_Gui ) Exit Func _Gui ( ) Local $_ProgressBarHeight=70, $_ProgressBarWidth=360, $_FreeHeight = _GetFreeHeight ( ) $_Gui = GUICreate ( "", $_ProgressBarWidth, $_ProgressBarHeight, @DesktopWidth/2 - $_ProgressBarWidth/2, $_FreeHeight - $_ProgressBarHeight - 2, -2138570616 ) _GuiSkin ( ) $_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 ) GUICtrlSetTip ( $_ProgressBar, $_Title & @Crlf & "will arrive on your Desktop download directory" ) GUICtrlSetColor ( $_ProgressBar, 0xFF0000 ) DllCall ( "UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle ( $_ProgressBar ), "wstr", " ", "wstr", " " ) GUICtrlSetStyle ( $_ProgressBar, 1 ) $_Label1 = GUICtrlCreateLabel ( "", 166, 30, 150, 50 ) GUICtrlSetBkColor ( $_Label1, $GUI_BKCOLOR_TRANSPARENT ) GUISetState ( @SW_SHOW ) GUICtrlSetData ( $_ProgressBar, 0 ) $_Label2 = GUICtrlCreateLabel ( "TinyYoutubeGrabber [ Mp3 Youtube Downloader ]", 5, 5, 350, 20 ) EndFunc ;==> _Gui ( ) Func _Increase ( ) $_PerCent = _Max ( _Min ( _Min ( _Max ( 1, $_PerCent ), 99 ) + 1, $_PerCentMax ), $_DownloadPercent ) GUICtrlSetData ( $_ProgressBar, $_PerCent ) If $_PerCent >= 1 Then GUICtrlSetData ( $_Label1, $_PerCent & " %" ) If $_PerCent >= 48 Then GUICtrlSetColor ( $_Label1, 0xFFFFFF ) ; black to white. $_Label3 = GUICtrlCreateLabel ( $_Message, 5, 52, 350, 20 ) EndFunc ;==> _Increase ( ) Func _Deturl ( ) ; Opening deturl.com Local $_TryAttach=0, $_Visible=0 ; 0 = Browser Window is hidden, 1 = Browser Window is visible $oIE = _IECreate ( $_YoutubeUrl, $_TryAttach, $_Visible ) _IELoadWait ( $oIE ) While 1 $_MyString = "mp3" $oLinks = _IELinkGetCollection ( $oIE ) If Not @error Then For $oLink in $oLinks $sLinkText = _IEPropertyGet ( $oLink, "innerText" ) ;ConsoleWrite ( "+>---- 1$sLinkText : " & $sLinkText & @Crlf ) If Not @error Then If $sLinkText = $_MyString Then $_LinkUrl = $oLink.href ;ConsoleWrite ( "!>---- 2$sLinkText : " & $sLinkText & @Crlf ) ;ConsoleWrite ( "!>---- $_LinkUrl : " & $_LinkUrl & @Crlf ) If StringInStr ( $_LinkUrl, 'http://audio.online-convert.com/convert-to-mp3?external_url' ) <> 0 Then Return $_LinkUrl EndIf EndIf Next EndIf Sleep ( 500 ) ;ToolTip ( TimerDiff ( $_TimerInit ), 0, 0 ) If TimerDiff ( $_TimerInit ) > 10000 Then _SelfRestart ( ) WEnd EndFunc ;==> _Deturl ( ) Func _AudioOnlineConvert ( $_LinkUrl ) ; Opening www.audio.online-convert $_Message='Opening www.audio.online-convert.com...' _IENavigate ( $oIE, $_LinkUrl ) _IELoadWait ( $oIE ) Sleep ( 1000 ) $oForm = _IEGetObjById ( $oIE, "forms" ) If Not @error Then $oText = _IEFormElementGetObjByName ( $oForm, "normalize" ) If Not @error Then _IEAction ( $oText, "Click") ; Normalize the audio Sleep ( 1000 ) $oForm = _IEGetObjById ( $oIE, "forms" ) If Not @error Then $oText = _IEFormElementGetObjByName ( $oForm, "submit_button" ) If Not @error Then _IEAction ( $oText, "Click") $_Message='Opening www.online-convert.com...' Sleep ( 2000 ) $_OldSize=0 $_Message='Grabbing file...' EndIf EndIf EndIf EndIf EndFunc ;==> _AudioOnlineConvert ( ) Func _OnlineConvert ( ) ; Opening www.online-convert While 1 $oLinks = _IELinkGetCollection ( $oIE ) If Not @error Then For $oLink in $oLinks $sLinkText = _IEPropertyGet ( $oLink, "innerText" ) If Not @error Then $_LinkUrl = $oLink.href If StringInStr ( $_LinkUrl, ".online-convert.com/download-file/" ) <> 0 Then ; $_LinkUrl : http://www2.online-convert.com/download-file/b8899324a98b7993813f2f808083e19b $_FileSize = InetGetSize ( $_LinkUrl ) If $_OldSize <> $_FileSize Then ConsoleWrite ( "+>---- $_FileSize : " & $_FileSize & @Crlf ) $_OldSize = $_FileSize If $_FileSize > 10 Then _IEErrorHandlerDeregister ( ) _IEQuit ( $oIE ) Return $_LinkUrl EndIf EndIf EndIf Next EndIf Sleep ( 50 ) ;ToolTip ( Round ( TimerDiff ( $_TimerInit ) ), 0, 0 ) ;If TimerDiff ( $_TimerInit ) > 500000 Then _SelfRestart ( ) If _WinExists ( 'audio.online-convert.com' ) Then _SelfRestart ( ) WEnd EndFunc ;==> _OnlineConvert ( ) Func _Downloading ( $_FinalUrl ) $_PerCentMax=99 $_Message='Downloading, Please Wait...' If Not FileExists ( $_SavePath ) Then DirCreate ( $_SavePath ) $_Freepath = _GetFreePath ( $_SavePath & '\' & $_Title & '.mp3' ); ConsoleWrite ( "!>---- $_Freepath : " & $_Freepath & @Crlf ) $_TempPath = @TempDir & '\' & _GetFullNameByFullPath ( $_Freepath ) ; ConsoleWrite ( "!>---- $_TempPath : " & $_TempPath & @Crlf ) $_Download = InetGet ( $_FinalUrl, $_TempPath, 1, 1 ) Local $_InfoData Do $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 ) EndIf Sleep ( 75 ) Until $_InfoData[2] = True FileMove ( $_TempPath, $_Freepath, 1 ) EndFunc ;==> _Downloading ( ) Func _GetFullNameByFullPath ( $_FullPath ) $_FileName = StringSplit ( $_FullPath, '\' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetFullNameByFullPath ( ) Func _GetFreePath ( $_FilePath ) Local $_N Do $_NewPath = _InsertStringBeetweenNameAndExt ( $_FilePath, $_N ) $_N = $_N + 1 Until Not FileExists ( $_NewPath ) Return $_NewPath EndFunc ;==> _GetFreePath ( ) Func _InsertStringBeetweenNameAndExt ( $_FullPath, $_InsertString ) Local $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit ( $_FullPath, $szDrive, $szDir, $szFName, $szExt ) Return $szDrive & $szDir & $szFName & $_InsertString & $szExt EndFunc ;==> _InsertStringBeetweenNameAndExt ( ) Func _GetFreeHeight ( ) Local $_WorkArea, $_Rect = DllStructCreate ( "long left;long top;long right;long bottom" ) Local $_Result = _WinAPI_SystemParametersInfo ( 48, 0, DllStructGetPtr ( $_Rect ), 0 ) If $_Result = True Then $_WorkArea = DllStructGetData ( $_Rect, "bottom" ) - DllStructGetData ( $_Rect, "top" ) If Not @error Then Return $_WorkArea Else Return 0 EndIf EndFunc ;==> _GetFreeHeight ( ) Func _GetCmdLines ( ) If @Compiled Then If $CmdLine[0] = 0 Then Exit $_YoutubeUrl= $CmdLine[1] For $_I = 2 To $CmdLine[0] $_Title = $_Title & ' ' & $CmdLine[$_I] Next $_Title = StringStripWS ( StringRegExpReplace ( $_Title, "\W", ' ' ), 7 ) Else $_Title = 'Lady GaGa Money Honey' $_YoutubeUrl = "http://www.youtube.com/watch?v=2duZoiSUE-w&feature=related" EndIf EndFunc ;==> _GetCmdLines ( ) Func _GetSourceCode ( $_Url ) $_InetRead = InetRead ( $_Url ) If Not @Error Then $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode ( ) Func _GetBetterTitle ( $_Url ) $_SourceCode = _GetSourceCode ( $_Url ) ;ConsoleWrite ( "->---- $_SourceCode : " & $_SourceCode & @Crlf ) $_FindTitle = _StringBetween ( $_SourceCode, '<meta name="title" content="', '">' ) If Not @error Then $_Title = $_FindTitle[0] ConsoleWrite ( "->---- $_Title : " & $_Title & @Crlf ) EndIf If FileExists ( $_SavePath & '\' & $_Title & '.mp3' ) Then $_MsgBox=MsgBox ( 1, 'TinyYoutubeGrabber', $_Title & '.mp3' & @CRLF & 'Already Exists in Download Directory !' & @CRLF & @CRLF & 'Confirm Download ?' ) ConsoleWrite ( "->---- $_MsgBox : " & $_MsgBox & @Crlf ) ; 1=yes, 2=cancel If $_MsgBox <> 1 Then Exit EndIf $_Title = _CleanVideoName ( $_Title ) EndFunc ;==> _GetBetterTitle ( ) Func _CleanVideoName ( $_Name ) $_Name2 = StringRegExpReplace ( $_Name, '(")|(")|(quot;)|(&)|(amp;)|(<)|(lt;)|(>)|(gt;)|(#39;)', '' ) $_Name2 = StringReplace ( $_Name2, 'ç', 'c' ) $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' ) $_Name2 = StringReplace ( $_Name2, '€', '€' ) $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' ) $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' ) $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' ) $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' ) $_Name2 = StringReplace ( $_Name2, '\', '' ) $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' ) $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' ) Return StringStripWS ( $_Name2, 7 ) EndFunc ;==> _CleanVideoName ( ) Func _MyErrFunc ( ) ; Important: the error object variable MUST be named $oIEErrorHandler $ErrorScriptline = $oIEErrorHandler.scriptline $ErrorNumber = $oIEErrorHandler.number $ErrorNumberHex = Hex ( $oIEErrorHandler.number, 8 ) $ErrorDescription = StringStripWS ( $oIEErrorHandler.description, 2 ) $ErrorWinDescription = StringStripWS ( $oIEErrorHandler.WinDescription, 2 ) $ErrorSource = $oIEErrorHandler.Source $ErrorHelpFile = $oIEErrorHandler.HelpFile $ErrorHelpContext = $oIEErrorHandler.HelpContext $ErrorLastDllError = $oIEErrorHandler.LastDllError $ErrorOutput = "" $ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR $ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR $ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR $ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR $ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR $ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR $ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR $ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR $ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR $ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError ;MsgBox ( 0, "COM Error", $ErrorOutput ) ConsoleWrite ( "!>---- COM Error : " & $ErrorOutput & @Crlf ) _IEQuit ( $oIE ) ProgressOff ( ) _SelfRestart ( ) EndFunc ;==> _MyErrFunc ( ) Func _WinExists ( $_String ) ; audio.online-convert.com Local $_WinListArray = WinList ( ) For $_W = 1 To $_WinListArray[0][0] If $_WinListArray[$_W][0] <> "" Then ;ConsoleWrite ( "+>---- Title= : " & $_WinListArray[$_W][0] & @Crlf ) $_StringInStr = StringInStr ( $_WinListArray[$_W][0], $_String ) If $_StringInStr <> 0 Then _IEQuit ( $oIE ) WinClose ( $_WinListArray[$_W][1] ) ConsoleWrite ( "+>---- _WinClose Title : " & $_WinListArray[$_W][0] & @Crlf ) ProgressOff ( ) _SelfRestart ( ) EndIf EndIf Next EndFunc ;==> _WinExists ( ) Func _WinClose ( ) Local $_WinListArray = WinList ( ) For $_W = 1 To $_WinListArray[0][0] If $_WinListArray[$_W][0] <> "" Then ;ConsoleWrite ( "+>---- Title= : " & $_WinListArray[$_W][0] & @Crlf ) $_StringInStr1 = StringInStr ( $_WinListArray[$_W][0], 'deturl.com - download YouTube videos.' ) $_StringInStr2 = StringInStr ( $_WinListArray[$_W][0], 'Convert audio and video to MP3' ) If $_StringInStr1 + $_StringInStr2 <> 0 Then WinClose ( $_WinListArray[$_W][1] ) ConsoleWrite ( "+>---- _WinClose Title : " & $_WinListArray[$_W][0] & @Crlf ) EndIf EndIf Next EndFunc ;==> _WinClose ( ) Func _GuiSkin ( ) $Dll = DllOpen ( @TempDir & "\TCJ\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TCJ\skin\QQ2008.she", "str", "mhgd" ) DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _GuiSkin ( ) Func _SelfRestart ( ) _WinClose ( ) If @Compiled Then Run ( FileGetShortName ( @ScriptFullPath ) & ' ' & $_YoutubeUrl & ' ' & $_Title ) Else Run ( FileGetShortName ( @AutoItExe ) & " " & FileGetShortName ( @ScriptFullPath ) ) EndIf Exit EndFunc ;==> _SelfRestart ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " If $_FileSize > 10 Then TrayTip ( "TinyYoutubeGrabber", $_Space & "by wakillon...", 1, 1 ) Else _SelfRestart ( ) EndIf Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( )TinyYoutubeGrabber must be compiled for TinyChartsJukebox is compiled Discover this new features who improve TinyChartsJukebox ! Edited September 1, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted September 1, 2010 Author Posted September 1, 2010 (edited) A tiny Update cause some buttons not worked correctly and IE hiden windows doesn't close correctly too !Now that's settled ! expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Juke-Box-SZ.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : wakillon Title : TinyChartsJukebox Updated : 01 september 2010 Script Fonction : Listen Last 100 Uk Top Charts singles like a radio in random order and without advertising by getting charts List on charts website and search song's list on youtube. _ WebSite http://www.chartstats.com/chart.php is update weekly _ Work with TinyYoutubeGrabber who download Youtube mp3. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <GUIStatusBar.au3> #Include <GuiListView.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> #include <Misc.au3> #include <Date.au3> #include <IE.au3> If Not _Singleton ( @ScriptName, 1 ) Then Exit Global $Sec, $Min, $Hour, $Time, $_ButtonWidth = 120, $_ButtonHeight=36, $_X=368, $_PicSize=118, $_ListView, $_Spaces=' ' Global $_DurationDiff, $_DurationMs, $_GetItem, $_RandomMode=1, $_RandomChoice, $_GenreTitle, $_Genre, $_DoubleClick, $_DoubleClickOld Global $oIE, $_PicPathOld, $_Dll, $_PID = ProcessExists ( @ScriptName ), $_YoutubeSearch='', $_Text2 Global $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyChartsJukebox" Global $_LastUkTopChartsListArray[1],$_ChartsListArray[1], $_ImagesUrlArray[1], $_RandomArray[1] Global $_DurationArray[1], $_GenreButton[4+1], $_PidsArray[1], $_BlacklistArray[1], $_YoutubeUrlArray[1] Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( ) Global $_StatusBar, $_Loop=0, $_DownloadMode, $_TitleKey = 'TinyChartsJukebox' Global $_StatusParts[1] = [500], $_TempStatus[1] = [""] Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]] Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) Opt ( "GuiOnEventMode", 1 ) Opt ( "TrayOnEventMode", 1 ) Opt ( "TrayMenuMode", 1 ) TraySetIcon ( "Shell32.dll", -129 ) TraySetToolTip ( "Tiny Charts Jukebox" & @Crlf & "- LeftClick to Set Window On Top" & @Crlf & "- RightClick to Traymenu" ) TraySetOnEvent ( $TRAY_EVENT_PRIMARYUP, "_WinSetOnTopOneTime" ) TraySetIcon ( @TempDir & "\TYD\Youtube.ico" ) $_StartItem = TrayCreateItem ( "Start With Windows" ) $_RegRead = RegRead ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) If $_RegRead <> '' Then TrayItemSetState ( $_StartItem, $TRAY_CHECKED ) TrayItemSetOnEvent ( $_StartItem, "_StartWithWindows" ) TrayCreateItem ( "" ) $_AboutItem = TrayCreateItem ( "About" ) TrayItemSetOnEvent ( -1, "_About" ) TrayCreateItem ( "" ) $_YoutubeItem = TrayCreateItem ( "Open Youtube" ) TrayItemSetOnEvent ( -1, "_OpenYoutube" ) TrayCreateItem ( "" ) $_OutputItem = TrayCreateItem ( "Open Download Directory" ) TrayItemSetOnEvent ( -1, "_OpenDownloadDirectory" ) TrayCreateItem ( "" ) $_ExitItem = TrayCreateItem ( "Exit" ) TrayItemSetOnEvent ( -1, "_Terminate" ) TraySetClick ( 16 ) TraySetState ( 4 ) AdlibRegister ( "__Slide_CheckHover", 100 ) OnAutoItExitRegister ( "_OnAutoItExit" ) _FileInstall ( ) _WaitUntilConnected ( ) _Init ( ) _GetBlacklist ( ) Dim $_ListViewItem[UBound ( $_ChartsListArray )] Dim $_GuiTitle='Tiny Charts ' & $_GenreTitle[$_RandomChoice] & ' Jukebox ' & $_UpDateDate $_Gui = GUICreate ( $_GuiTitle, 635, 340, @DesktopWidth-507, @DesktopHeight - 360, -1, BitOR ( $WS_EX_LAYERED, $WS_EX_TOOLWINDOW ) ) _GuiSkin ( ) GUISetBkColor ( 0xFFD900 ) GUISetIcon ( "Shell32.dll", -129 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Terminate" ) _GUICtrlCreateListViewItems ( $_ChartsListArray ) $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_RandomButton = GUICtrlCreateButton ( "Enable Manual Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetState ( $_RandomButton, $GUI_DISABLE ) $_NextButton = GUICtrlCreateButton ( "Next Random Song", 502, 65, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_NextButton, "Listen an other songs of this List" ) GUICtrlSetOnEvent ( $_NextButton, "_NextSong" ) GUICtrlCreateGroup ( 'Select Genre', $_X+4, 149, 118, 130 ) _GUICtrlCreateRadioButtons ( UBound ( $_Genre ) -1 ) $_BlackListButton= GUICtrlCreateButton ( "Add To Blacklist", 502, 110, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_BlackListButton, "Add this Youtube Url To Blacklist, it will be not listened" ) GUICtrlSetOnEvent ( $_BlackListButton, "_AddToBlacklist" ) $_ResetButton = GUICtrlCreateButton ( "Reset BlackList", 502, 154, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ResetButton, "Reset BlackList Only for this Song" ) GUICtrlSetOnEvent ( $_ResetButton, "_ResetBlackList" ) $_DownloadButton = GUICtrlCreateButton ( "Download This mp3", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Download and Normalize this Mp3 Song to your Desktop download directory" ) GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) $_ExitButton = GUICtrlCreateButton ( "Exit", 502, 244, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ExitButton, "Goodbye..." ) GUICtrlSetOnEvent ( $_ExitButton, "_Terminate" ) $_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP ) _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 ) $_Icons = _WinAPI_LoadShell32Icon ( 128 ) _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons ) _Slide_WinSetSlide ( $_Gui, "top" ) _Slide_SlideSetOnHover ( $_Gui ) GUISetState ( @SW_SHOW ) If ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) While 1 If $_RandomMode Then $_R = _Randomize ( UBound ( $_ChartsListArray ) -1 ) $_Text2 = $_ChartsListArray[$_R] _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & ' Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_ChartsListArray[$_R] & ' official' ) If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/watch?v' ) <> 0 Then $_Loop=1 $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 GUICtrlSetState ( $_RandomButton, $GUI_ENABLE ) GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) $_PicPath = @TempDir & '\TCJ\Pics\' & $_ChartsListArray[$_R] & '.jpg' GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) Else $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) EndIf GUICtrlSetState ( $_Pic, $GUI_SHOW ) DLLCall ( "user32.dll", "int", "InvalidateRect", "hwnd", $_Gui, "int", 0, "int", 0 ) _WinSetOnTopOneTime ( ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_ChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 ) _WinSetOnTopOneTime ( ) Sleep ( 2000 ) EndIf EndIf $_PicPath = @TempDir & '\TCJ\Pics\' & $_Text2 & '.jpg' If $_PicPath <> $_PicPathOld Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) If FileExists ( $_PicPath ) Then $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) $_PicPathOld = $_PicPath $_PicPath='' GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then $_ProcessListArray = ProcessList ( "iexplore.exe" ) For $i = 1 to $_ProcessListArray[0][0] _ReduceMemory ( $_ProcessListArray[$i][1] ) Next EndIf While $_Loop If $_DurationDiff > $_DurationMs Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) ExitLoop EndIf Sleep ( 20 ) If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) $_DurationMs = $_Duration * 1000 If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) ) _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec ) If $_Text2 Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 ) _ReduceMemory ( ProcessExists ( @ScriptName ) ) If ProcessExists ( "iexplore.exe" ) Then For $_P = 1 To UBound ( $_PidsArray ) -1 _ReduceMemory ( $_PidsArray[$_P] ) Next EndIf If $_DownloadMode = 1 And Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then Sleep ( 2000 ) If Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) EndIf $_DownloadButtonState = GUICtrlGetState ( $_DownloadButton ) If $_DownloadMode = 0 Then If $_YoutubeSearch = '' Then If $_DownloadButtonState <> 144 Then GUICtrlSetState ( $_DownloadButton, $GUI_DISABLE ) Else If $_DownloadButtonState <> 80 Then GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) EndIf Else If $_DownloadButtonState <> 80 Then GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) EndIf WEnd WEnd Func _DownloadMp3 ( ) GUICtrlSetState ( $_DownloadButton, $GUI_HIDE ) If $_DownloadMode = 1 Then $_DownloadMode=0 $_DownloadButton = GUICtrlCreateButton ( "Download This mp3", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Download this Mp3 Song to your Desktop" ) ProcessClose ( 'TinyYoutubeGrabber.exe' ) _WinClose ( ) Else If $_YoutubeSearch ='' Then Return $_DownloadMode = 1 $_DownloadButton = GUICtrlCreateButton ( "Cancel Download", 502, 200, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Cancel This Download" ) If $_YoutubeSearch <> '' And $_Text2 <> '' Then Run ( @TempDir & "\TCJ\TinyYoutubeGrabber.exe " & $_YoutubeSearch & ' ' & $_Text2 ) EndIf EndIf GUICtrlSetState ( $_DownloadButton, $GUI_SHOW ) GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) EndFunc ;==> _DownloadMp3 ( ) Func _ResetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) If $_StatusBarText = '' Then Return _GetBlacklist ( ) For $_J = 1 To 500 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) If _AlreadyInArray ( $_YoutubeUrlArray, $_RegRead ) Then RegDelete ( $_Key & '\Blacklist', StringFormat ( "%03i", $_J ) ) Next EndFunc ;==> _ResetBlacklist ( ) Func _GetBlacklist ( ) ReDim $_BlackListArray[1] For $_J = 1 To 500 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) _ArrayAdd ( $_BlackListArray, $_RegRead ) Next EndFunc ;==> _GetBlacklist ( ) Func _AddToBlacklist ( ) _GetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) If $_StatusBarText = '' Then Return If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeSearch ) Then RegWrite ( $_Key & '\Blacklist', StringFormat ( "%03i", UBound ( $_BlackListArray ) ), "REG_SZ", $_YoutubeSearch ) EndFunc ;==> _AddToBlacklist ( ) Func _GUICtrlCreateRadioButtons ( $_Ubound ) For $_G = 1 To $_Ubound $_GenreButton[$_G] = GUICtrlCreateRadio ( $_GenreTitle[$_G], $_X+20, 151+25*$_G, 80, 20 ) If $_G = $_RandomChoice Then GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) GUICtrlSetOnEvent ( $_GenreButton[$_G], "_ChangeGenre" ) Next EndFunc ;==> _GUICtrlCreateRadioButtons ( ) Func _ChangeGenre ( ) $_YoutubeSearch = '' For $_G = 1 To 4 If GUICtrlRead ( $_GenreButton[$_G] ) = $GUI_CHECKED Then GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) $_GuiTitle='Tiny Charts ' & $_GenreTitle[$_G] & ' Jukebox ' & $_UpDateDate WinSetTitle ( $_Gui, "", $_GuiTitle ) _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) ReDim $_ChartsListArray[1] For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_Genre[$_G], $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_Genre[$_G], $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next $_ChartsListArray[0] = UBound ( $_ChartsListArray ) - 1 _GUICtrlCreateListViewItems ( $_ChartsListArray ) EndIf Next $_Loop =0 EndFunc ;==> _ChangeGenre ( ) Func _GUICtrlCreateListViewItems ( $_ListArray ) GUICtrlDelete ( $_ListView ) $_ListView = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 347, 260 ) _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER ) ReDim $_ListViewItem[UBound ( $_ListArray )] For $_G = 1 To UBound ( $_ListArray ) - 1 $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_ListArray[$_G], $_ListView ) Next GUICtrlSetTip ( $_ListView, "Double click for play a song of the List" ) GUICtrlSetState ( $_ListView, @SW_SHOW ) EndFunc ;==> _GUICtrlCreateListViewItem ( ) Func _WnNotify ( $_Wnd, $_Msg, $_WParam, $_LParam ) $_Tnmtv = DllStructCreate ( $tagNMTVDISPINFO, $_LParam ) $_Code = DllStructGetData ( $_Tnmtv, "Code" ) $_Index = _GUICtrlListView_GetSelectedIndices ( $_ListView ) If $_Code = $NM_DBLCLK And StringLen ( $_Index ) <> 0 Then $_DoubleClick = _GUICtrlListView_GetItemText ( $_ListView, Number ( $_Index ) ) If $_DoubleClick <> $_DoubleClickOld And Not $_RandomMode Then _SelectSong ( ) $_DoubleClickOld = $_DoubleClick EndFunc ;==> _WnNotify ( ) Func _GetPics ( $_PicsArray, $_ListArray ) If Not FileExists ( @TempDir & '\TCJ\Pics' ) Then DirCreate ( @TempDir & '\TCJ\Pics' ) For $_P = 1 To UBound ( $_PicsArray ) -1 $_PicPath = @TempDir & '\TCJ\Pics\' & $_ListArray[$_P] & '.jpg' If Not FileExists ( $_PicPath ) Then InetGet ( $_PicsArray[$_P], $_PicPath, 1, 0 ) If Not FileExists ( $_PicPath ) Then FileCopy ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_PicPath ) EndIf Next EndFunc ;==> _GetPics ( ) Func _SelectSong ( ) $_YoutubeSearch = '' _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_GetItem = _GetItem ( ) If $_GetItem Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 ) $_YoutubeSearch = _YoutubeSearch ( $_GetItem & ' official' ) $oIE = _IECreate ( $_YoutubeSearch, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 $_PicPath = @TempDir & '\TCJ\Pics\' & $_GetItem & '.jpg' If FileExists ( $_PicPath ) Then GUICtrlSetState ( $_Pic, $GUI_HIDE ) $_Pic = GUICtrlCreatePic ( $_PicPath, $_X+4, 20, $_PicSize, $_PicSize, BitOR ( $SS_Notify, $WS_GROUP, $WS_CLIPSIBLINGS ) ) GUICtrlSetState ( $_Pic, $GUI_SHOW ) EndIf $_Text2 = $_GetItem $_Loop =1 EndIf EndFunc ;==> _SelectSong ( ) Func _RandomMode ( ) $_YoutubeSearch = '' _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) GUICtrlSetState ( $_RandomButton, $GUI_HIDE ) If $_RandomMode = 1 Then $_RandomMode=0 GUICtrlSetState ( $_NextButton, $GUI_DISABLE ) $_RandomButton = GUICtrlCreateButton ( "Enable Random Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUIRegisterMsg ( $WM_NOTIFY, "_WnNotify" ) Else $_RandomMode = 1 GUICtrlSetState ( $_NextButton, $GUI_ENABLE ) $_RandomButton = GUICtrlCreateButton ( "Enable Manual Mode", 502, 20, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_RandomButton, "Choose Manualy a song" ) GUIRegisterMsg ( $WM_NOTIFY, "" ) EndIf $_Text2='' GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 ) GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) EndFunc ;==> _RandomMode ( ) Func _NextSong ( ) $_YoutubeSearch = '' _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop=0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) EndFunc ;==> _NextSong ( ) Func _InvertColorButton ( $_GuiCtrl ) If $_Invert Then GUICtrlSetBkColor ( $_GuiCtrl, 0xFF0000 ) GUICtrlSetColor ( $_GuiCtrl, 0xFFFF00 ) $_Invert=False Else GUICtrlSetBkColor ( $_GuiCtrl, 0xFFFF00 ) GUICtrlSetColor ( $_GuiCtrl, 0xFF0000 ) $_Invert=True EndIf EndFunc ;==> _InvertColorButton ( ) Func _EachXseconds ( $_Interval ) $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 ) If $_TimerDiff >= $_Interval Then $_InvertTimerInit = TimerInit ( ) Return 1 Else Return 0 EndIf EndFunc ;==> _EachXseconds ( ) Func _GetItem ( ) $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) If $_Select Then $_SelectSplit = StringSplit ( $_Select, '|' ) If Not @error Then $_R=$_SelectSplit[1] $_Select = $_SelectSplit[2] If $_Select Then Return $_Select EndIf EndIf EndFunc ;==> _GetItem ( ) Func _GetUpdateDate ( $_LastChartsUrl ) Local $_UpDateDate $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl ) $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '"date"> -', "<" ) If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )' Return $_UpDateDate EndFunc ;==> _GetUpdateDate ( ) Func _GetLastUkTopChartsListArray ( $_SourceCode, $_SubKey ) Local $_NamesArray[1], $_Add $_LastChartsArray = StringSplit ( $_SourceCode, @CRLF ) Local $_ChartsArray[1] For $_I = 1 To UBound ( $_LastChartsArray ) -1 If StringInStr ( $_LastChartsArray[$_I], '</h4>' ) <> 0 Then $_Title = _StringBetween ( $_LastChartsArray[$_I], '<h4>', '</h4>' ) If Not @error Then $_Artist = StringReplace ( $_LastChartsArray[$_I+2], '<br />', '' ) $_Name = _CleanVideoName ( $_Title[0] & ' - ' & $_Artist ) If Not _AlreadyInArray ( $_NamesArray, $_Name ) Then _ArrayAdd ( $_NamesArray, $_Name ) $_Add = $_Add + 1 RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name ) If $_I+43 < UBound ( $_LastChartsArray ) -1 Then For $_J = $_I-3 To $_I+3 $_ImagesUrl = _StringBetween ( $_LastChartsArray[$_J], 'coverimage" src="', '"' ) If Not @error Then $_ImagesUrl = $_ImagesUrl[0] If StringLeft ( $_ImagesUrl, 4 ) <> 'http' Then $_ImagesUrl = 'http://www.theofficialcharts.com' & $_ImagesUrl If Not _IsValidUrl ( $_ImagesUrl ) Then $_ImagesUrl='' _ArrayAdd ( $_ImagesUrlArray, $_ImagesUrl ) EndIf Next EndIf EndIf EndIf EndIf Next $_NamesArray[0] = UBound ( $_NamesArray ) -1 RegWrite ( $_Key & '\' & $_SubKey, 'UpdateDate', "REG_SZ", $_UpdateDate ) Return $_NamesArray EndFunc ;==> _GetLastUkTopChartsListArray ( ) Func _YoutubeSearch ( $_Query ) Dim $_WordOfQuery[1] $_QuerySplit = StringSplit ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_Query, 'è', 'e' ), 'é', 'e' ), "\W", " " ) , 7 ), ' ' ) For $_I = 1 To UBound ( $_QuerySplit ) - 1 If StringLen ( $_QuerySplit[$_I] ) > 1 Then _ArrayAdd ( $_WordOfQuery, StringReplace ( $_QuerySplit[$_I], ',', ' ' ) ) Next $_WordOfQuery[0] = UBound ( $_WordOfQuery ) - 1 $_Query = StringReplace ( $_Query, " ", "+" ) $_Query = StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace ( StringReplace _ ( StringReplace ( StringStripWS ( $_Query, 7 ), ',', '%2C' ), '&', '%26' ), '(', '%28' ), ')', '%29' ), "'", '%27' ), 'è', 'e' ), 'é', 'e' ), '«', ' ' ), '»', ' ' ) $_SourceCode = _GetSourceCode ( "http://www.youtube.com/results?search_query=" & $_Query ) $_SourceCodeSplit = StringSplit ( $_SourceCode, @CRLF ) Dim $_Watch[1], $_DurationArray[1] For $_I = 1 To UBound ( $_SourceCodeSplit )-1 If StringInStr ( $_SourceCodeSplit[$_I], '/watch?v=' ) <> 0 And StringInStr ( $_SourceCodeSplit[$_I], 'video-long-title' ) <> 0 Then _ArrayAdd ( $_Watch, $_SourceCodeSplit[$_I] ) If StringInStr ( $_SourceCodeSplit[$_I-17], 'video-time">' ) <> 0 Then $_VideoTime = _StringBetween ( $_SourceCodeSplit[$_I-17], 'video-time">', '<' ) If Not @error Then $_DurationSplit = StringSplit ( $_VideoTime[0], ':' ) $_DurationSplit[0]=UBound ( $_DurationSplit ) -1 $_Duration = $_DurationSplit[1]*60 + $_DurationSplit[$_DurationSplit[0]] _ArrayAdd ( $_DurationArray, $_Duration ) Else _ArrayAdd ( $_DurationArray, 240 ) EndIf Else _ArrayAdd ( $_DurationArray, 240 ) EndIf EndIf Next _GetBlacklist ( ) Dim $_YoutubeUrlArray[1] For $_I = 1 To UBound ( $_Watch )-1 $Titles = _StringBetween ( $_Watch[$_I], 'title="', '" rel=' ) If Not @error Then If Not _OneOfThisStringInStr ( $Titles[0], 'Karaok|Singing|parod|Fête' ) Then $Link = _StringBetween ( $_Watch[$_I], 'href="', '"' ) If Not @error Then If StringInStr ( $Link[0], 'http://www.youtube.com' ) = 0 Then $_UrlToExtract = "http://www.youtube.com" & $Link[0] Else $_UrlToExtract = $Link[0] EndIf $_Duration = $_DurationArray[$_I] _ArrayAdd ( $_YoutubeUrlArray, $_UrlToExtract ) EndIf EndIf EndIf Next For $_I = 1 To UBound ( $_YoutubeUrlArray )-1 If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeUrlArray[$_I] ) Then $_Duration = $_DurationArray[$_I] Return $_YoutubeUrlArray[$_I] EndIf Next Endfunc ;==> _YoutubeSearch ( ) Func _OneOfThisStringInStr ( $_InStr, $_String ) $_StringArray = StringSplit ( $_String, '|' ) If @error Then Return 0 For $_I = 1 To UBound ( $_StringArray ) -1 $_StringInStr = StringInStr ( $_InStr, $_StringArray[$_I] ) If $_StringInStr <> 0 Then Return 1 Next Return 0 EndFunc ;==> _OneOfThisStringInStr ( ) Func _StringBetweenArrayByStringInstrArray ( $_String, $_StringInStrArray, $_Start, $_End ) Dim $_ArrayAdd[1] For $_I = 1 To UBound ( $_StringInStrArray ) -1 $_StringRight = StringRight ( $_String, StringLen ( $_String ) - $_StringInStrArray[$_I] +1 ) Local $_StringBetween = _StringBetween ( $_StringRight, $_Start, $_End ) If Not @error Then _ArrayAdd ( $_ArrayAdd, $_StringBetween[0] ) Next Return $_ArrayAdd EndFunc ;==> _StringBetweenArrayByStringInstrArray ( ) Func _StringInstrArrayOfLine( $_String, $_StringToFind ) Dim $_ArrayAdd[1] For $_I = 1 To StringLen ( $_String ) $_StringInStr = StringInStr ( $_String, $_StringToFind, 0, $_I ) If $_StringInStr = 0 Then $_ArrayAdd[0] = UBound ( $_ArrayAdd ) -1 Return $_ArrayAdd Else _ArrayAdd ( $_ArrayAdd, $_StringInStr ) EndIf Next EndFunc ;==> _StringInstrArrayOfLine( ) Func _CleanVideoName ( $_Name ) $_Name2 = StringRegExpReplace ( $_Name, '(")|(")|(quot;)|(&)|(amp;)|(<)|(lt;)|(>)|(gt;)|(#39;)', '' ) $_Name2 = StringReplace ( $_Name2, 'ç', 'c' ) $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' ) $_Name2 = StringReplace ( $_Name2, '€', '€' ) $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' ) $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' ) $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' ) $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' ) $_Name2 = StringReplace ( $_Name2, '\', '' ) $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' ) $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' ) Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) ) EndFunc ;==> _CleanVideoName ( ) Func _CleanHtmlName ( $_Name ) $_Name2 = StringReplace ( $_Name, '%2C', ',' ) $_Name2 = StringReplace ( $_Name2, '%82', ',' ) $_Name2 = StringReplace ( $_Name2, '%27', "'" ) $_Name2 = StringReplace ( $_Name2, '&039', "'" ) Return $_Name2 EndFunc ;==> _CleanHtmlName ( ) Func _Randomize ( $_Max=100 ) Do $_Random = Random ( 1, $_Max, 1 ) Until Not _AlreadyInArray ( $_RandomArray, $_Random ) _ArrayAdd ( $_RandomArray, $_Random ) $_RandomArray[0] = UBound ( $_RandomArray ) -1 If $_RandomArray[0] >= $_Max Then ReDim $_RandomArray[1] Return $_Random EndFunc ;==> _Randomize ( ) Func _AlreadyInArray ( $_SearchArray, $_Item ) $_Index = _ArraySearch ( $_SearchArray, $_Item ) If @error Then Return False Else If $_Index <> 0 Then Return True Else Return False EndIf EndIf EndFunc ;==> _AlreadyInArray ( ) Func _GetSourceCode ( $_Url ) $_InetRead = InetRead ( $_Url ) If Not @Error Then $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode ( ) Func _IsArrayEmpty ( $_EmptyArray ) Local $_V = UBound ( $_EmptyArray ) -1, $_P If $_V = 0 Then Return True For $_F = 1 To $_V If $_EmptyArray[$_F] = '' Then $_P = $_P + 1 Next If $_P = $_V Then Return True Else Return False EndIf EndFunc ;==> _IsArrayEmpty ( ) Func _IsConnected ( ) $_SrcFilePath = _TempFile ( @TempDir & "\", '~google_', ".src", 7 ) Local $IsConnected = InetGet ( "http://www.google.com", $_SrcFilePath, 1, 1 ) Local $_Info Do $_Info = InetGetInfo ( $IsConnected ) Sleep ( 50 ) Until $_Info[2] = True InetClose ( $IsConnected ) _Delete ( $_SrcFilePath ) If $_Info[3] <> True Then Return 0 Else Return 1 EndIf EndFunc ;==> _IsConnected ( ) Func _WaitUntilConnected ( ) Do Sleep ( 1000 ) ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny Charts Jukebox', 1, 4 ) Until _IsConnected ( ) ToolTip ( '' ) EndFunc ;==> _WaitUntilConnected ( ) Func _IsValidUrl ( $_IsValidUrl ) $_Size = InetGetSize ( $_IsValidUrl ) If $_Size <> 0 Then Return 1 Endfunc ;==> _IsValidUrl ( ) Func _Delete ( $_FullPath ) $_DeleteInit = TimerInit ( ) While FileExists ( $_FullPath ) If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then DirRemove ( $_FullPath, 1 ) Else FileDelete ( $_FullPath ) EndIf If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0 WEnd Return 1 EndFunc ;==> _Delete ( ) Func _WinSetOnTopOneTime ( ) WinWait ( $_GuiTitle, "", 2 ) WinSetOnTop ( $_GuiTitle, "", 1 ) Sleep ( 250 ) WinSetOnTop ( $_GuiTitle, "", 0 ) WinActivate ( $_GuiTitle, "" ) EndFunc ;==> _WinSetOnTopOneTime ( ) Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 ) If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $iMode Case 1 ReDim $__SLIDE_aGUI[$iUbound + 1][5] $__SLIDE_aGUI[$iUbound][0] = $hWnd $__SLIDE_aGUI[$iUbound][1] = $sSide $__SLIDE_aGUI[$iUbound][2] = True $__SLIDE_aGUI[$iUbound][3] = False $__SLIDE_aGUI[$iUbound][4] = False _Slide_SlideOut ( $hWnd ) GUISetState ( @SW_SHOWNOACTIVATE, $hWnd ) Case 0 For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then For $j = $i To UBound($__SLIDE_aGUI) - 2 $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0] $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1] $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2] $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3] $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4] ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5] _Slide_SlideIn ( $hWnd ) GUISetState ( @SW_HIDE, $hWnd ) Next EndIf Next EndSwitch EndFunc ;==> _Slide_WinSetSlide ( ) Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $sMode Case True For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = True EndIf Next Case False For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = False EndIf Next EndSwitch EndFunc ;==> _Slide_SlideSetOnHover ( ) Func _Slide_SlideOut ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = False Return SetError ( 0, 0, 1 ) Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideOut ( ) Func _Slide_SlideIn ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If Not $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = True Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideIn ( ) Func __Slide_WinSlide ( $hWnd, $sMode, $sSide ) Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) ) Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" ) Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" ) WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _ + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _ + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _ , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _ + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _ + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ) ) $aWPos = WinGetPos ( $hWnd ) Switch $sSide Case "left", "right" Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _ - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP For $i = $aWPos[0] To $TO Step $STEP WinMove ( $hWnd, "", $i, $aWPos[1] ) Sleep ( 10 ) Next Case "top", "bottom" Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _ - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP If $STEP > 0 Then $TO = $TO -25 For $i = $aWPos[1] To $TO + 25 Step $STEP WinMove ( $hWnd, "", $aWPos[0], $i ) Sleep ( 10 ) Next EndSwitch EndFunc ;==> __Slide_WinSlide ( ) Func __Slide_CheckHover ( ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][4] Then If Not $__SLIDE_aGUI[$i][3] Then If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] ) Else If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] ) EndIf EndIf EndIf Next EndFunc ;==> __Slide_CheckHover ( ) Func __Slide_UnloadDLL ( ) DllClose ( $__SLIDE_hDLL ) EndFunc ;==> __Slide_UnloadDLL ( ) Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" ) Local $aResult, $aWPos = WinGetPos ( $hWnd ) If @error Then Return Local $aMPos = MouseGetPos ( ) If @error Then Return Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" ) Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3] Local $iX = $aMPos[0], $iY = $aMPos[1] DllStructSetData ( $tRect, "Left", $iLeft ) DllStructSetData ( $tRect, "Top", $iTop ) DllStructSetData ( $tRect, "Right", $iLeft + $iWidth ) DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight ) $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY ) If @error Then Return SetError ( @error, 0, False ) Return $aResult[0] <> 0 EndFunc ;==> __Slide_WinIsHovered ( ) Func _Init ( ) $_Genre = StringSplit ( 'singles-chart|rock-and-metal-singles-chart|catalogue-singles-chart|dance-singles-chart', '|' ) $_GenreTitle = StringSplit ( 'Singles|Rock|Catalogue|Dance', '|' ) $_RandomChoice = Random ( 1, UBound ( $_Genre ) -1, 1 ) $_GenreRandomChoice = $_Genre[$_RandomChoice] $_UpdateDate = _GetUpdateDate ( 'http://www.theofficialcharts.com/' & $_Genre[$_RandomChoice] & '/' ) $_RegUpdateDate = RegRead ( $_Key & '\' & $_GenreRandomChoice, 'UpdateDate' ) Dim $_LastUkTopChartsListArray[UBound ( $_Genre )], $_GetSourceCode[UBound ( $_Genre )] If $_UpdateDate <> $_RegUpdateDate Or Not FileExists ( @TempDir & '\TCJ\Pics' ) Then ToolTip ( $_Spaces & 'Please Wait while Updating Last Top Charts Lists' & @Crlf & $_Spaces & 'and Downloading their Pics Cover...', @DesktopWidth/2-152, 0, 'Tiny Charts Jukebox', 1, 4 ) For $_K = 1 To UBound ( $_Genre ) -1 Redim $_ImagesUrlArray[1] RegDelete ( $_Key & '\' & $_Genre[$_K] ) $_GetSourceCode[$_K] = _GetSourceCode ( 'http://www.theofficialcharts.com/' & $_Genre[$_K] & '/' ) $_LastUkTopChartsListArray[$_K] = _GetLastUkTopChartsListArray ( $_GetSourceCode[$_K], $_Genre[$_K] ) If _IsArrayEmpty ( $_LastUkTopChartsListArray[$_K] ) Then Exit MsgBox ( 0, 'Error', 'Sorry ' & $_Genre[$_K] & ' List Not Found !', 5 ) _GetPics ( $_ImagesUrlArray, $_LastUkTopChartsListArray[$_K] ) Next ToolTip ( '' ) $_ChartsListArray=$_LastUkTopChartsListArray[$_RandomChoice] Else For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_GenreRandomChoice, $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_GenreRandomChoice, $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next EndIf EndFunc ;==> _Init ( ) Func _GuiSkin ( ) $Dll = DllOpen ( @TempDir & "\TCJ\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TCJ\skin\QQ2008.she", "str", "mhgd" ) DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _GuiSkin ( ) Func _FileInstall ( ) DirCreate ( @TempDir & "\TCJ\skin" ) FileInstall ( "SkinH_EL.dll", @TempDir & "\TCJ\skin\SkinH_EL.dll" ) FileInstall ( "QQ2008.she", @TempDir & "\TCJ\skin\QQ2008.she" ) FileInstall ( "TinyYoutubeGrabber.exe", @TempDir & "\TCJ\TinyYoutubeGrabber.exe", 1 ) EndFunc ;==> _FileInstall ( ) Func _ProcessClose ( $_ProcessName ) While ProcessExists ( $_ProcessName ) ProcessClose ( $_ProcessName ) WEnd EndFunc ;==> _ProcessClose ( ) Func _ReduceMemory ( $_PID ) Local $hPsAPIdll = "psapi.dll", $hKernel32dll = "kernel32.dll" If $_PID <> -1 Then Local $aHandle = DllCall ( $hKernel32dll, "int", "OpenProcess", "int", 0x1f0fff, "int", False, "int", $_PID ) Local $aReturn = DllCall ( $hPsAPIdll, "int", "EmptyWorkingSet", "long", $aHandle[0] ) DllCall ( $hKernel32dll, "int", "CloseHandle", "int", $aHandle[0] ) Endif EndFunc ;==>_ReduceMemory ( ) Func _About ( ) TrayItemSetState ( $_AboutItem, $TRAY_UNCHECKED ) Local $_ProgramName="Tiny Charts Jukebox", $_ProgramVersion='1.0.5' MsgBox ( 64 + 8192, "About", "Informations" & @CRLF & @CRLF & $_ProgramName & ' ' & $_ProgramVersion & @CRLF & @CRLF _ & "Hello! I hope this software will be useful for listening Hit Music Only !" & @CRLF _ & "Choose between Random Mode Or Manual Mode." & @CRLF _ & "In Manual Mode a double click on a song will start the music." & @CRLF _ & "You can select 4 genres of Music Singles, Rock, Catalogue, Dance" & @CRLF _ & "and you can Blacklisted Youtube Url that looks Bad !" & @CRLF _ & "Reset Blacklist song is possible too." & @CRLF _ & "For simplicity, english only and all mp3 arrive in a folder on your desktop, but same names are not overwritten." & @CRLF _ & "This program is free and is not protected by a Copyright." & @CRLF _ & "It can be distributed and copied, and may be modified and distributed under a different name." & @CRLF _ & "This program has been tested successfully on XP Sp3 32 bits." & @CRLF & @CRLF _ & "Thank's to use TinyChartsJukebox !" & @CRLF _ & "Thank's to YouTube, deturl.com, AutoIt Community and ( you've probably noticed ), Google Translate ..." & @CRLF & @CRLF _ & "wakillon." ) EndFunc ;==> _About ( ) Func _OpenDownloadDirectory ( ) TrayItemSetState ( $_OutputItem , $TRAY_UNCHECKED ) If Not FileExists ( @DesktopDir & '\TinyDownloads' ) Then DirCreate ( @DesktopDir & '\TinyDownloads' ) ShellExecute ( @DesktopDir & '\TinyDownloads' ) EndFunc ;==> _OpenDownloadDirectory ( ) Func _OpenYoutube ( ) TrayItemSetState ( $_YoutubeItem , $TRAY_UNCHECKED ) ShellExecute ( 'http://www.youtube.com' ) EndFunc ;==> _OpenYoutube ( ) Func _StartWithWindows ( ) $_ItemGetState = TrayItemGetState ( $_StartItem ) If $_ItemGetState = 64+1 Then RegWrite ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey, "REG_SZ", @ScriptFullPath ) Else RegDelete ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) EndIf EndFunc ;==> _StartWithWindows ( ) Func _CloseWindowWithString ( $_String ) $_WinList = WinList ( ) For $_I = 1 To $_WinList[0][0] If StringInStr ( $_WinList[$_I][0], $_String ) <> 0 And Not BitAnd ( WinGetState ( $_WinList[$_I][1] ), 2 ) Then WinClose ( $_WinList[$_I][1] ) Next EndFunc ;==> _CloseWindowWithString ( ) Func _WinClose ( ) Local $_WinListArray = WinList ( ) For $_W = 1 to $_WinListArray[0][0] If $_WinListArray[$_W][0] <> "" Then $_StringInStr1 = StringInStr ( $_WinListArray[$_W][0], 'deturl.com - download YouTube videos.' ) $_StringInStr2 = StringInStr ( $_WinListArray[$_W][0], 'Convert audio and video to MP3' ) If $_StringInStr1 + $_StringInStr2 <> 0 Then WinClose ( $_WinListArray[$_W][1] ) EndIf EndIf Next EndFunc ;==> _WinClose ( ) Func _Terminate ( ) _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) Exit EndFunc ;==> _Terminate ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " TrayTip ( "TinyChartsJukebox", $_Space & "by wakillon...", 1, 1 ) Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( ) Edited September 9, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted September 9, 2010 Author Posted September 9, 2010 (edited) New update :Now pictures of covers are download on Google Image for best quality ! And new items to tray menu... Edited November 29, 2010 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
pierrotm777 Posted September 11, 2010 Posted September 11, 2010 Always a good job. Thanks for this sharing
pierrotm777 Posted September 11, 2010 Posted September 11, 2010 (edited) This function don't run with your last version. I obtain an error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Func _CreateTextList ( );creation d'une liste simple Dim $_WebRadioArray[$_LastUkTopChartsListArray[0]+1] $_TxtFilePath = @ScriptDir & "\WebRadio.txt" For $_I = 1 To UBound ( $_LastUkTopChartsListArray ) -1 $_WebRadioArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_LastUkTopChartsListArray[$_I] Next _FileWriteFromArray ( $_TxtFilePath, $_WebRadioArray, 1 ) EndFunc;fin ajout creation fichier liste An idea ? Thanks Edited September 11, 2010 by pierrotm777
wakillon Posted September 13, 2010 Author Posted September 13, 2010 Always a good job. Thanks for this sharing Thanks ! I must adapt the download part who works when he want... This function don't run with your last version. I obtain an error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.: An idea ? Thanks It was not the good array ! now it work... _CreateTextList ( ) ; ( to place after _GetBlacklist ( ) ) Func _CreateTextList ( );creation d'une liste simple Dim $_WebRadioArray[UBound ( $_ChartsListArray )] $_TxtFilePath = @ScriptDir & "\WebRadio.txt" For $_I = 1 To UBound ( $_ChartsListArray ) -1 $_WebRadioArray[$_I] = StringFormat ( "%03i", $_I ) & " - " & $_ChartsListArray[$_I] Next _FileWriteFromArray ( $_TxtFilePath, $_WebRadioArray, 1 ) EndFunc;fin ajout creation fichier liste AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted September 14, 2010 Author Posted September 14, 2010 Cool,That run again for me.Thanks Glad to help youHave you tried this ? AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted November 28, 2010 Author Posted November 28, 2010 (edited) A big update :1 ) to correct lot of little display buggs.2 ) to improve the youtube search.3 ) to use quvi, a command line tool for get the download url instead of IE.4 ) to use FLVExtractCL.exe to convert flv to mp3.5 ) to change gui skin.More fast, stable, nice and reliable...First part : TinyChartsJukebox.au3expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Jukebox.ico #AutoIt3Wrapper_outfile=TinyChartsJukebox.exe #AutoIt3Wrapper_Compression = 4 #AutoIt3Wrapper_Res_Fileversion=1.0.3 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=Y #AutoIt3Wrapper_Res_Description = listen or download Charts music like Jukebox. #AutoIt3Wrapper_Res_Comment = Tested on Xp 32bit with IE7,IE8. #AutoIt3Wrapper_Res_Language = 1036 #AutoIt3Wrapper_Res_Icon_Add=Jukebox.ico #AutoIt3Wrapper_Run_Obfuscator = n #AutoIt3Wrapper_Res_LegalCopyright=Copyright ? 2010 wakillon ://////=__= ://////=__= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : wakillon Title : TinyChartsJukebox Script Fonction : Listen Last 100 Uk Top Charts singles like a Jukebox in random order. by getting charts List on charts website and search song's list on youtube. _ WebSite http://www.chartstats.com/chart.php is update weekly _ Work with TinyYoutubeGrabber who download mp3. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <GUIStatusBar.au3> #Include <GuiListView.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> #include <Misc.au3> #include <Date.au3> #include <Math.au3> #include <IE.au3> If Not _Singleton ( @ScriptName, 1 ) Then Exit Global $Sec, $Min, $Hour, $Time, $_ButtonWidth = 120, $_ButtonHeight=34, $_X=368, $_PicSize=118, $_ListView, $_Spaces=' ' Global $_DurationDiff, $_DurationMs, $_GetItem, $_RandomMode=1, $_RandomChoice, $_GenreTitle, $_Genre, $_DoubleClick, $_DoubleClickOld Global $oIE, $_PicPathOld, $_Dll, $_PID = ProcessExists ( @ScriptName ), $_YoutubeQuery='', $_Text2, $_OutputDir, $_Pic, $_Gui, $_DownloadButton, $_NextButton Global $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyChartsJukebox", $_GuiTitle, $_GuiWidth = 635, $_GuiHeight = 340, $_StatusBarHeight=40 Global $_LastUkTopChartsListArray[1],$_ChartsListArray[1], $_RandomArray[1], $_ColorOne=0x2F598D, $_ColorTwo=0xC7E2FF Global $_DurationArray[1], $_GenreButton[4+1], $_BlacklistArray[1], $_YoutubeUrlArray[1], $_ListViewItemMax Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( ) Global $_StatusBar, $_Loop=0, $_DownloadMode, $_TitleKey = 'TinyChartsJukebox', $_RandomButton Global $_AddBLItem, $_NextItem, $_AboutItem, $_OutputItem, $_YoutubeItem, $_StartItem Global $_StatusParts[1] = [500], $_TempStatus[1] = [""] Global $__SLIDE_aGUI[1][5] = [["Winhandle", "sSide", "sState", "locked", "OnHover"]] Global $__SLIDE_hDLL = DllOpen ( "user32.dll" ) Opt ( "GuiOnEventMode", 1 ) Opt ( "GUICloseOnESC", 0 ) Opt ( "TrayOnEventMode", 1 ) Opt ( "TrayMenuMode", 1 ) AdlibRegister ( "__Slide_CheckHover", 100 ) OnAutoItExitRegister ( "_OnAutoItExit" ) _Init ( ) _FileInstall ( ) If Not _IsConnected ( ) Then Exit MsgBox ( 4096, "Exiting on Error", "You are not connected !", 5 ) _GetBlacklist ( ) _TrayMenu ( ) Dim $_ListViewItem[UBound ( $_ChartsListArray )] $_GuiTitle=' Tiny Charts ' & $_GenreTitle[$_RandomChoice] & ' Jukebox ' & $_UpDateDate _GuiCreate ( ) If ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) While 1 If $_RandomMode Then $_R = _Randomize ( UBound ( $_ChartsListArray ) -1 ) $_Text2 = $_ChartsListArray[$_R] ConsoleWrite ( "-->--- $_Text2 : " & $_Text2 & @Crlf ) _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & ' Waiting for Next Song...', 0 ) $_YoutubeQuery = _YoutubeQuery ( $_ChartsListArray[$_R] ) ConsoleWrite ( "+->--- $_YoutubeQuery : " & $_YoutubeQuery & @Crlf ) If StringInStr ( $_YoutubeQuery, 'http://www.youtube.com/watch?v' ) <> 0 Then $_Loop=1 $oIE = _IECreate ( $_YoutubeQuery, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 GUICtrlSetState ( $_RandomButton, $GUI_ENABLE ) GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) $_PicPath = @TempDir & '\TCJ\Pics\' & $_ChartsListArray[$_R] & '.jpg' ConsoleWrite ( "-->--- $_PicPath : " & $_PicPath & @Crlf ) If Not FileExists ( $_PicPath ) Then _GetPics ( $_ChartsListArray[$_R] ) If FileExists ( $_PicPath ) Then GUICtrlSetImage ( $_Pic, $_PicPath ) DLLCall ( "user32.dll", "int", "InvalidateRect", "hwnd", $_Gui, "int", 0, "int", 0 ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_ChartsListArray[$_R] & @Crlf & 'Music Not Found !', 0 ) Sleep ( 2000 ) EndIf EndIf $_PicPath = @TempDir & '\TCJ\Pics\' & $_Text2 & '.jpg' If $_PicPath <> $_PicPathOld Then If FileExists ( $_PicPath ) Then GUICtrlSetImage ( $_Pic, $_PicPath ) $_PicPathOld = $_PicPath $_PicPath='' EndIf If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) If Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then $_DownloadMode = 0 GUICtrlSetData ( $_DownloadButton, "Download This mp3" ) EndIf EndIf While $_Loop If $_DurationDiff > $_DurationMs Then If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) ExitLoop EndIf Sleep ( 20 ) If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton ) $_DurationMs = $_Duration * 1000 If $_Duration Then $_DurationDiff = Round ( TimerDiff ( $_DurationInit ) ) _TicksToTime ( $_DurationMs - $_DurationDiff, $Hour, $Min, $Sec ) If $_Text2 Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_Text2 & ' - ' & StringFormat ( "%02i:%02i", $Min, $Sec ), 0 ) ;_ReduceMemory ( $_PID ) If $_DownloadMode = 1 And Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then Sleep ( 2000 ) If Not ProcessExists ( 'TinyYoutubeGrabber.exe' ) Then _DownloadMp3 ( ) EndIf $_DownloadButtonState = GUICtrlGetState ( $_DownloadButton ) If $_DownloadMode = 0 Then If $_YoutubeQuery = '' Then If $_DownloadButtonState <> 144 Then GUICtrlSetState ( $_DownloadButton, $GUI_DISABLE ) Else If $_DownloadButtonState <> 80 Then GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) EndIf Else If $_DownloadButtonState <> 80 Then GUICtrlSetState ( $_DownloadButton, $GUI_ENABLE ) EndIf WEnd WEnd Func _DownloadMp3 ( ) If $_DownloadMode = 1 Then $_DownloadMode=0 GUICtrlSetData ( $_DownloadButton, "Download This mp3" ) GUICtrlSetTip ( $_DownloadButton, "Download this Mp3 Song to your Desktop" ) ProcessClose ( 'TinyYoutubeGrabber.exe' ) _WinClose ( ) Else If $_YoutubeQuery ='' Then Return $_DownloadMode = 1 GUICtrlSetData ( $_DownloadButton, "Cancel Download" ) GUICtrlSetTip ( $_DownloadButton, "Cancel This Download" ) If $_YoutubeQuery <> '' And $_Text2 <> '' Then Run ( @TempDir & '\TCJ\TinyYoutubeGrabber.exe ' & $_YoutubeQuery & ' ' & $_Text2 ) EndIf EndIf GUICtrlSetState ( $_DownloadButton, $GUI_SHOW ) ;GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) ConsoleWrite ( "-->--- $_DownloadMode : " & $_DownloadMode & @Crlf ) EndFunc ;==> _DownloadMp3 ( ) Func _ResetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) ConsoleWrite ( "+->--- $_StatusBarText : " & $_StatusBarText & @Crlf ) If $_StatusBarText = '' Then Return _GetBlacklist ( ) For $_J = 1 To 1000 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) If _AlreadyInArray ( $_YoutubeUrlArray, $_RegRead ) Then RegDelete ( $_Key & '\Blacklist', StringFormat ( "%03i", $_J ) ) ConsoleWrite ( "!->--- RegDelete " & $_RegRead & @Crlf ) EndIf Next EndFunc ;==> _ResetBlacklist ( ) Func _GetBlacklist ( ) ReDim $_BlackListArray[1] For $_J = 1 To 1000 $_Value = RegEnumVal ( $_Key & '\Blacklist', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_Key & '\Blacklist', $_Value ) _ArrayAdd ( $_BlackListArray, $_RegRead ) Next EndFunc ;==> _GetBlacklist ( ) Func _AddToBlacklist ( ) ConsoleWrite ( "!->--- _AddToBlacklist : " & $_YoutubeQuery & @Crlf ) TrayItemSetState ( $_AddBLItem, $TRAY_UNCHECKED ) _GetBlacklist ( ) $_StatusBarText = _GUICtrlStatusBar_GetText ( $_StatusBar, 0 ) ConsoleWrite ( "+->--- $_StatusBarText : " & $_StatusBarText & @Crlf ) If $_StatusBarText = '' Then Return If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeQuery ) Then RegWrite ( $_Key & '\Blacklist', StringFormat ( "%03i", UBound ( $_BlackListArray ) ), "REG_SZ", $_YoutubeQuery ) EndFunc ;==> _AddToBlacklist ( ) Func _GUICtrlCreateRadioButtons ( $_Ubound ) For $_G = 1 To $_Ubound $_GenreButton[$_G] = GUICtrlCreateRadio ( $_GenreTitle[$_G], $_X+20, 151+25*$_G, 80, 20 ) If $_G = $_RandomChoice Then GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) GUICtrlSetOnEvent ( $_GenreButton[$_G], "_ChangeGenre" ) Next EndFunc ;==> _GUICtrlCreateRadioButtons ( ) Func _ChangeGenre ( ) $_YoutubeQuery = '' For $_G = 1 To 4 If GUICtrlRead ( $_GenreButton[$_G] ) = $GUI_CHECKED Then ConsoleWrite ( '-->--- $_GenreButton[' & $_G & '] is Checked' & @Crlf ) GUICtrlSetState ( $_GenreButton[$_G], $GUI_CHECKED ) $_GuiTitle='Tiny Charts ' & $_GenreTitle[$_G] & ' Jukebox ' & $_UpDateDate WinSetTitle ( $_Gui, "", $_GuiTitle ) _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) ReDim $_ChartsListArray[1] For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_Genre[$_G], $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_Genre[$_G], $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next $_ChartsListArray[0] = UBound ( $_ChartsListArray ) - 1 ConsoleWrite ( '-->--- $_ChartsListArray[0] : ' & $_ChartsListArray[0] & @Crlf ) _GUICtrlCreateListViewItems ( $_ChartsListArray ) EndIf Next $_Loop =0 EndFunc ;==> _ChangeGenre ( ) Func _GUICtrlCreateListViewItems ( $_ListArray ) If $_ListView=0 Then $_ListView = GUICtrlCreateListView ( "Top Nb|Title - Artist", 15, 20, 346, 259, BitOr ( $LVS_SINGLESEL, $LVS_SHOWSELALWAYS ) , BitOr ( $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES ) ) _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER ) For $_G = 1 To UBound ( $_ListArray ) - 1 $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_ListArray[$_G], $_ListView ) Next GUICtrlSetTip ( $_ListView, "In Manual Mode" & @CRLF & "Double click for play a song of the List" ) $_ListViewItemMax = UBound ( $_ListArray )-1 Else GUICtrlSetState ( $_ListView, $GUI_HIDE ) For $_G = 1 To $_ListViewItemMax GUICtrlDelete ( $_ListViewItem[$_G] ) Next ReDim $_ListViewItem[UBound ( $_ListArray )] For $_G = 1 To UBound ( $_ListArray ) - 1 $_ListViewItem[$_G] = GUICtrlCreateListViewItem ( StringFormat ( "%02i", $_G ) & "|" & $_ListArray[$_G], $_ListView ) Next GUICtrlSetState ( $_ListView, $GUI_SHOW ) $_ListViewItemMax = UBound ( $_ListArray )-1 EndIf GUICtrlSetState ( $_ListView, @SW_SHOW ) EndFunc ;==> _GUICtrlCreateListViewItem ( ) Func _WnNotify ( $_Wnd, $_Msg, $_WParam, $_LParam ) $_Tnmtv = DllStructCreate ( $tagNMTVDISPINFO, $_LParam ) $_Code = DllStructGetData ( $_Tnmtv, "Code" ) $_Index = _GUICtrlListView_GetSelectedIndices ( $_ListView ) If $_Code = $NM_DBLCLK And StringLen ( $_Index ) <> 0 Then $_DoubleClick = _GUICtrlListView_GetItemText ( $_ListView, Number ( $_Index ) ) If $_DoubleClick <> $_DoubleClickOld Then ConsoleWrite ( '+->--- $_DoubleClick : ' & $_DoubleClick & ' ' & $_ChartsListArray[$_DoubleClick] & @Crlf ) GUICtrlSetState ( $_ListView, @SW_SHOW ) If Not $_RandomMode Then _SelectSong ( ) EndIf $_DoubleClickOld = $_DoubleClick EndFunc ;==> _WnNotify ( ) Func _SelectSong ( ) $_YoutubeQuery = '' If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_GetItem = _GetItem ( ) ConsoleWrite ( "+->--- $_GetItem : " & $_GetItem & @Crlf ) If $_GetItem Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Song...', 0 ) $_YoutubeQuery = _YoutubeQuery ( $_GetItem ) $oIE = _IECreate ( $_YoutubeQuery, 0, 0, 1 ) $_DurationInit = TimerInit ( ) $_DurationDiff=0 $_PicPath = @TempDir & '\TCJ\Pics\' & $_GetItem & '.jpg' ConsoleWrite ( "-->--- $_PicPath : " & $_PicPath & @Crlf ) If Not FileExists ( $_PicPath ) Then _GetPics ( $_ChartsListArray[$_R] ) If FileExists ( $_PicPath ) Then GUICtrlSetImage ( $_Pic, $_PicPath ) $_Text2 = $_GetItem $_Loop =1 EndIf EndFunc ;==> _SelectSong ( ) Func _RandomMode ( ) $_YoutubeQuery = '' If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop =0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) If $_RandomMode = 1 Then $_RandomMode=0 GUICtrlSetState ( $_NextButton, $GUI_DISABLE ) GUICtrlSetData ( $_RandomButton, "Enable Random Mode" ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUIRegisterMsg ( $WM_NOTIFY, "_WnNotify" ) Else $_RandomMode = 1 GUICtrlSetState ( $_NextButton, $GUI_ENABLE ) GUICtrlSetData ( $_RandomButton, "Enable Manual Mode" ) GUICtrlSetTip ( $_RandomButton, "Choose Manualy a song" ) GUIRegisterMsg ( $WM_NOTIFY, "" ) EndIf $_Text2='' GUICtrlSetBkColor ( $_RandomButton, $_ColorOne ) GUICtrlSetColor ( $_RandomButton, $_ColorTwo ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) EndFunc ;==> _RandomMode ( ) Func _NextSong ( ) $_YoutubeQuery = '' TrayItemSetState ( $_NextItem, $TRAY_UNCHECKED ) If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) $_Loop=0 _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 ) EndFunc ;==> _NextSong ( ) Func _InvertColorButton ( $_GuiCtrl ) If $_Invert Then GUICtrlSetBkColor ( $_GuiCtrl, $_ColorOne ) GUICtrlSetColor ( $_GuiCtrl, $_ColorTwo ) $_Invert=False Else GUICtrlSetBkColor ( $_GuiCtrl, $_ColorTwo ) GUICtrlSetColor ( $_GuiCtrl, $_ColorOne ) $_Invert=True EndIf EndFunc ;==> _InvertColorButton ( ) Func _EachXseconds ( $_Interval ) $_TimerDiff = Round ( TimerDiff ( $_InvertTimerInit )/ 1000 ) If $_TimerDiff >= $_Interval Then $_InvertTimerInit = TimerInit ( ) Return 1 Else Return 0 EndIf EndFunc ;==> _EachXseconds ( ) Func _GetItem ( ) $_Select = GUICtrlRead ( GUICtrlRead ( $_ListView ) ) If $_Select Then $_SelectSplit = StringSplit ( $_Select, '|' ) If Not @error Then $_R=$_SelectSplit[1] $_Select = $_SelectSplit[2] If $_Select Then Return $_Select EndIf EndIf EndFunc ;==> _GetItem ( ) Func _GetUpdateDate ( $_LastChartsUrl ) Local $_UpDateDate $_LastChartPageSourceCode = _GetSourceCode ( $_LastChartsUrl ) $_UpDateDate = _StringBetween ( $_LastChartPageSourceCode, '"date"> -', "<" ) If Not @error Then $_UpDateDate = '( Week of ' & StringStripWS ( $_UpDateDate[0], 7 ) & ' )' Return $_UpDateDate EndFunc ;==> _GetUpdateDate ( ) Func _GetLastUkTopChartsListArray ( $_SourceCode, $_SubKey ) Local $_NamesArray[1], $_Add $_LastChartsArray = StringSplit ( $_SourceCode, @CRLF ) Local $_ChartsArray[1] For $_I = 1 To UBound ( $_LastChartsArray ) -1 If StringInStr ( $_LastChartsArray[$_I], '</h4>' ) <> 0 Then $_Title = _StringBetween ( $_LastChartsArray[$_I], '<h4>', '</h4>' ) If Not @error Then $_Artist = StringStripWS ( StringReplace ( $_LastChartsArray[$_I+2], '<br />', '' ), 1 ) $_Error = 0 If Stringlen ( $_Artist ) < 3 Then $_Artist = _StringBetween ( $_LastChartsArray[$_I+4], 'label">', '</span' ) If Not @error Then $_Artist = StringReplace ( StringReplace ( $_Artist[0], '(', '' ), ')', '' ) Else $_Error = 1 EndIf EndIf If Not $_Error Then $_Name = _CleanVideoName ( $_Title[0] & ' - ' & $_Artist ) If Not _AlreadyInArray ( $_NamesArray, $_Name ) Then _ArrayAdd ( $_NamesArray, $_Name ) $_Add = $_Add + 1 RegWrite ( $_Key & '\' & $_SubKey, StringFormat ( "%03i", $_Add ), "REG_SZ", $_Name ) EndIf EndIf EndIf EndIf Next $_NamesArray[0] = UBound ( $_NamesArray ) -1 RegWrite ( $_Key & '\' & $_SubKey, 'UpdateDate', "REG_SZ", $_UpdateDate ) Return $_NamesArray EndFunc ;==> _GetLastUkTopChartsListArray ( ) Func _YoutubeQuery ( $_QueryString ) $_QueryString = _RemoveBetweenBrackets ( $_QueryString, 2 ) Local $_QueryArray = StringSplit ( $_QueryString, ' ' ), $_FilterString = 'teaser|trailer|karaok|parod|singing|tutorial|cover|makeup|review|spoof|reverse|translation|advert|version|dissection|piano|live|fan|unofficial|by' ; lyric| Local $_FilterArray1 = StringSplit ( $_FilterString, '|' ), $_FilterArray2[1], $_Array2[1] For $_I = 1 To UBound ( $_FilterArray1 ) -1 If _AlreadyInArray ( $_QueryArray, $_FilterArray1[$_I] ) =0 Then _ArrayAdd ( $_FilterArray2, $_FilterArray1[$_I] ) Next $_YoutubeQueryUrl = 'http://www.youtube.com/results?search_query=' & StringReplace ( $_QueryString, ' ', '+' ) & '+official&search_type=&aq=f' $_GetSourceCode = StringStripWS ( _GetSourceCode ( $_YoutubeQueryUrl ), 7 ) $_Array = _StringBetween ( $_GetSourceCode, 'start search results', 'end search results' ) If Not @error Then $_GetSourceCode = $_Array[0] $_Array1 = _StringBetween ( $_GetSourceCode, '/watch', 'video-description' ) If Not @error Then _GetBlacklist ( ) ReDim $_DurationArray[1], $_YoutubeUrlArray[1] $_Limit = 1 If UBound ( $_QueryArray ) -1 > 6 Then $_Limit = 2 For $_I = 0 To UBound ( $_Array1 ) -1 $_NotOk=0 $_Id = _StringBetween ( $_Array1[$_I], '?v=', '"' ) If Not @error Then $_Id=StringLeft ( $_Id[0], 11 ) $_Title = _StringBetween ( $_Array1[$_I], '" title="', '"></span>' ) If Not @error Then If StringInStr ( $_Title[0], '" data' ) <> 0 Then $_Title = _StringBetween ( $_Title[0], '', '" data' ) $_Duration = _StringBetween ( $_Array1[$_I], 'video-time">', "</" ) If Not @error Then $_NotOk=0 Else $_NotOk=1 EndIf $_FilterResult = _OneOfThisStringInStr ( $_Title[0], $_FilterString ) If $_FilterResult Then $_NotOk =1 $_Pertinence = _OneOfThisStringInStr ( $_Title[0], StringReplace ( $_QueryString, ' ', '|' ) ) If $_Pertinence < UBound ( $_QueryArray ) - $_Limit Then $_NotOk =1 If $_NotOk =0 Then $_Title = _CleanVideoName ( $_Title[0] ) $_StringSplit=StringSplit ( $_Duration[0], ':' ) _ArrayAdd ( $_DurationArray, $_StringSplit[1]*60+$_StringSplit[2] ) _ArrayAdd ( $_YoutubeUrlArray, 'http://www.youtube.com/watch?v=' & $_Id ) EndIf EndIf EndIf Next For $_I = 1 To UBound ( $_YoutubeUrlArray )-1 If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeUrlArray[$_I] ) And $_DurationArray[$_I] > 120 Then $_Duration = $_DurationArray[$_I] If $_YoutubeUrlArray[$_I] <> '' Then Return $_YoutubeUrlArray[$_I] EndIf Next $_YoutubeRescueQuery = _YoutubeRescueQuery ( $_QueryString ) If $_YoutubeRescueQuery ='' Then MsgBox ( 0, 'Error', 'Sorry...' & @CRLF & 'Video of "' & $_QueryString & '" was Not Found !', 5 ) Else Return $_YoutubeRescueQuery EndIf EndIf EndFunc ;==> _YoutubeQuery ( ) Func _YoutubeRescueQuery ( $_QueryString ) $_QueryArray = StringSplit ( $_QueryString, ' ' ) $_FilterString = 'teaser|trailer|karaok|parod|singing|tutorial|cover|makeup|review|spoof|reverse|translation|advert|version|dissection|piano|live|fan|unofficial|by' $_FilterArray1 = StringSplit ( $_FilterString, '|' ) Local $_FilterArray2[1], $_Array2[1] ReDim $_DurationArray[1], $_YoutubeUrlArray[1] For $_I = 1 To UBound ( $_FilterArray1 ) -1 If _AlreadyInArray ( $_QueryArray, $_FilterArray1[$_I] ) =0 Then _ArrayAdd ( $_FilterArray2, $_FilterArray1[$_I] ) Next $_YoutubeSearchUrl = 'http://gdata.youtube.com/feeds/api/videos?q=' & StringReplace ( $_QueryString, ' ', '+' ) & '+official&safeSearch=strict&max-results=10&v=2' $_GetSourceCode = _GetSourceCode ( $_YoutubeSearchUrl ) $_Array1 = _StringBetween ( $_GetSourceCode, "<media:group>", "</media:group>" ) If Not @error Then For $_I = 1 To UBound ( $_Array1 ) -1 $_Id = _StringBetween ( $_Array1[$_I], 'watch?v=', '&' ) If Not @error Then $_Title = _StringBetween ( $_Array1[$_I], "<media:title type='plain'>", "</media:title>" ) If Not @error Then $_Duration = _StringBetween ( $_Array1[$_I], "<yt:duration seconds='", "'/>" ) If Not @error Then $_NotOk=0 For $_J = 1 To UBound ( $_FilterArray2 ) -1 If StringInStr ( $_Title[0], $_FilterArray2[$_J] ) <> 0 Then $_NotOk =1 Next If $_NotOk =0 Then $_Title = _CleanVideoName ( $_Title[0] ) _ArrayAdd ( $_DurationArray, $_Duration[0] ) _ArrayAdd ( $_YoutubeUrlArray, 'http://www.youtube.com/watch?v=' & $_Id[0] ) EndIf EndIf EndIf Next EndIf For $_I = 1 To UBound ( $_YoutubeUrlArray )-1 If Not _AlreadyInArray ( $_BlackListArray, $_YoutubeUrlArray[$_I] ) And $_DurationArray[$_I] > 120 Then $_Duration = $_DurationArray[$_I] Return $_YoutubeUrlArray[$_I] EndIf Next EndFunc ;==> _YoutubeRescueQuery ( ) Func _RemoveBetweenBrackets ( $_Stringg, $_Option=1 ) ; 1 [ ], 2 ( ), 3 { }, 4 < >, 5 ‹ ›, 6 « » Local $_BracketsArray[13] = [12, '[' ,']' ,'(' ,')' ,'{', '}', '<', '>', '‹', '›', '«', '»'] Local $_chr1 = $_BracketsArray[$_Option*2-1], $_chr2 = $_BracketsArray[$_Option*2] $_StringBetweenArray = _StringBetween ( $_Stringg, $_chr1, $_chr2 ) If Not @error Then For $_S = 0 To UBound ( $_StringBetweenArray )-1 $_StringInStr1 = StringInStr ( $_Stringg, $_chr1 & $_StringBetweenArray[$_S] & $_chr2 ) -1 $_StringInStr2 = StringLen ( $_StringBetweenArray[$_S] ) + 2 $_Stringg = StringLeft ( $_Stringg, $_StringInStr1 ) & StringRight ( $_Stringg, StringLen ( $_Stringg ) -$_StringInStr1-$_StringInStr2 ) Next Else Return $_Stringg EndIf Return StringStripWS ( $_Stringg, 7 ) EndFunc ;==> _RemoveBetweenBrackets ( ) Func _OneOfThisStringInStr ( $_InStr, $_String ) Local $_StringInStr=0, $_StringArray = StringSplit ( $_String, '|' ) If @error Then Return False For $_I = 1 To UBound ( $_StringArray ) -1 If StringInStr ( $_InStr, $_StringArray[$_I] ) <> 0 Then $_StringInStr = $_StringInStr + 1 Next Return $_StringInStr EndFunc ;==> _OneOfThisStringInStr ( ) Func _CleanVideoName ( $_Name ) $_Name2 = StringRegExpReplace ( $_Name, '(")|(")|(quot;)|(&)|(amp;)|(<)|(lt;)|(>)|(gt;)|(#39;)', '' ) $_Name2 = StringReplace ( $_Name2, 'ç', 'c' ) $_Name2 = StringReplace ( $_Name2, 'ß', 'ss' ) $_Name2 = StringReplace ( $_Name2, '€', '€' ) $_Name2 = StringRegExpReplace ( $_Name2, '(à )|(â)|(ä)|(À)|(ã)|(á)|(Ã¥)', 'a' ) $_Name2 = StringRegExpReplace ( $_Name2, '(Ú)|(ê)|(é)|(è)|(ë)', 'e' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ï)|(î)|(Ã)', 'i' ) $_Name2 = StringRegExpReplace ( $_Name2, '(ÃŽ)|(ö)|(ó)|(ô)', 'o' ) $_Name2 = StringRegExpReplace ( $_Name2, '(û)|(ü)|(ù)|(ÃŒ)|(ú)', 'u' ) $_Name2 = StringReplace ( $_Name2, 'Ã', 'a' ) $_Name2 = StringReplace ( $_Name2, '\', '' ) $_Name2 = StringRegExpReplace ( $_Name2, "[|!?_*~´’'`³¹¼¯,]", ' ' ) $_Name2 = StringRegExpReplace ( $_Name2, '[âªâ™«»¥¶£¢€¡†Ø§³ÙŠšØ¹±ª#®¤©‰¨¹¬·/;:"]', '' ) Return _StringProper ( StringStripWS ( _CleanHtmlName ( $_Name2 ), 7 ) ) EndFunc ;==> _CleanVideoName ( ) Func _CleanHtmlName ( $_Name ) Local $_Charc = '%20, ,%21,!,%22,",%23,#,%24,$,%25,%,%26,&,%28,(,%29,),%2A,*,%2B,+,%2D,-,%2E,.,%2F,/,%30,0,%31,1,' _ & '%32,2,%33,3,%34,4,%35,5,%36,6,%37,7,%38,8,%39,9,%3A,:,%3B,;,%3C,<,%3D,=,%3E,>,%3F,?,%40,@,%41,A,%42,B,%43,C,' _ & '%44,D,%45,E,%46,F,%47,G,%48,H,%49,I,%4A,J,%4B,K,%4C,L,%4D,M,%4E,N,%4F,O,%50,P,%51,Q,%52,R,%53,S,%54,T,%55,U,' _ & '%56,V,%57,W,%58,X,%59,Y,%5A,Z,%5B,[,%5C,\,%5D,],%5E,^,%5F,_,%60,`,%61,a,%62,b,%63,c,%64,d,%65,e,%66,f,%67,g,' _ & '%68,h,%69,i,%6A,j,%6B,k,%6C,l,%6D,m,%6E,n,%6F,o,%70,p,%71,q,%72,r,%73,s,%74,t,%75,u,%76,v,%77,w,%78,x,%79,y,' _ & '%7A,z,%7B,{,%7C,|,%7D,},%7E,~,%7F, ,%80,€,%81, ,%83,ƒ,%84,„,%85,…,%86,†,%87,‡,%88,ˆ,%89,‰,%8A,Š,%8B,‹,%8C,Œ,' _ & '%8D, ,%8E,Ž,%8F, ,%90, ,%91,‘,%92,’,%93,“,%94,”,%95,•,%96,–,%97,—,%98,˜,%99,™,%9A,š,%9B,›,%9C,œ,%9D, ,%9E,ž,' _ & '%9F,Ÿ,%A0, ,%A1,¡,%A2,¢,%A3,£,%A4, ,%A5,¥,%A6,|,%A7,§,%A8,¨,%A9,©,%AA,ª,%AB,«,%AC,¬,%AD,¯,%AE,®,%AF,¯,%B0,°,' _ & '%B1,±,%B2,²,%B3,³,%B4,´,%B5,µ,%B6,¶,%B7,·,%B8,¸,%B9,¹,%BA,º,%BB,»,%BC,¼,%BD,½,%BE,¾,%BF,¿,%C0,À,%C1,Á,%C2,Â,' _ & '%C3,Ã,%C4,Ä,%C5,Å,%C6,Æ,%C7,Ç,%C8,È,%C9,É,%CA,Ê,%CB,Ë,%CC,Ì,%CD,Í,%CE,Î,%CF,Ï,%D0,Ð,%D1,Ñ,%D2,Ò,%D3,Ó,%D4,Ô,' _ & '%D5,Õ,%D6,Ö,%D7, ,%D8,Ø,%D9,Ù,%DA,Ú,%DB,Û,%DC,Ü,%DD,Ý,%DE,Þ,%DF,ß,%E0,à,%E1,á,%E2,â,%E3,ã,%E4,ä,%E5,å,%E6,æ,' _ & '%E7,ç,%E8,è,%E9,é,%EA,ê,%EB,ë,%EC,ì,%ED,í,%EE,î,%EF,ï,%F0,ð,%F1,ñ,%F2,ò,%F3,ó,%F4,ô,%F5,õ,%F6,ö,%F7,÷,%F8,ø,' _ & '%F9,ù,%FA,ú,%FB,û,%FC,ü,%FD,ý,%FE,þ,%FF,ÿ' $_CharcArray = StringSplit ( $_Charc, "," ) ; URL Encoding Reference Replace Characters in HTML for display. %2C = ',' %82 = '‚' %27 = "'" $_Name2 = StringReplace ( $_Name, '%82', ',' ) $_Name2 = StringReplace ( $_Name2, '%27', "'" ) For $_C = 1 To UBound ( $_CharcArray ) -1 Step 2 $_Name2 = StringReplace ( $_Name2, $_CharcArray[$_C], $_CharcArray[$_C+1] ) Next $_Name2 = StringReplace ( $_Name2, '%2C', ',' ) Return $_Name2 EndFunc ;==> _CleanHtmlName ( ) Func _Randomize ( $_Max=100 ) Do $_Random = Random ( 1, $_Max, 1 ) Until Not _AlreadyInArray ( $_RandomArray, $_Random ) _ArrayAdd ( $_RandomArray, $_Random ) $_RandomArray[0] = UBound ( $_RandomArray ) -1 If $_RandomArray[0] >= $_Max Then ReDim $_RandomArray[1] Return $_Random EndFunc ;==> _Randomize ( ) Func _AlreadyInArray ( $_SearchArray, $_Item ) $_Index = _ArraySearch ( $_SearchArray, $_Item, 0, 0, 0, 1 ) ; partial search If @error Then Return False Else If $_Index <> 0 Then Return True Else Return False EndIf EndIf EndFunc ;==> _AlreadyInArray ( ) Func _GetSourceCode ( $_Url ) $_InetRead = InetRead ( $_Url ) If Not @Error Then $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode ( ) Func _IsArrayEmpty ( $_EmptyArray ) Local $_V = UBound ( $_EmptyArray ) -1, $_P If $_V = 0 Then Return True For $_F = 1 To $_V If $_EmptyArray[$_F] = '' Then $_P = $_P + 1 Next If $_P = $_V Then Return True Else Return False EndIf EndFunc ;==> _IsArrayEmpty ( ) Func _IsConnected ( $sPingHost="google.com", $iPingTimeOut=3000 ) Local $iPing_Results = Ping ( $sPingHost, $iPingTimeOut ) If $iPing_Results > 0 Then Return $iPing_Results Local $hWinInetDll = DllOpen ( "wininet.dll" ) If $hWinInetDll = -1 Then Return SetError ( 1, 0, -1 ) Local $aRet = DllCall ( $hWinInetDll, "int", "InternetGetConnectedState", "int", 0, "int", 0 ) DllClose ( $hWinInetDll ) If IsArray ( $aRet ) Then $aRet = $aRet[0] Else $aRet = 0 EndIf If $aRet And $iPing_Results <= 0 Then Return 0 Return $aRet EndFunc ;==> _IsConnected ( ) Func _IsValidUrl ( $_IsValidUrl ) $_Size = InetGetSize ( $_IsValidUrl ) If $_Size <> 0 Then Return 1 Endfunc ;==> _IsValidUrl ( ) Func _Delete ( $_FullPath ) $_DeleteInit = TimerInit ( ) While FileExists ( $_FullPath ) If StringInStr ( FileGetAttrib ( $_FullPath ), "D" ) Then DirRemove ( $_FullPath, 1 ) Else FileDelete ( $_FullPath ) EndIf If TimerDiff ( $_DeleteInit ) > 5000 Then Return 0 WEnd Return 1 EndFunc ;==> _Delete ( ) Func _GetPics ( $_ListItem ) $_OutputDir = @TempDir & '\TCJ\Pics' If Not FileExists ( $_OutputDir ) Then DirCreate ( $_OutputDir ) $_ImagesPath = _GetImagesByGoogleSearch ( $_ListItem ) ConsoleWrite ( "+->--- $_ImagesPath : " & $_ImagesPath & @CRLF ) EndFunc ;==> _GetPics ( ) Func _GetImagesByGoogleSearch ( $_ItemSearch ) ;ConsoleWrite ( "$_ItemSearch : " & $_ItemSearch & @Crlf ) $_OutputName = $_ItemSearch & '.jpg' ;ConsoleWrite ( "$_OutputName : " & $_OutputName & @Crlf ) If Not FileExists ( $_OutputDir & '\' & $_OutputName ) Then $_PicSearchUrl = 'http://www.google.co.nz/images?hl=en&q=' & StringReplace ( StringReplace ( StringReplace ( $_ItemSearch, '-', '' ), ' ', '+' ), '++', '+' ) & '+official+cover' & '&btnG=Search' ConsoleWrite ( "+->--- $_PicSearchUrl : " & $_PicSearchUrl & @Crlf ) $_SourceCode = _GetSourceCode ( $_PicSearchUrl ) ;ConsoleWrite ( "$_SourceCode : " & $_SourceCode & @Crlf ) ;$_StringReplace = StringReplace ( $_SourceCode, 'img src=', 'img src=' ) ;ConsoleWrite ( "@extended : " & @extended & @Crlf ) $_StringInstrArrayOfLine = _StringInstrArrayOfLine ( $_SourceCode, 'img src=' ) ;_ArrayDisplay ( $_StringInstrArrayOfLine ) $_UrlImageArray = _StringBetweenArrayByStringInstrArray ( $_SourceCode, $_StringInstrArrayOfLine, 'img src=', ' ' ) If _IsArrayEmpty ( $_UrlImageArray ) Then ConsoleWrite ( "!->---- No Image : " & @Crlf ) ;ConsoleWrite ( "$_SourceCode : " & $_SourceCode & @Crlf ) ;_ArrayDisplay ( $_StringInstrArrayOfLine ) ;_ArrayDisplay ( $_UrlImageArray ) Sleep ( 10000 ) Return EndIf ;_ArrayDisplay ( $_UrlImageArray ) InetGet ( $_UrlImageArray[1], $_OutputDir & '\' & $_OutputName , 1, 0 ) EndIf Return $_OutputDir & '\' & $_OutputName EndFunc ;==> _GetImagesByGoogleSearch ( ) Func _GetExtByFullPath ( $_FullPath=@ScriptFullPath ) $_FileName = StringSplit ( $_FullPath, '.' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetExtByFullPath ( ) Func _GetFullNameByUrl ( $_FullUrl ) $_FileName = StringSplit ( $_FullUrl, '/' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetFullNameByUrl ( ) Func _StringBetweenArrayByStringInstrArray ( $_String, $_StringInStrArray, $_Start, $_End ) Dim $_ArrayAdd[1] For $_I = 1 To UBound ( $_StringInStrArray ) -1 $_StringRight = StringRight ( $_String, StringLen ( $_String ) - $_StringInStrArray[$_I] +1 ) Local $_StringBetween = _StringBetween ( $_StringRight, $_Start, $_End ) If Not @error Then _ArrayAdd ( $_ArrayAdd, $_StringBetween[0] ) Next Return $_ArrayAdd EndFunc ;==> _StringBetweenArrayByStringInstrArray ( ) Func _StringInstrArrayOfLine( $_String, $_StringToFind ) Dim $_ArrayAdd[1] For $_I = 1 To StringLen ( $_String ) $_StringInStr = StringInStr ( $_String, $_StringToFind, 0, $_I ) If $_StringInStr = 0 Then $_ArrayAdd[0] = UBound ( $_ArrayAdd ) -1 Return $_ArrayAdd Else _ArrayAdd ( $_ArrayAdd, $_StringInStr ) EndIf Next EndFunc ;==> _StringInstrArrayOfLine( ) Func _WinSetOnTopOneTime ( ) WinWait ( $_GuiTitle, "", 2 ) WinSetOnTop ( $_GuiTitle, "", 1 ) Sleep ( 250 ) WinSetOnTop ( $_GuiTitle, "", 0 ) WinActivate ( $_GuiTitle, "" ) EndFunc ;==> _WinSetOnTopOneTime ( ) Func _Slide_WinSetSlide ( $hWnd, $sSide, $iMode = 1 ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) If $iMode > 1 Or $iMode < 0 Then Return SetError ( 1, 0, 0 ) If Not StringRegExp ( $sSide, "(?i)(left|right|top|bottom)" ) Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $iMode Case 1 ReDim $__SLIDE_aGUI[$iUbound + 1][5] $__SLIDE_aGUI[$iUbound][0] = $hWnd $__SLIDE_aGUI[$iUbound][1] = $sSide $__SLIDE_aGUI[$iUbound][2] = True $__SLIDE_aGUI[$iUbound][3] = False $__SLIDE_aGUI[$iUbound][4] = False _Slide_SlideOut ( $hWnd ) GUISetState ( @SW_SHOWNOACTIVATE, $hWnd ) Case 0 For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then For $j = $i To UBound($__SLIDE_aGUI) - 2 $__SLIDE_aGUI[$j][0] = $__SLIDE_aGUI[$j + 1][0] $__SLIDE_aGUI[$j][1] = $__SLIDE_aGUI[$j + 1][1] $__SLIDE_aGUI[$j][2] = $__SLIDE_aGUI[$j + 1][2] $__SLIDE_aGUI[$j][3] = $__SLIDE_aGUI[$j + 1][3] $__SLIDE_aGUI[$j][4] = $__SLIDE_aGUI[$j + 1][4] ReDim $__SLIDE_aGUI[UBound ( $__SLIDE_aGUI ) - 1][5] _Slide_SlideIn ( $hWnd ) GUISetState ( @SW_HIDE, $hWnd ) Next EndIf Next EndSwitch EndFunc ;==> _Slide_WinSetSlide ( ) Func _Slide_SlideSetOnHover ( $hWnd, $sMode = True ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) $iUbound = UBound ( $__SLIDE_aGUI ) Switch $sMode Case True For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = True EndIf Next Case False For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then $__SLIDE_aGUI[$i][4] = False EndIf Next EndSwitch EndFunc ;==> _Slide_SlideSetOnHover ( ) Func _Slide_SlideOut ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "out", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = False Return SetError ( 0, 0, 1 ) Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideOut ( ) Func _Slide_SlideIn ( $hWnd ) If Not IsHWnd ( $hWnd ) Then $hWnd = WinGetHandle ( $hWnd ) If @error Then Return SetError ( 1, 0, 0 ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][0] = $hWnd Then If Not $__SLIDE_aGUI[$i][2] Then __Slide_WinSlide ( $hWnd, "in", $__SLIDE_aGUI[$i][1] ) $__SLIDE_aGUI[$i][2] = True Else Return SetError ( 3, 0, 0 ) EndIf EndIf Next Return SetError ( 2, 0, 0 ) EndFunc ;==> _Slide_SlideIn ( ) Func __Slide_WinSlide ( $hWnd, $sMode, $sSide ) Local $aScreen_Res = WinGetPos ( WinGetHandle ( "Program Manager" ) ) Local $aWPos = WinGetPos ( $hWnd ), $m = 0 - ( $sMode = "in" ) + ( $sMode = "out" ) Local $h = 0 - ( $sSide = "left" ) + ( $sSide = "right" ), $v = 0 - ( $sSide = "top" ) + ( $sSide = "bottom" ) WinMove ( $hWnd, "", $aScreen_Res[0] - ( ( $h = -1 ) * ( $m = -1 ) * ( $aWPos[2] - 10 ) ) _ + ( ( $h = 1 ) * ( ( $h = 1 ) * $aScreen_Res[2] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[2] ) ) _ + ( ( $h = 0 ) * ( ( $h = 0 ) * ( $aScreen_Res[2] / 2 ) - ( $aWPos[2] / 2 ) ) ) _ , $aScreen_Res[1] - ( ( $v = -1 ) * ( $m = -1 ) * ( $aWPos[3] - 10 ) ) _ + ( ( $v = 1 ) * ( ( $v = 1 ) * $aScreen_Res[3] - ( 10 * ( $m = -1 ) ) - ( $m <> -1 ) * $aWPos[3] ) ) _ + ( ( $v = 0 ) * ( ( $v = 0 ) * ( $aScreen_Res[3] / 2 ) - ($aWPos[3] / 2 ) ) ), $_GuiWidth, $_GuiHeight+$_StatusBarHeight ) $aWPos = WinGetPos ( $hWnd ) Switch $sSide Case "left", "right" Local $STEP = ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) - ( ( ( $h = -1 ) And ( $m = 1 ) ) Or ( ( $h = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[0], $TO = $aWPos[0] + ( ( ( ( $h = 1 ) And ( $m = 1 ) ) Or ( ( $h = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[2] ) ) _ - ( ( ( ( $h = 1 ) And ( $m = -1 ) ) Or ( ( $h = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[2] ) ) - $STEP For $i = $aWPos[0] To $TO Step $STEP WinMove ( $hWnd, "", $i, $aWPos[1], $_GuiWidth, $_GuiHeight+$_StatusBarHeight ) Sleep ( 10 ) Next Case "top", "bottom" Local $STEP = ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) - ( ( ( $v = -1 ) And ( $m = 1 ) ) Or ( ( $v = 1 ) And ( $m = -1 ) ) ) ) * 10 Local $FROM = $aWPos[1], $TO = $aWPos[1] + ( ( ( ( $v = 1 ) And ( $m = 1 ) ) Or ( ( $v = -1 ) And ( $m = -1 ) ) ) * ( $aWPos[3] ) ) _ - ( ( ( ( $v = 1 ) And ( $m = -1 ) ) Or ( ( $v = -1 ) And ( $m = 1 ) ) ) * ( $aWPos[3] ) ) - $STEP If $STEP > 0 Then $TO = $TO -35 For $i = $aWPos[1] To $TO + 35 Step $STEP ; WinMove ( $hWnd, "", $aWPos[0], $i, $_GuiWidth, $_GuiHeight+$_StatusBarHeight ) Sleep ( 10 ) Next EndSwitch EndFunc ;==> __Slide_WinSlide ( ) Func __Slide_CheckHover ( ) For $i = 1 To UBound ( $__SLIDE_aGUI ) - 1 If $__SLIDE_aGUI[$i][4] Then If Not $__SLIDE_aGUI[$i][3] Then If __Slide_WinIsHovered ( $__SLIDE_aGUI[$i][0] ) Then If Not $__SLIDE_aGUI[$i][2] Then _Slide_SlideIn ( $__SLIDE_aGUI[$i][0] ) Else If $__SLIDE_aGUI[$i][2] Then _Slide_SlideOut ( $__SLIDE_aGUI[$i][0] ) EndIf EndIf EndIf Next EndFunc ;==> __Slide_CheckHover ( ) Func __Slide_UnloadDLL ( ) DllClose ( $__SLIDE_hDLL ) EndFunc ;==> __Slide_UnloadDLL ( ) Func __Slide_WinIsHovered ( $hWnd, $vDLL = "User32.dll" ) Local $aResult, $aWPos = WinGetPos ( $hWnd ) If @error Then Return Local $aMPos = MouseGetPos ( ) If @error Then Return Local $tRect = DllStructCreate ( "int Left;int Top;int Right;int Bottom" ) Local $iLeft = $aWPos[0], $iTop = $aWPos[1], $iWidth = $aWPos[2], $iHeight = $aWPos[3] Local $iX = $aMPos[0], $iY = $aMPos[1] DllStructSetData ( $tRect, "Left", $iLeft ) DllStructSetData ( $tRect, "Top", $iTop ) DllStructSetData ( $tRect, "Right", $iLeft + $iWidth ) DllStructSetData ( $tRect, "Bottom", $iTop + $iHeight ) $aResult = DllCall ( $vDLL, "int", "PtInRect", "ptr", DllStructGetPtr ( $tRect ), "int", $iX, "int", $iY ) If @error Then Return SetError ( @error, 0, False ) Return $aResult[0] <> 0 EndFunc ;==> __Slide_WinIsHovered ( ) Func _Init ( ) $_Genre = StringSplit ( 'singles-chart|rock-and-metal-singles-chart|catalogue-singles-chart|dance-singles-chart', '|' ) $_GenreTitle = StringSplit ( 'Singles|Rock|Catalogue|Dance', '|' ) $_RandomChoice = Random ( 1, UBound ( $_Genre ) -1, 1 ) $_GenreRandomChoice = $_Genre[$_RandomChoice] $_UpdateDate = _GetUpdateDate ( 'http://www.theofficialcharts.com/' & $_Genre[$_RandomChoice] & '/' ) $_RegUpdateDate = RegRead ( $_Key & '\' & $_GenreRandomChoice, 'UpdateDate' ) Dim $_LastUkTopChartsListArray[UBound ( $_Genre )], $_GetSourceCode[UBound ( $_Genre )] If $_UpdateDate <> $_RegUpdateDate Or Not FileExists ( @TempDir & '\TCJ\Pics' ) Then ToolTip ( $_Spaces & 'Please Wait while Updating Last Top Charts Lists' & @Crlf, @DesktopWidth/2-152, 0, 'Tiny Charts Jukebox', 1, 4 ) For $_K = 1 To UBound ( $_Genre ) -1 RegDelete ( $_Key & '\' & $_Genre[$_K] ) $_GetSourceCode[$_K] = _GetSourceCode ( 'http://www.theofficialcharts.com/' & $_Genre[$_K] & '/' ) $_LastUkTopChartsListArray = _GetLastUkTopChartsListArray ( $_GetSourceCode[$_K], $_Genre[$_K] ) If _IsArrayEmpty ( $_LastUkTopChartsListArray ) Then Exit MsgBox ( 0, 'Error', 'Sorry ' & $_Genre[$_K] & ' List Not Found !', 5 ) If $_K = $_RandomChoice Then $_ChartsListArray=$_LastUkTopChartsListArray Next Else For $_J = 1 To 100 $_Value = RegEnumVal ( $_Key & '\' & $_GenreRandomChoice, $_J ) If @error <> 0 Then ExitLoop If StringInStr ( $_Value, 'UpdateDate' ) = 0 Then $_RegRead = RegRead ( $_Key & '\' & $_GenreRandomChoice, $_Value ) _ArrayAdd ( $_ChartsListArray, $_RegRead ) EndIf Next EndIf EndFunc ;==> _Init ( ) Func _GuiSkin ( ) $Dll = DllOpen ( @TempDir & "\TCJ\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TCJ\skin\X3_QQ.she", "str", "mhgd" ) ; ouframe.she, X3_QQ.she, whitefire.she, skinh.she, QQ2009.she, pixos.she, longhorn.she, enjoy.she, dogmax.she, darkroyale.she, black.she DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _GuiSkin ( ) Func _FileInstall ( ) If Not FileExists ( @TempDir & "\TCJ\skin" ) Then DirCreate ( @TempDir & "\TCJ\skin" ) DirCreate ( @TempDir & "\TCJ\lua\util" ) DirCreate ( @TempDir & "\TCJ\lua\website" ) EndIf If Not FileExists ( @TempDir & '\TCJ\skin\QQ2008.she' ) Then InetGet ( 'http://uploadedfiles.free.fr/TinyChartsJukebox/QQ2008.sh_', @TempDir & '\TCJ\skin\QQ2008.she', 1, 0 ) If Not FileExists ( @TempDir & '\TCJ\skin\X3_QQ.she' ) Then InetGet ( 'http://uploadedfiles.free.fr/TinyChartsJukebox/X3_QQ.sh_', @TempDir & '\TCJ\skin\X3_QQ.she', 1, 0 ) $_DownLoadString = 'TCJ\skin,SkinH_EL.dll,TCJ,TinyYoutubeGrabber.exe,TCJ,FLVExtractCL.exe,TCJ,quvi.exe,TCJ,libcurl-4.dll,TCJ,libiconv-2.dll,TCJ,libpcre-0.dll,TCJ,libquvi-0.dll,TCJ,lua51.dll' & _ ',TCJ\lua\util,charset.lua,TCJ\lua\util,content_type.lua,TCJ\lua\util,trim.lua,TCJ\lua\website,youtube.lua' $_DownLoadArray = StringSplit ( $_DownLoadString, ',' ) For $_I = 1 To UBound ( $_DownLoadArray ) -1 Step 2 $_Path = @TempDir & '\' & $_DownLoadArray[$_I] & '\' & $_DownLoadArray[$_I+1] If Not FileExists ( $_Path ) Then Do $_InetGet = InetGet ( 'http://uploadedfiles.free.fr/TinyChartsJukebox/' & $_DownLoadArray[$_I+1], $_Path, 1, 1 ) $_Result = _WaitWhileDownload ( $_InetGet ) If Not _IsConnected ( ) Then Exit MsgBox ( 4096, "Exiting on Error", "You are not connected !", 5 ) If Not $_Result Then Sleep ( 10000 ) Until $_Result = 1 EndIf Next ToolTip ( '' ) EndFunc ;==> _FileInstall ( ) Func _WaitWhileDownload ( $_Download ) $_Begin = TimerInit ( ) Do Sleep ( 500 ) InetGetInfo ( $_Download ) If @Error Then Return 0 If TimerDiff ( $_Begin ) > 30000 Then Return 0 Until InetGetInfo ( $_Download, 2 ) Return 1 EndFunc ;==> _WaitWhileDownload ( ) Func _ReduceMemory ( $_PID ) Local $hPsAPIdll = "psapi.dll", $hKernel32dll = "kernel32.dll" If $_PID <> -1 Then Local $aHandle = DllCall ( $hKernel32dll, "int", "OpenProcess", "int", 0x1f0fff, "int", False, "int", $_PID ) Local $aReturn = DllCall ( $hPsAPIdll, "int", "EmptyWorkingSet", "long", $aHandle[0] ) DllCall ( $hKernel32dll, "int", "CloseHandle", "int", $aHandle[0] ) Endif EndFunc ;==> _ReduceMemory ( ) Func _GuiCreate ( ) $_Gui = GUICreate ( $_GuiTitle, $_GuiWidth, $_GuiHeight, @DesktopWidth-507, @DesktopHeight - 360, -1, -1, WinGetHandle ( AutoItWinGetTitle ( ) ) ) _GuiSkin ( ) GUISetIcon ( "Shell32.dll", -129 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Terminate" ) _GUICtrlCreateListViewItems ( $_ChartsListArray ) $_Pic = GUICtrlCreatePic ( @ProgramFilesDir & "\AutoIt3\Examples\GUI\merlin.gif", $_X+4, 20, $_PicSize, $_PicSize, $SS_BITMAP ) $_RandomButton = GUICtrlCreateButton ( "Enable Manual Mode", 501, 20, $_ButtonWidth+2, $_ButtonHeight+2 ) GUICtrlSetTip ( $_RandomButton, "Listen Randomly this songs List" ) GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) GUICtrlSetBkColor ( $_RandomButton, $_ColorOne ) GUICtrlSetColor ( $_RandomButton, $_ColorTwo ) GUICtrlSetState ( $_RandomButton, $GUI_DISABLE ) $_NextButton = GUICtrlCreateButton ( "Next Random Song", 502, 65, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_NextButton, "Listen an other songs of this List" ) GUICtrlSetOnEvent ( $_NextButton, "_NextSong" ) GUICtrlCreateGroup ( 'Select Genre', $_X+4, 149, 118, 130 ) _GUICtrlCreateRadioButtons ( UBound ( $_Genre ) -1 ) $_BlackListButton= GUICtrlCreateButton ( "Add To Blacklist", 502, 110, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_BlackListButton, "Add this Youtube Url To Blacklist, it will be not listened" ) GUICtrlSetOnEvent ( $_BlackListButton, "_AddToBlacklist" ) $_ResetButton = GUICtrlCreateButton ( "Reset BlackList", 502, 154, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ResetButton, "Reset BlackList Only for this Song" ) GUICtrlSetOnEvent ( $_ResetButton, "_ResetBlackList" ) $_DownloadButton = GUICtrlCreateButton ( "Download This mp3", 502, 197, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_DownloadButton, "Download and Normalize this Mp3 Song to your Desktop download directory" ) GUICtrlSetOnEvent ( $_DownloadButton, "_DownloadMp3" ) $_ExitButton = GUICtrlCreateButton ( "Exit", 502, 242, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_ExitButton, "Goodbye..." ) GUICtrlSetOnEvent ( $_ExitButton, "_Terminate" ) $_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP ) _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, $_StatusBarHeight ) $_Icons = _WinAPI_LoadShell32Icon ( 128 ) _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons ) _Slide_WinSetSlide ( $_Gui, "top" ) _Slide_SlideSetOnHover ( $_Gui ) GUISetState ( @SW_SHOW ) EndFunc ;==> _GuiCreate ( ) Func _TrayMenu ( ) TraySetIcon ( "Shell32.dll", -129 ) TraySetToolTip ( "Tiny Charts Jukebox" & @Crlf & "- LeftClick to Set Window On Top" & @Crlf & "- RightClick to Traymenu" ) TraySetOnEvent ( $TRAY_EVENT_PRIMARYUP, "_WinSetOnTopOneTime" ) TraySetIcon ( @TempDir & "\TYD\Youtube.ico" ) $_StartItem = TrayCreateItem ( "Start With Windows" ) $_RegRead = RegRead ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) ConsoleWrite ( "+->--- $_RegRead : " & $_RegRead & @Crlf ) If $_RegRead <> '' Then TrayItemSetState ( $_StartItem, $TRAY_CHECKED ) TrayItemSetOnEvent ( $_StartItem, "_StartWithWindows" ) TrayCreateItem ( "" ) $_AboutItem = TrayCreateItem ( "About" ) TrayItemSetOnEvent ( $_AboutItem, "_About" ) TrayCreateItem ( "" ) $_YoutubeItem = TrayCreateItem ( "Open Youtube" ) TrayItemSetOnEvent ( $_YoutubeItem, "_OpenYoutube" ) TrayCreateItem ( "" ) $_OutputItem = TrayCreateItem ( "Open Download Directory" ) TrayItemSetOnEvent ( $_OutputItem, "_OpenDownloadDirectory" ) TrayCreateItem ( "" ) $_NextItem = TrayCreateItem ( "Next Song" ) TrayItemSetOnEvent ( $_NextItem, "_NextSong" ) TrayCreateItem ( "" ) $_AddBLItem = TrayCreateItem ( "Add Song to BlackList" ) TrayItemSetOnEvent ( $_AddBLItem, "_AddToBlacklist" ) TrayCreateItem ( "" ) $_ExitItem = TrayCreateItem ( "Exit" ) TrayItemSetOnEvent ( $_ExitItem, "_Terminate" ) TraySetClick ( 16 ) TraySetState ( 4 ) EndFunc ;==> _TrayMenu ( ) Func _About ( ) TrayItemSetState ( $_AboutItem, $TRAY_UNCHECKED ) Local $_ProgramName="Tiny Charts Jukebox", $_ProgramVersion='1.0.2' MsgBox ( 64 + 8192, "About", "Informations" & @CRLF & @CRLF & $_ProgramName & ' ' & $_ProgramVersion & @CRLF & @CRLF _ & "Hello! I hope this software will be useful for listening Hit Music Only !" & @CRLF _ & "Choose between Random Mode Or Manual Mode." & @CRLF _ & "In Manual Mode a double click on a song will start the music." & @CRLF _ & "You can select 4 genres of Music Singles, Rock, Catalogue, Dance" & @CRLF _ & "and you can Blacklisted Youtube Url that looks Bad !" & @CRLF _ & "Reset Blacklist song is possible too." & @CRLF _ & "For simplicity, english only and all mp3 arrive in a folder on your desktop, but same names are not overwritten." & @CRLF _ & "This program is free and is not protected by a Copyright." & @CRLF _ & "It can be distributed and copied, and may be modified and distributed under a different name." & @CRLF _ & "This program has been tested successfully on XP Sp3 32 bits." & @CRLF & @CRLF _ & "Thank's to use TinyChartsJukebox !" & @CRLF _ & "Thank's to YouTube, quvi developper and AutoIt Community" & @CRLF & @CRLF _ & "wakillon." ) EndFunc ;==> _About ( ) Func _OpenDownloadDirectory ( ) TrayItemSetState ( $_OutputItem , $TRAY_UNCHECKED ) If Not FileExists ( @DesktopDir & '\TinyDownloads' ) Then DirCreate ( @DesktopDir & '\TinyDownloads' ) ShellExecute ( @DesktopDir & '\TinyDownloads' ) EndFunc ;==> _OpenDownloadDirectory ( ) Func _OpenYoutube ( ) TrayItemSetState ( $_YoutubeItem , $TRAY_UNCHECKED ) ShellExecute ( 'http://www.youtube.com' ) EndFunc ;==> _OpenYoutube ( ) Func _StartWithWindows ( ) If @Compiled Then $_ItemGetState = TrayItemGetState ( $_StartItem ) If $_ItemGetState = 64+1 Then RegWrite ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey, "REG_SZ", @ScriptFullPath ) Else RegDelete ( "HKCU\Software\Microsoft\Windows\CurrentVersion\Run", $_TitleKey ) EndIf EndIf EndFunc ;==> _StartWithWindows ( ) Func _CloseWindowWithString ( $_String ) $_WinList = WinList ( ) For $_I = 1 To $_WinList[0][0] If StringInStr ( $_WinList[$_I][0], $_String ) <> 0 And Not BitAnd ( WinGetState ( $_WinList[$_I][1] ), 2 ) Then While WinExists ( $_WinList[$_I][0] ) WinClose ( $_WinList[$_I][1] ) WEnd EndIf Next EndFunc ;==> _CloseWindowWithString ( ) Func _WinClose ( ) Local $_WinListArray = WinList ( ) For $_W = 1 To $_WinListArray[0][0] If $_WinListArray[$_W][0] <> "" Then $_StringInStr = StringInStr ( $_WinListArray[$_W][0], 'http://0.0.0.0/' ) If $_StringInStr <> 0 Then WinClose ( $_WinListArray[$_W][1] ) EndIf Next EndFunc ;==> _WinClose ( ) Func _Terminate ( ) If IsObj ( $oIE ) Then _IEQuit ( $oIE ) _CloseWindowWithString ( 'YouTube - ' ) Exit EndFunc ;==> _Terminate ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " TrayTip ( "TinyChartsJukebox", $_Space & "by wakillon...", 1, 1 ) Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( )Second part : TinyYoutubeGrabber.au3expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=Vinyl orange.ico #AutoIt3Wrapper_outfile=TinyYoutubeGrabber.exe #AutoIt3Wrapper_Compression = 4 #AutoIt3Wrapper_Res_Fileversion=1.0.3 #AutoIt3Wrapper_Res_FileVersion_AutoIncrement=Y #AutoIt3Wrapper_Res_Description = download youtube video and encode them to mp3. #AutoIt3Wrapper_Res_Comment = Tested on Xp 32bit #AutoIt3Wrapper_Res_Language = 1036 #AutoIt3Wrapper_Run_Obfuscator = n #AutoIt3Wrapper_Res_LegalCopyright=Copyright ? 2010 wakillon ://////=__= ://////=__= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ----------------------------------------------------------------------------------------------------------- AutoIt Version : 3.3.6.1 Author : wakillon Title : TinyYoutubeGrabber Script Fonction : Get youtube video download url. Download youtube song. You can Cancel download by TinyChartsJukebox "Cancel Download" button. Encode flv to mp3. #ce ----------------------------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <Constants.au3> #include <String.au3> #include <File.au3> #include <Math.au3> #include <Misc.au3> #Include <Date.au3> Opt ( "GUICloseOnESC", 0 ) Global $_Title, $_YoutubeUrl, $_FileSize, $_PerCentMax=100 Global $_FlvTempPath, $_SavePath = @DesktopDir & '\TinyDownloads', $_ProgressBar, $_Gui, $_Label1, $_Label2 Sleep ( 2000 ) If Not _Singleton ( @ScriptName, 1 ) Then Exit OnAutoItExitRegister ( "_OnAutoItExit" ) _GetCmdLines ( ) _Gui ( ) $_FreeHeight = _GetFreeHeight ( ) _GuiSkin ( ) $_DownloadUrl = _GetDownloadUrl ( $_YoutubeUrl ) If $_DownloadUrl Then _Downloading ( $_DownloadUrl ) Exit Func _GetDownloadUrl ( $_Url ) $_QuviPath = @TempDir & '\TCJ\quvi.exe' $_Run = @ComSpec & ' /c "' & $_QuviPath & '" --xml ' & $_Url ; ConsoleWrite ( '--------- $_Run : ' & $_Run & @Crlf ) FileChangeDir ( @TempDir & '\TCJ' ) $_Pid = Run ( $_Run, '', @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD ) Dim $_StderrRead='', $_StdoutRead='', $_StdReadAll='' While ProcessExists ( $_Pid ) $_StderrRead = StderrRead ( $_Pid ) If Not @error And $_StderrRead <> '' Then $_StdReadAll = $_StdReadAll & $_StderrRead & @CRLF EndIf $_StdoutRead = StdoutRead ( $_Pid ) If Not @error And $_StdoutRead <> '' Then $_StdReadAll = $_StdReadAll & $_StdoutRead & @CRLF EndIf Wend ConsoleWrite ( "!-->--- $_StdReadAll : " & $_StdReadAll & @Crlf ) If StringInStr ( $_StdReadAll, 'no match: video id' ) <> 0 Then MsgBox ( 0, 'Error', 'Sorry...' & @CRLF & 'Download url of "' & $_Url & '" was Not Found !', 5 ) Return 0 EndIf ; Local $a_rep[8][2] = [["%3A", ":"], ["%2F", "/"], ["%2E", "."], ["%5F", "_"], ["%3F", "?"], ["%26", "&"], ["%3D", "="], ["%2D", "-"]] ; For $i = 0 To Ubound ( $a_rep, 1 ) - 1 ; $_StdReadAll = StringRegExpReplace ( $_StdReadAll, "\Q" & $a_rep[$i][0] & "\E", $a_rep[$i][1]) ; Next $_DownloadUrl= _StringBetween ( $_StdReadAll, '<url>', '</url>' ) If @error Then MsgBox ( 0, 'Error', 'Sorry...' & @CRLF & 'Download url of "' & $_Url & '" was Not Found !', 5 ) Return 0 EndIf ConsoleWrite ( "!-->--- $_DownloadUrl[0] : " & $_DownloadUrl[0] & @Crlf ) Return _CleanHtmlName ( $_DownloadUrl[0] ) EndFunc ;==> _GetDownloadUrl ( ) Func _Gui ( ) Local $_ProgressBarHeight=70, $_ProgressBarWidth=360, $_FreeHeight = _GetFreeHeight ( ) $_Gui = GUICreate ( "", $_ProgressBarWidth, $_ProgressBarHeight, @DesktopWidth/2 - $_ProgressBarWidth/2, $_FreeHeight - $_ProgressBarHeight - 5, $WS_POPUPWINDOW, BitOr ( $WS_EX_CLIENTEDGE, $WS_EX_TOOLWINDOW ), WinGetHandle ( AutoItWinGetTitle ( ) ) ) _GuiSkin ( ) $_ProgressBar = GUICtrlCreateProgress ( 5, 25, 350, 23 ) GUICtrlSetTip ( $_ProgressBar, $_Title & @Crlf & "will arrive on your Desktop download directory" ) GUISetState ( @SW_SHOW ) GUICtrlSetData ( $_ProgressBar, 0 ) $_Label1 = GUICtrlCreateLabel ( "TinyYoutubeGrabber [ Mp3 Youtube Downloader ]", 5, 5, 350, 20 ) $_Label2 = GUICtrlCreateLabel ( $_Title, 5, 53, 350, 20 ) EndFunc ;==> _Gui ( ) Func _Downloading ( $_FinalUrl ) Local $_PerCentMax=99, $_FileSize=InetGetSize ( $_FinalUrl ) $_Message='Downloading, Please Wait...' If Not FileExists ( $_SavePath ) Then DirCreate ( $_SavePath ) $_Freepath = _GetFreePath ( $_SavePath & '\' & $_Title & '.mp3' ); ConsoleWrite ( "!>---- $_Freepath : " & $_Freepath & @Crlf ) $_FlvTempPath = @TempDir & '\TCJ\' & $_Title & '.flv' $_Mp3TempPath = @TempDir & '\TCJ\' & $_Title & '.mp3' ; ConsoleWrite ( "!>---- $_TempPath : " & $_FlvTempPath & @Crlf ) $_Download = InetGet ( $_FinalUrl, $_FlvTempPath, 1, 1 ) Local $_InfoData Do $_InfoData = InetGetInfo ( $_Download ) If Not @error Then $_InetGet = $_InfoData[0] $_DownloadPercent = Round ( ( 100 * $_InetGet ) / $_FileSize ) $_DownloadPercent = _Min ( _Max ( 1, $_DownloadPercent ), 99 ) ;ConsoleWrite ( "$_DownloadPercent : " & $_DownloadPercent & @Crlf ) GUICtrlSetData ( $_ProgressBar, $_DownloadPercent ) EndIf Sleep ( 1000 ) Until $_InfoData[2] = True _Flv2Mp3 ( ) Sleep ( 1000 ) FileMove ( $_Mp3TempPath, $_Freepath, 1 ) GUICtrlSetData ( $_ProgressBar, 100 ) GUICtrlSetData ( $_Label2, 'Download succesfull !' ) Sleep ( 2500 ) GUIDelete ( $_Gui ) EndFunc ;==> _Downloading ( ) Func _Flv2Mp3 ( ) Runwait ( @TempDir & '\TCJ\FLVExtractCL.exe -a -o -d "' & $_SavePath & '" "' & $_FlvTempPath & '"', '', @SW_HIDE ) FileDelete ( $_FlvTempPath ) EndFunc ;==> _Flv2Mp3 ( ) Func _GetFullNameByFullPath ( $_FullPath ) $_FileName = StringSplit ( $_FullPath, '\' ) If Not @error Then Return $_FileName[$_FileName[0]] Else Return 0 EndIf EndFunc ;==> _GetFullNameByFullPath ( ) Func _GetFreePath ( $_FilePath ) Local $_N Do $_NewPath = _InsertStringBeetweenNameAndExt ( $_FilePath, $_N ) $_N = $_N + 1 Until Not FileExists ( $_NewPath ) Return $_NewPath EndFunc ;==> _GetFreePath ( ) Func _InsertStringBeetweenNameAndExt ( $_FullPath, $_InsertString ) Local $szDrive, $szDir, $szFName, $szExt $TestPath = _PathSplit ( $_FullPath, $szDrive, $szDir, $szFName, $szExt ) Return $szDrive & $szDir & $szFName & $_InsertString & $szExt EndFunc ;==> _InsertStringBeetweenNameAndExt ( ) Func _GetFreeHeight ( ) Local $_WorkArea, $_Rect = DllStructCreate ( "long left;long top;long right;long bottom" ) Local $_Result = _WinAPI_SystemParametersInfo ( 48, 0, DllStructGetPtr ( $_Rect ), 0 ) If $_Result = True Then $_WorkArea = DllStructGetData ( $_Rect, "bottom" ) - DllStructGetData ( $_Rect, "top" ) If Not @error Then Return $_WorkArea Else Return 0 EndIf EndFunc ;==> _GetFreeHeight ( ) Func _GetCmdLines ( ) If @Compiled Then If $CmdLine[0] = 0 Then Exit $_YoutubeUrl= $CmdLine[1] For $_I = 2 To $CmdLine[0] $_Title = $_Title & ' ' & $CmdLine[$_I] Next $_Title = StringStripWS ( StringRegExpReplace ( $_Title, "\W", ' ' ), 7 ) Else $_Title = 'Lady GaGa Money Honey' $_YoutubeUrl = "http://www.youtube.com/watch?v=vc6vs-l5dkc" EndIf EndFunc ;==> _GetCmdLines ( ) Func _GuiSkin ( ) $Dll = DllOpen ( @TempDir & "\TCJ\skin\SkinH_EL.dll" ) DllCall ( $Dll, "int", "SkinH_AttachEx", "str", @TempDir & "\TCJ\skin\QQ2008.she", "str", "mhgd" ) DllCall ( $Dll, "int", "SkinH_SetAero", "int", 1 ) EndFunc ;==> _GuiSkin ( ) Func _CleanHtmlName ( $_Name ) Local $_Charc = '%20, ,%21,!,%22,",%23,#,%24,$,%25,%,%26,&,%28,(,%29,),%2A,*,%2B,+,%2D,-,%2E,.,%2F,/,%30,0,%31,1,' _ & '%32,2,%33,3,%34,4,%35,5,%36,6,%37,7,%38,8,%39,9,%3A,:,%3B,;,%3C,<,%3D,=,%3E,>,%3F,?,%40,@,%41,A,%42,B,%43,C,' _ & '%44,D,%45,E,%46,F,%47,G,%48,H,%49,I,%4A,J,%4B,K,%4C,L,%4D,M,%4E,N,%4F,O,%50,P,%51,Q,%52,R,%53,S,%54,T,%55,U,' _ & '%56,V,%57,W,%58,X,%59,Y,%5A,Z,%5B,[,%5C,\,%5D,],%5E,^,%5F,_,%60,`,%61,a,%62,b,%63,c,%64,d,%65,e,%66,f,%67,g,' _ & '%68,h,%69,i,%6A,j,%6B,k,%6C,l,%6D,m,%6E,n,%6F,o,%70,p,%71,q,%72,r,%73,s,%74,t,%75,u,%76,v,%77,w,%78,x,%79,y,' _ & '%7A,z,%7B,{,%7C,|,%7D,},%7E,~,%7F, ,%80,€,%81, ,%83,ƒ,%84,„,%85,…,%86,†,%87,‡,%88,ˆ,%89,‰,%8A,Š,%8B,‹,%8C,Œ,' _ & '%8D, ,%8E,Ž,%8F, ,%90, ,%91,‘,%92,’,%93,“,%94,”,%95,•,%96,–,%97,—,%98,˜,%99,™,%9A,š,%9B,›,%9C,œ,%9D, ,%9E,ž,' _ & '%9F,Ÿ,%A0, ,%A1,¡,%A2,¢,%A3,£,%A4, ,%A5,¥,%A6,|,%A7,§,%A8,¨,%A9,©,%AA,ª,%AB,«,%AC,¬,%AD,¯,%AE,®,%AF,¯,%B0,°,' _ & '%B1,±,%B2,²,%B3,³,%B4,´,%B5,µ,%B6,¶,%B7,·,%B8,¸,%B9,¹,%BA,º,%BB,»,%BC,¼,%BD,½,%BE,¾,%BF,¿,%C0,À,%C1,Á,%C2,Â,' _ & '%C3,Ã,%C4,Ä,%C5,Å,%C6,Æ,%C7,Ç,%C8,È,%C9,É,%CA,Ê,%CB,Ë,%CC,Ì,%CD,Í,%CE,Î,%CF,Ï,%D0,Ð,%D1,Ñ,%D2,Ò,%D3,Ó,%D4,Ô,' _ & '%D5,Õ,%D6,Ö,%D7, ,%D8,Ø,%D9,Ù,%DA,Ú,%DB,Û,%DC,Ü,%DD,Ý,%DE,Þ,%DF,ß,%E0,à,%E1,á,%E2,â,%E3,ã,%E4,ä,%E5,å,%E6,æ,' _ & '%E7,ç,%E8,è,%E9,é,%EA,ê,%EB,ë,%EC,ì,%ED,í,%EE,î,%EF,ï,%F0,ð,%F1,ñ,%F2,ò,%F3,ó,%F4,ô,%F5,õ,%F6,ö,%F7,÷,%F8,ø,' _ & '%F9,ù,%FA,ú,%FB,û,%FC,ü,%FD,ý,%FE,þ,%FF,ÿ' $_CharcArray = StringSplit ( $_Charc, "," ) ConsoleWrite ( ">--- Func _CleanHtmlName ( )" & @Crlf ) ; URL Encoding Reference Replace Characters in HTML for display. %2C = ',' %82 = '‚' %27 = "'" $_Name2 = StringReplace ( $_Name, '%82', ',' ) $_Name2 = StringReplace ( $_Name2, '%27', "'" ) For $_C = 1 To UBound ( $_CharcArray ) -1 Step 2 $_Name2 = StringReplace ( $_Name2, $_CharcArray[$_C], $_CharcArray[$_C+1] ) Next $_Name2 = StringReplace ( $_Name2, '%2C', ',' ) Return $_Name2 EndFunc ;==> _CleanHtmlName ( ) Func _OnAutoItExit ( ) Opt ( "TrayIconHide", 0 ) Local $_Space="" If @OSVersion = "WIN_XP" Then $_Space=" " If $_FileSize > 10 Then TrayTip ( "TinyYoutubeGrabber", $_Space & "by wakillon...", 1, 1 ) EndIf Sleep ( 2000 ) TrayTip ( '', '', 1, 1 ) EndFunc ;==> _OnAutoItExit ( )External files are downloaded at the first execution.If you have used an old version, you should delete @Tempdir & '\TCJ' directory first !I hope you enjoy it more ! Edited February 9, 2011 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted December 12, 2010 Author Posted December 12, 2010 (edited) Argh ! Youtube has changed yet his source code !Previous scripts and download link updated...If you download the update, you should delete @Tempdir & '\TCJ' directory first ! Edit : Most of bugg or lagg are due to IE.Reset IE settings is a solution...I can't edit the topic description for modify the date of the last update, it ask me each time to enter a post... Edited April 20, 2011 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted February 9, 2011 Author Posted February 9, 2011 (edited) Some needed Updates : _Website "theofficialcharts.com" doesn't update catalogue genre, so I changed to Independant(Alternative) genre. _Video Search engine is modified for fewer errors. _Cleaning of title is modified for fewer errors. _BlackLists Functions are modified. _A nice Font is added to the gui for the fun. _Skin only for XP _And some littles improvements... It works better ! Edited April 7, 2012 by wakillon AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted April 7, 2012 Author Posted April 7, 2012 Updated. AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted March 23, 2014 Author Posted March 23, 2014 Updated ( almost 2 years since latest version ! ) See first post for changes. AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
wakillon Posted June 28, 2014 Author Posted June 28, 2014 Updated. AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
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