Jump to content
Sign in to follow this  
wakillon

TinyYoutubeJukebox

Recommended Posts

wakillon

TinyYoutubeJukebox :

Script Fonction : Play Videos of Uk Top Charts singles like a jukebox in random order

by getting charts List on charts website and search song's list on youtube.

_ ESC for Quit

_ WebSite http://www.theofficialcharts.com/singles-chart/ is updated weekly

_ 4 Genres :

Singles chart

Rock and metal singles chart

Catalogue singles chart

Dance singles chart

_ But some times with embeded video, you get this message "This video is restricted from being viewed on this domain".

So I add 'live' to youtube query for get more of "no restrited video".

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Radio.ico
;#AutoIt3Wrapper_Run_Debug_Mode=Y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs --------------------------------------------------------------------------------------------------------------------------------------------

 AutoIt Version  : 3.3.6.1
 Author          : Wakillon
 Title          : TinyYoutubeJukebox
 Script Fonction : Play Videos of Uk Top Charts singles like a jukebox in random order 
                by getting charts List on charts website and search song's list on youtube.
                _ ESC for Quit
                _ WebSite http://www.theofficialcharts.com/singles-chart/ is updated weekly
                _ 4 Genres  :  
                                singles-chart
                                rock-and-metal-singles-chart
                                catalogue-singles-chart
                                dance-singles-chart
                _ But some times with embeded video, you get this message "This video is restricted from being viewed on this domain".
                    So I add 'live' to youtube query for have more "no restrited video".
                    
#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 = 157, $_X=370, $_Spaces='        '
Dim $_Text= @Crlf & $_Spaces & '_ ESC for Quit'
Dim $_DurationDiff, $_DurationMs, $_GetItem, $_RandomMode=1
Dim $_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\TinyYoutubeJukebox"
Global $_LastUkTopChartsListArray[1], $_RandomArray[1], $_DurationArray[1]
Global $_Duration, $_UpDateDate, $_LastChartPageSourceCode, $_Invert=True, $_InvertTimerInit=TimerInit ( ), $_StatusBar, $_Loop, $oIE
Global $_StatusParts[1] = [500], $_TempStatus[1] = [""]

Opt ( "TrayMenuMode", 1 )
TraySetIcon ( "Shell32.dll", -138 ) 
TraySetToolTip ( "   TinyYoutubeJukebox" & @Crlf & StringStripWS ( $_Text, 7 ) ) 
TraySetState ( 4 )
OnAutoItExitRegister ( "_OnAutoItExit" )    

Do    
    Sleep ( 1000 )
    ToolTip ( $_Spaces & 'Waiting for Internet connection', @DesktopWidth/2-100, 0, 'Tiny Youtube Jukebox', 1, 4 )
Until _IsConnected ( )
ToolTip ( '' )

$_Genre = StringSplit ( 'singles-chart|rock-and-metal-singles-chart|catalogue-singles-chart|dance-singles-chart', '|' )
$_SubKey = _SelectGenre ( ) 
$_LastChartsUrl = 'http://www.theofficialcharts.com/' & $_SubKey & '/'
$_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 Youtube Jukebox', 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 )
Dim $_ListViewItem[$_LastUkTopChartsListArray[0]+1]
Dim $_GuiTitle='Tiny Youtube ' & $_SubKey & ' Jukebox ' & $_UpDateDate
Opt ( "GuiOnEventMode", 1 ) 


$_Gui                      = GUICreate ( $_GuiTitle, 695, 330, @DesktopWidth-704, @DesktopHeight - 400 )
                        GUISetBkColor ( 0xFFD900 ) 
                            GUISetIcon ( "Shell32.dll", -138 )
                         GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Terminate" )
$_ListView  = GUICtrlCreateListView ( "Top Nb|Title - Artist", 5, 5, 360, 275 )
    _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, 229, $_ButtonWidth, 24 )   
                    GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" )
                    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
                    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
                    GUICtrlSetState ( $_RandomButton, $GUI_DISABLE )
$_NextButton    = GUICtrlCreateButton ( "Next Random Song", $_X+163, 229, $_ButtonWidth, 24 )               
                    GUICtrlSetOnEvent ( $_NextButton, "_NextSong" )
$_SelectButton   = GUICtrlCreateButton ( "Listen Selected Song", $_X, 257, $_ButtonWidth, 24 ) 
                    GUICtrlSetOnEvent ( $_SelectButton, "_SelectSong" )
                    GUICtrlSetBkColor ( $_SelectButton, 0xFFFF00 ) 
                    GUICtrlSetColor ( $_SelectButton, 0xff0000 )    
                    GUICtrlSetState ( $_SelectButton, $GUI_DISABLE ) 
$_ExitButton    = GUICtrlCreateButton ( "Exit", $_X+163, 257, $_ButtonWidth, 24 ) 
                    GUICtrlSetOnEvent ( $_ExitButton, "_Terminate" )
$_StatusBar = _GUICtrlStatusBar_Create ( $_Gui, $_StatusParts, $_TempStatus, $SBARS_SIZEGRIP )
        _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 40 )
    $_Icons = _WinAPI_LoadShell32Icon ( 128 )
            _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons )
                        GUISetState ( @SW_SHOW )
                          
                            
While 1
    If $_RandomMode Then
        $_R = _Randomize ( $_LastUkTopChartsListArray[0] ) 
        $_Text2 = $_LastUkTopChartsListArray[$_R]
        _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & ' Waiting for Next Video...', 0 )   
        $_YoutubeSearch = _YoutubeSearch ( $_LastUkTopChartsListArray[$_R] ) 
        If StringInStr ( $_YoutubeSearch, 'http://www.youtube.com/' ) <> 0 Then 
            $_YoutubeEmbedUrl = StringReplace ( $_YoutubeSearch, 'watch?v=', 'v/' ) 
            $Flash = _GuiCtrlCreateFlash ( 320, 220, $_X , 5,  $_YoutubeEmbedUrl ) 
            $_DurationInit = TimerInit ( )
            $_DurationDiff=0
            _WinSetOnTopOneTime ( $_GuiTitle )
            $_Loop = 1
            GUICtrlSetState ( $_RandomButton, $GUI_ENABLE ) 
        Else    
            _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Top N°' & $_R & ' - ' & $_LastUkTopChartsListArray[$_R] & @Crlf & 'Video Not Found !', 0 )    
            _WinSetOnTopOneTime ( $_GuiTitle )
            Sleep ( 2000 )
        EndIf
    EndIf
    If _EachXseconds ( 1.5 ) Then _InvertColorButton ( $_RandomButton )
    While $_Loop
        If $_DurationDiff > $_DurationMs Then
            $oIE.Stop
            $_Loop =0
            _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 )
            ExitLoop 
        EndIf       
        Sleep ( 20 )
        If _EachXseconds ( 1.1 ) 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 )
    WEnd
WEnd

Func _GuiCtrlCreateFlash ( $_EmbedWidth, $_EmbedHeight, $_Left, $_Top, $_FlashUrl )
    Local $_GUIActiveX, $_HtmlCode, $_OpenFile
    If Not IsObj ( $oIE ) Then $oIE = ObjCreate ( "Shell.Explorer.2" )
    $_GUIActiveX = GUICtrlCreateObj ( $oIE, $_Left, $_Top, $_EmbedWidth, $_EmbedHeight )
    $_HtmlCode = '<object width="' & $_EmbedWidth & '" height="' & $_EmbedHeight & '">'
    $_HtmlCode &= '<param name="movie" value="' & $_FlashUrl & '?autoplay=1"></param>'
    $_HtmlCode &= '<param name="allowScriptAccess" value="always"></param>' 
    $_HtmlCode &= '<embed src="' & $_FlashUrl & '?autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" width="' & $_EmbedWidth-27 & '" height="' & $_EmbedHeight-27 & '">'
    $_HtmlCode &= '</embed>'
    $_HtmlFilePath = @TempDir & "\AutoItFlash.html" 
    $_OpenFile = FileOpen ( $_HtmlFilePath, 2 )
    FileWrite ( $_OpenFile, $_HtmlCode )
    FileClose ( $_OpenFile )
    $oIE.navigate ( $_HtmlFilePath )
    $oIE.document.body.scroll = "no" 
    FileDelete ( $_HtmlFilePath )
    Return $_GUIActiveX
EndFunc ;==> _GuiCtrlCreateFlash ( )

Func _SelectSong ( )
    If $_Loop Then $oIE.Stop
    $_GetItem = _GetItem ( )
    If $_GetItem Then
        _GUICtrlStatusBar_SetText ( $_StatusBar, $_Spaces & 'Waiting for Next Video...', 0 )
        $_YoutubeSearch = _YoutubeSearch ( $_GetItem )
            $_YoutubeEmbedUrl = StringReplace ( $_YoutubeSearch, 'watch?v=', 'v/' ) 
            $Flash = _GuiCtrlCreateFlash ( 320, 220, $_X-20, 5, $_YoutubeEmbedUrl ) 
        $_DurationInit = TimerInit ( )
        $_DurationDiff=0
        $_Text2 = $_GetItem
        $_Loop =1
    EndIf
EndFunc ;==> _SelectSong ( )

Func _RandomMode ( )
    $_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, 229, $_ButtonWidth, 24 ) 
    Else    
        $_RandomMode = 1
        GUICtrlSetState ( $_SelectButton, $GUI_DISABLE )
        GUICtrlSetState ( $_NextButton, $GUI_ENABLE )
        $_RandomButton = GUICtrlCreateButton ( "Disable Random Mode", $_X, 229, $_ButtonWidth, 24 ) 
    EndIf
    $_Text2=''
    Sleep ( 250 )
    GUICtrlSetBkColor ( $_RandomButton, 0xFF0000 )  
    GUICtrlSetColor ( $_RandomButton, 0xFFFF00 ) 
    GUICtrlSetOnEvent ( $_RandomButton, "_RandomMode" ) 
EndFunc ;==> _RandomMode ( )

Func _NextSong ( )
    $oIE.Stop
    $_Loop=0    
    _GUICtrlStatusBar_SetText ( $_StatusBar, '', 0 )
EndFunc ;==> _NextSong ( )

Func _SelectGenre ( )
    $_Gui = GUICreate ( "Tiny Youtube Jukebox, Select Genre...", 250, 130, -1, -1, -1, BitOR ( $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW ) ) 
    GUISetBkColor ( 0xFFD900 ) 
    Dim $_Radio[UBound ( $_Genre )]
    For $_I = 1 To UBound ( $_Genre ) -1
        $_Radio[$_I] = GUICtrlCreateRadio ( _StringProper ( StringReplace ( $_Genre[$_I], '-', ' ' ) ), 10, $_I*20 -10, 160, 20 )
    Next
    GUISetState ( )    
    $_TimerInit =  TimerInit ( )
    While 1
        $msg = GUIGetMsg ( )    
        Select
            Case $msg = $GUI_EVENT_CLOSE
            Exit
            Case $msg <> -11 And $msg <> 0
                For $_I = 1 To UBound ( $_Genre ) -1
                    If $msg = $_Radio[$_I] And BitAND ( GUICtrlRead ( $_Radio[$_I] ), $GUI_CHECKED ) = $GUI_CHECKED Then
                        $_SubKey = $_Genre[$_I]
                        GUIDelete ( $_Gui )
                        Return $_SubKey
                    EndIf
                Next
        EndSelect
        $_ChoiceTimerDiff = Round ( TimerDiff ( $_TimerInit )/1000 )
        If _EachXseconds ( 1 ) Then GUICtrlCreateLabel ( StringFormat ( "%02i", ( 11 - $_ChoiceTimerDiff ) ) & ' Seconds to make your Choice...', 10, ( $_I+1 ) * 20 -10 )
        If $_ChoiceTimerDiff > 10 Then
            Dim $_SubKey = $_Genre[Random ( 1, $_Genre[0], 1 )]
            GUIDelete ( $_Gui )
            Return $_SubKey
        EndIf       
        Sleep ( 20 )
    WEnd
EndFunc ;==> _SelectGenre ( )

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 )
    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 )
                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]
    $_Query = StringStripWS ( StringReplace ( $_Query, '-', ' ' ) & ' official video live' , 7 )
    $_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|lyrics|cover|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
                    $_SourceCode = _GetSourceCode ( $_UrlToExtract )        
                    $_AllowEmbed = StringInStr ( $_SourceCode, 'attribution content=' ) + StringInStr ( $_SourceCode, "ALLOW_EMBED': false" ) 
                    If $_AllowEmbed = 0 Then    
                        $_Duration = $_DurationArray[$_I]
                        Return $_UrlToExtract
                    EndIf
                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 _CleanVideoName ( $_Name )
    $_Name2 = StringRegExpReplace ( $_Name, '(&quot;)|(&quot;)|(quot;)|(&amp;)|(amp;)|(&lt;)|(lt;)|(&gt;)|(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 _Terminate ( )
    If $_Loop Then $oIE.Stop
    FileDelete ( @TempDir & '\*.html' )
    Exit 
EndFunc ;==> _Terminate ( )

Func _OnAutoItExit ( )
    Opt ( "TrayIconHide", 0 ) 
    Local $_Space=""
    If @OSVersion = "WIN_XP" Then $_Space="        "
    TrayTip ( "TinyYoutubeJukebox", $_Space & "by wakillon...", 1, 1 )
    Sleep ( 2000 )
    TrayTip ( '', '', 1, 1 )
EndFunc ;==> _OnAutoItExit ( )

Posted Image

I hope you enjoy it Posted Image

Thanks to ChrisL for his _GuiCtrlCreateFlash Function and pierrotm777 for his help !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pierrotm777

Cooool , I love also !!!

Very good job.

I think to adapt it if you accept to RideRunner !

Share this post


Link to post
Share on other sites
pierrotm777

A full screen option (into the gui) would be cool ! :blink:

And may be , the possibility to download or not the video that you see

Edited by pierrotm777

Share this post


Link to post
Share on other sites
wakillon

Cooool , I love also !!!

Very good job.

I think to adapt it if you accept to RideRunner !

Thanks !, Yes I gladly accept, and I hope you don't find any bug ! Posted Image

A full screen option (into the gui) would be cool ! :blink:

And may be , the possibility to download or not the video that you see

I don't know how do a full screen in the gui Posted Image

But for the download, I' m allready working on a new project... Posted Image

Meanwhile, here is an Skiny update and Flash screen is more larger...

Posted Image

I have some problem with refresh flash ctrl,

I have try usual GUICtrlSetState with different state but it bug, so If someone know how do that...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pierrotm777

I think that you can to put the video in a gui larger and hide the first gui with the possibility to return to the main gui !

Share this post


Link to post
Share on other sites
wakillon

I think that you can to put the video in a gui larger and hide the first gui with the possibility to return to the main gui !

I will Try your idea... and I will add a Button for "BlackListed" bad Youtube Url Videos Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pierrotm777

In fact, some url video are bad and the video is stopped immediately ;)

Share this post


Link to post
Share on other sites
wakillon

In fact, some url video are bad and the video is stopped immediately ;)

Oups, i will see that...Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
wakillon

Nice. Thank you.

Thanks ! Posted Image

Glad you enjoy it !

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.