Cueing Up Downloads on the Go

Posted by on Tuesday 19th of April 3:47 PM

Sometimes when I'm out and about, I want to download files at home. This is common when I'm on a holiday, and want to watch some YouTube movies. The hotel Wifi is often so unreliable that it's a better option to download movies, and let them be sent to you by Dropbox or some other cloud storage provider.

Luckily readers of this blog are huge nerds and will appreciate some forward thinking in this regards.

This is based on a workflow I did in the past, where I would use a Dropbox text file to push links from an iOS device to a desktop computer. (Open iOS Tab on a Mac)

The essentials are still the same. You can use anything on a mobile device that creates a text file in Dropbox. We read that text file on the computer side, process the lines inside of it, and do something based on specific lines.

Please read Open iOS Tab on a Mac for information on the setup. This is still the same, though I want to add you can use Folder Actions as well.

The script we run at the end is a little bit more intricate:

set movielocation to "/Users/ME/Sync/Dropbox/Plex/YouTube/"

set singleItemNaming to "%(uploader)s %(title)s.%(ext)s"
set playlistNaming to "%(playlist)s/%(playlist_index)s - %(uploader)s %(title)s.%(ext)s"

set youtubedlcommand to "/usr/local/bin/youtube-dl"
set youtubedlFormat to "--format '(mp4)[height<=?1080]/best'"

repeat with thisItem in inputAttributes
    if thisItem contains "" and thisItem contains "playlist" and thisItem does not contain "?list=WL" then
        log "playlist"
        set cmd to youtubedlcommand & " " & youtubedlFormat & " " & "--output " & (quoted form of movielocation) & (quoted form of playlistNaming) & " --quiet " & (quoted form of thisItem)
        do shell script cmd
    else if thisItem contains "" then
        log "single item"
        set cmd to youtubedlcommand & " " & youtubedlFormat & " " & "--output " & (quoted form of movielocation) & (quoted form of singleItemNaming) & " --quiet " & (quoted form of thisItem)
        do shell script cmd
        open location (thisItem as string)
    end if
end repeat

You see that I choose to run a different command based on whehter the text contains a playlist. If it is a playlist, youtube-dl creates a folder containing the playlist items. Files inside playlists contain the playlist index in their filename, so they are easier to sort.

Of course you can get creative with this. In this example I match the URL inside the AppleScript. But there are ways to do this in Hazel, too. You can create one rule for each platform you want to download from.

To download single files, check out curl.


As described in the original post, you can use whatever you like. My personal favorites are: