Beege Posted July 26, 2007 Share Posted July 26, 2007 (edited) I Got the idea from Eusebio youtube script. Theres still a few bugs to be worked out but its pretty handy. Comments on mistakes or changes that could be made would be cool so don't hold back. Also it wont work the the new beta. Problem with the Listview. expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> #Include <GuiList.au3> #include <inet.au3> #include <ie.au3> AutoItSetOption("WinTitleMatchMode", 2) HotKeySet('{f8}', '_SaveLink') HotKeySet('{esc}', '_Exit') Local $nItem, $total, $bytes_total, $URL, $DIF Local $sav = 'C:\' Local $Recent_URLS[1] $hGUI = GUICreate("~Beege~ YouTube Download Manager", 517, 350, 213, 268) $hList = GUICtrlCreateListView("", 8, 8, 497, 149) _GUICtrlListViewInsertColumn($hList, 0, 'Save Name', 0, 233) _GUICtrlListViewInsertColumn($hList, 1, 'Size', 0, 70) _GUICtrlListViewInsertColumn($hList, 2, 'URL', 0, 200) _GUICtrlListViewInsertColumn($hList, 3, '', 0, 1) $File_Progress = GUICtrlCreateProgress(8, 192, 497, 17) $Label1 = GUICtrlCreateLabel("Current File: ", 8, 216, 63, 17) $Delete = GUICtrlCreateButton("Delete", 384, 160, 49, 25, 0) $total = GUICtrlCreateLabel("Total Files:", 8, 168, 55, 17) $Label4 = GUICtrlCreateLabel("Total Size:", 232, 168, 54, 17) $Save_Dir = GUICtrlCreateInput("C:\", 88, 248, 337, 21) $Total_Files = GUICtrlCreateLabel("0", 72, 168, 146, 17) $tsize = GUICtrlCreateLabel("0", 296, 168, 74, 17) $Browse = GUICtrlCreateButton("Browse", 440, 248, 57, 25, 0) $Clear = GUICtrlCreateButton("Clear All", 456, 160, 49, 25, 0) $Save = GUICtrlCreateLabel("Save Directory :", 8, 248, 80, 17) $Exit = GUICtrlCreateButton("Exit", 408, 312, 81, 25, 0) $Start = GUICtrlCreateButton("Download", 310, 312, 81, 25, 0) $YouTube = GUICtrlCreateButton("YouTube", 114, 312, 81, 25, 0) $Help = GUICtrlCreateButton("Help", 16, 312, 81, 25, 0) $Checkbox1 = GUICtrlCreateCheckbox("", 16, 280, 17, 17) $Label2 = GUICtrlCreateLabel("Start Downloading Automattically", 40, 280, 159, 17) $CFProgress = GUICtrlCreateLabel("", 72, 216, 415, 17) $Abort = GUICtrlCreateButton("Stop Download", 212, 312, 81, 25, 0) $Checkbox2 = GUICtrlCreateCheckbox("Filecheck", 232, 280, 17, 17) $Label3 = GUICtrlCreateLabel("Do Not Overwrite Previously Downloaded Files", 256, 280, 224, 17) GUISetState(@SW_SHOW) GUICtrlSetState($Checkbox1, $GUI_CHECKED) GUICtrlSetState($Checkbox2, $GUI_CHECKED) GUICtrlSetData($Save_Dir, $sav) Do $GUI = GUIGetMsg() Select Case $GUI = $Browse $sav = FileSelectFolder('Select Save Directory', '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}', 7) If @error = 1 Then ContinueLoop GUICtrlSetData($Save_Dir, $sav) Case $GUI = $Help _help() Case $GUI = $Delete $file = _GUICtrlListViewGetCurSel($hList) _Delete($file) Case $GUI = $Clear _GUICtrlListViewDeleteAllItems($hList) $bytes_total = 0 GUICtrlSetData($Total_Files, _GUICtrlListViewGetItemCount($hList)) GUICtrlSetData($tsize, $bytes_total) Case $GUI = $Abort GUICtrlSetState($Checkbox1, $GUI_UNCHECKED) InetGet('abort') GUICtrlSetData($File_Progress, 0) GUICtrlSetData($CFProgress, '') Case $GUI = $Start And _GUICtrlListViewGetItemCount($hList) > 0 InetGet("abort") $Link = StringSplit( _GUICtrlListViewGetItemText($hList, 0), '|') InetGet($Link[3], $sav & $Link[1], 1, 1) $timer_start = TimerInit() Sleep(4000) If @InetGetActive = 0 Then InetGet("abort") _Delete(0) EndIf Case $GUI = $YouTube $oIE = _IECreate("www.youtube.com") Case $GUI = $Exit Exit EndSelect Select Case @InetGetActive = 1 And @InetGetBytesRead > 0 $DIF = TimerDiff($timer_start) GUICtrlSetData($File_Progress, ((@InetGetBytesRead / $Link[4]) * 100)) GUICtrlSetData($CFProgress, $Link[1] & ' ' & Round(((@InetGetBytesRead / $Link[4]) * 100), 1) & ' % ' & Round((@InetGetBytesRead/ ($DIF / 1000)) / 1000, 1) & ' KB\Sec') Sleep(20) Case @InetGetActive = 0 And GUICtrlRead($File_Progress) >= 1 And _GUICtrlListViewGetItemCount($hList) >= 1 _Delete(0) GUICtrlSetData($Total_Files, _GUICtrlListViewGetItemCount($hList)) GUICtrlSetData($File_Progress, 0) GUICtrlSetData($CFProgress, '') If _GUICtrlListViewGetItemCount($hList) >= 1 Then $Link = StringSplit( _GUICtrlListViewGetItemText($hList, 0), '|') InetGet($Link[3], $sav & $Link[1], 1, 1) $timer_start = TimerInit() EndIf Sleep(15) Case @InetGetActive = 0 And GUICtrlRead($Checkbox1) = 1 And _GUICtrlListViewGetItemCount($hList) >= 1 And GUICtrlRead($CFProgress) = 0 $Link = StringSplit( _GUICtrlListViewGetItemText($hList, 0), '|') InetGet($Link[3], $sav & $Link[1], 1, 1) Sleep(15) $timer_start = TimerInit() Case @InetGetActive = 1 And GUICtrlRead($Checkbox1) = 1 And _GUICtrlListViewGetItemCount($hList) >= 1 And @InetGetBytesRead = -1 InetGet('abort') _Delete(0) TrayTip('Error Downloading File!!', $Link[1], 10, 2) EndSelect Until $GUI = $GUI_EVENT_CLOSE Func _SaveLink() $dwnlink = StatusbarGetText("Internet Explorer") $Link_valid = StringInStr($dwnlink, 'watch?v=') If Not $Link_valid = 1 Then TrayTip('Not a Valid Link!', '"watch?v=" Must be in the Link', 10, 1) Return EndIf $sCode = _INetGetSource($dwnlink) $title = StringRegExp($sCode, '<(?i)title>(.*?)</(?i)title>', 1) If Not IsArray($title) Then Return $title[0] = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimLeft($title[0], 10), '[', ''), ']', ''), '*', ''), '?', ''), ':', ''), '!', ''), '"', '') & '.flv' If StringLen($title[0]) > 250 Then $title[0] = StringLeft($title[0], 250) & '.flv' EndIf If _CheckDuplicate($title[0]) = 1 Then Return $s_t = StringRegExp($sCode, "&t=(.*?)&", 3) $s_v = StringMid($dwnlink, StringInStr($dwnlink, "v=") + 2) $URL = "http://youtube.com/get_video?video_id=" & $s_v & "&t=" & $s_t[0] $bytesize = InetGetSize($URL) $bytes_total = $bytesize + $bytes_total GUICtrlSetData($tsize, _Bytes_Convert($bytes_total)) $nItem = GUICtrlCreateListViewItem($title[0] & '|' & _Bytes_Convert($bytesize) & '|' & $URL & '|' & $bytesize, $hList) TrayTip('Added Video :', $title[0], 10, 1) GUICtrlSetData($Total_Files, _GUICtrlListViewGetItemCount($hList)) EndFunc ;==>_SaveLink Func _CheckDuplicate(ByRef $filecheck) If GUICtrlRead($Checkbox2) = 1 And FileExists($sav & $filecheck) Then TrayTip('File Aready in Save Path!!', $sav & $filecheck, 10, 2) Return 1 EndIf $Check_Duplicate = _GUICtrlListViewFindItem ($hList, $filecheck, -1, BitOR($LVFI_STRING, $LVFI_WRAP)) If $Check_Duplicate <> $LV_ERR Then TrayTip('File Aready in List!!', 'Item ' & $filecheck + 1, 10, 2) Return 1 EndIf EndFunc ;==>_CheckDuplicate Func _Delete($item) If $item = -1 Then $item = 0 $split = StringSplit(_GUICtrlListViewGetItemText($hList, $item), '|') $bytes_total = $bytes_total - $split[4] $total = _Bytes_Convert($bytes_total) _GUICtrlListViewDeleteItem($hList, $item) GUICtrlSetData($Total_Files, _GUICtrlListViewGetItemCount($hList)) GUICtrlSetData($tsize, $total) GUICtrlSetData($CFProgress, '') EndFunc ;==>_Delete Func _Help() MsgBox(0,'How To Use', 'Press Youtube button to lanch Internet Explorer and take you to Youtube' & @CRLF & 'Place mouse pointer over Video Link (Not the Flash player!) and then press F8 to add Video to Download List' & @CRLF & 'Press ESC button to exit Program' & @CRLF & '---NOTE--Some File sizes will show up 0 bytes when they really are not. This is a known bug and program should still download the file.') EndFunc Func _Bytes_Convert($bytes) Select Case $bytes >= 1024000000 Return Round($bytes / 1024000000, 2) & ' GB' Case $bytes >= 1024000 Return Round($bytes / 1024000, 2) & ' MB' Case $bytes >= 1024 Return Round($bytes / 1024, 2) & ' KB' Case Else Return $bytes & ' Bytes' EndSelect EndFunc ;==>_Bytes_Convert Func _Exit() Exit EndFunc ;==>_ExitYouTube_Downloader.au3 Edited November 6, 2013 by Melba23 Title adjusted Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Chris86 Posted July 30, 2007 Share Posted July 30, 2007 You should add a input so we can insert the link our selves because whene i hold the mouse over the link i get this message "watch?v= must be in the link" Link to comment Share on other sites More sharing options...
Beege Posted August 7, 2007 Author Share Posted August 7, 2007 You should add a input so we can insert the link our selves because whene i hold the mouse over the link i get this message "watch?v= must be in the link" Well an inputbox kinda defeats what i was going for and it wouldnt help if your getting that messege. See when you put your mouse over the link and press F8, It copies the statusbar from internet explorer. whats on the status bar should be the link to the video. ""watch?v= must be in the link" is an error messege i put in the script for links that won't work. Links like the "promoted videos" and the "videos being watched right now". I do plan on working on it more, but as of right now, if "watch?v=" is not in the link, it won't work. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now