This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutube-dl.ahk
99 lines (86 loc) · 2.29 KB
/
youtube-dl.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
ytdl = %A_ScriptDir%\Files\youtube-dl.exe
DLtype = Audio
DLdir = %USERPROFILE%\Videos\`%(title)s
Menu, Tray, Icon, %A_ScriptDir%\Files\yt-dl.ico
return
CreateGUI:
{
;set font size
Gui, Font, s9
;format
Gui, Add, Tab3, ggDLtype vDLtype w300, Video|Audio
Gui, Tab, 1 ;video
Gui, Add, Text,, Video Format
Gui, Add, DropDownList, choose1 w250 vFormatVideo, mp4|flv|ogg|webm|mkv|avi|3gp
Gui, Add, CheckBox, vEmbedSubs, Embed Subtitles
Gui, Tab, 2 ;audio
Gui, Add, Text,, Audio Format
Gui, Add, DropDownList, choose1 w250 vFormatAudio, mp3|aac|flac|m4a|opus|vorbis|wav
Gui, Add, CheckBox, vEmbedArt, Embed Album Art
Gui, Tab
;link
Gui, Add, Text,, Video/Playlist Link
Gui, Add, Edit, -Multi r1 w300 vurl, %vLink%
;file name
Gui, Add, Text,, File path
Gui, Add, Edit, -Multi r1 w280 vfilePath, %DLdir%
Gui, Add, Button, gBrowse x+1 y+-22 w19, ...
Gui, Font, s7
Gui, Add, Link,xm, `%(title)s `%(uploader)s `%(playlist_index)s <a href="https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template">more</a>
Gui, Font, s9
;Gui end
Gui, Add, Button, gDownloadVideo default w300, Download Video
return
}
!x::
{
;Set the link edit box to the newest clipboard text
vLink = %Clipboard%
;Show GUI to select format
Gui, Destroy
gosub, CreateGUI
Gui, Show
return
;Submit GUI
DownloadVideo:
Gui, Submit
;Set up config file
configPath = %Appdata%\youtube-dl\config.txt
FileCreateDir, %Appdata%\youtube-dl ;create config dir if it doesn't already exist
FileDelete, %configPath%
FileAppend, #This config file was created with AutoHotkey on %A_MM%/%A_DD%/%A_YYYY% `n`n, %configPath%
;Setup format of downloaded file in config file
If DLtype = Video
{
;Change config file
FileAppend, -f %FormatVideo%`n, %configPath%
FileFormat = %FormatVideo%
if EmbedSubs = 1
{
FileAppend, --embed-subs`n, %configPath%
}
}
Else
{
;Change config file
FileAppend, -x --audio-format %FormatAudio%`n, %configPath%
FileFormat = %FormatAudio%
if EmbedArt = 1
{
FileAppend, --embed-thumbnail`n, %configPath%
}
}
;Name video
FileAppend, -o '%filePath%.%FileFormat%'`n, %configPath%
;Download video
Run, %ytdl% %url%
return
}
gDLtype:
Return
Browse:
FileSelectFile, DLdir,, %USERPROFILE%\Videos, Select download location
Gui, Destroy
gosub CreateGUI
Gui, Show
Return