├── README.md └── ytdl-ResolveWindow_V2 (1).lua /README.md: -------------------------------------------------------------------------------- 1 | # youtube-to-resolve-Windows 2 | download a youtube video into Davinci Resolve studio on Windows 3 | 4 | 5 | to install place the lua file in: C:\ProgramData\Blackmagic Design\DaVinci Resolve\Fusion\Scripts\Comp 6 | 7 | to run in Resolve: Workspace > Scripts > ytdl-ResolveWindow_V2 (1) 8 | 9 | this script requires youtube-dl to work 10 | -------------------------------------------------------------------------------- /ytdl-ResolveWindow_V2 (1).lua: -------------------------------------------------------------------------------- 1 | local ui = fu.UIManager 2 | local disp = bmd.UIDispatcher(ui) 3 | local width,height = 600,600 4 | local clock = os.clock 5 | 6 | function sleep(n) -- seconds 7 | local t0 = clock() 8 | while clock() - t0 <= n do end 9 | end 10 | win = disp:AddWindow({ 11 | ID = 'MyWin', 12 | WindowTitle = 'youtube-dl', 13 | Geometry = {100,100,width,height}, 14 | Spacing = 15, 15 | Margin = 20, 16 | 17 | ui:VGroup{ 18 | ID = 'root', 19 | ui:HGroup{ 20 | ui:LineEdit{ ID = "inputurl", 21 | PlaceholderText = "Enter a video's url", 22 | Text = "", 23 | Weight = 1.5, 24 | MinimumSize = {150, 24} }, 25 | ui:Button{ID='geturl', Text='Get Formats', weight=1.5}, 26 | 27 | }, 28 | ui:HGroup{ 29 | ui:TextEdit{ID='formats', Text = '[yt-dl] \n [info] Available formats (Choose an MP4)', ReadOnly = true,}, 30 | }, 31 | ui:HGroup{ 32 | ui:LineEdit{ ID = "userformat", 33 | PlaceholderText = "Leave blank on stock sites", 34 | Text = "", 35 | Weight = 1.5, 36 | MinimumSize = {150, 24} }, 37 | ui:Button{ID='getvidf', Text='Get video', weight=1.5}, 38 | }, 39 | 40 | }, 41 | 42 | }) 43 | 44 | 45 | 46 | itm=win:GetItems() 47 | resolve = Resolve() 48 | projectManager = resolve:GetProjectManager() 49 | project = projectManager:GetCurrentProject() 50 | mediapool = project:GetMediaPool() 51 | folder = mediapool:GetCurrentFolder() 52 | mediastorage=resolve:GetMediaStorage() 53 | mtdvol=mediastorage:GetMountedVolumes() 54 | 55 | 56 | 57 | function win.On.MyWin.Close(ev) 58 | disp:ExitLoop() 59 | end 60 | 61 | function win.On.geturl.Clicked(ev) 62 | url = tostring(itm.inputurl.Text) 63 | dump(url) 64 | lpath = tostring(mtdvol[1]).."/ytdl" 65 | dump(lpath) 66 | 67 | ytdlProgramPath = 'youtube-dl' 68 | 69 | 70 | ytformatcmd=ytdlProgramPath.." -F "..url 71 | formatproc=io.popen(ytformatcmd) 72 | local foutput = formatproc:read('*all') 73 | formatproc:close() 74 | dump(foutput) 75 | 76 | 77 | itm.formats.PlainText = foutput 78 | ytcommand=ytdlProgramPath.." "..url 79 | dump("Attempting to download ") 80 | dump(ytcommand) 81 | 82 | --propat=os.execute(ytcommand) 83 | --mediastorage:AddItemListToMediaPool(fpath) 84 | 85 | 86 | 87 | folder = mediapool:GetCurrentFolder() 88 | 89 | 90 | end 91 | 92 | function win.On.getvidf.Clicked(ev) 93 | 94 | 95 | url = tostring(itm.inputurl.Text) 96 | 97 | if itm.userformat.Text ~= "" then 98 | uformat = tostring(itm.userformat.Text) 99 | uwuformat = " -f "..uformat 100 | dump(uwuformat) 101 | else 102 | uwuformat = " " 103 | dump("Inentionally blank ") 104 | end 105 | 106 | 107 | pname = project:GetName() 108 | ipath = mtdvol[1].."\\ytdl\\"..pname 109 | iqpath = "\""..mtdvol[1].."\\ytdl\\"..pname.."\"" 110 | prelscomm = "dir \""..ipath.."\" /o-d /tc /b" 111 | dump(prelscomm) 112 | count = 0 113 | 114 | 115 | --[[for line in noutput:lines() do 116 | if count == 8 then 117 | noutput:close() 118 | preoutput = line 119 | end 120 | count = count+1 121 | end 122 | noutput:close()]] 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | ytdlcomm ="youtube-dl"..uwuformat.." "..url.." -o \""..ipath.."\\%(title)s.%(ext)s\" --restrict-filenames" 131 | propat=os.execute(ytdlcomm) 132 | 133 | prenameproc = assert(io.popen(prelscomm)) 134 | for line in prenameproc:lines() do 135 | 136 | if count == 0 then 137 | dump(line) 138 | fname = line 139 | end 140 | count = count +1 141 | end 142 | prenameproc:close() 143 | 144 | 145 | fpath = ipath.."\\"..fname 146 | dump(fpath) 147 | mediastorage:AddItemListToMediaPool(fpath) 148 | 149 | 150 | end 151 | 152 | win:Show() 153 | disp:RunLoop() 154 | win:Hide() --------------------------------------------------------------------------------