Jump to content

Download Media — Download video and audio from web pages


Recommended Posts

I've stumbled upon another workflow that shows you the download progress. You may get an idea from there: http://www.alfredforum.com/topic/2680-search-download-and-install-mac-apps/

Unfortunately, that’s what I consider to not be a good way to do it. It might be fine when downloading a single application, but when downloading video after video (which I regularly do), having a GUI bar appear is really suboptimal and ugly. That is a solution I won’t pursue.

Link to comment
  • 1 month later...
  • 1 month later...
  • 1 month later...

Is there any way to download more than 1 link at a time without having to wait for each one to finish?

 

also, is there a way it keeps track of it when i'm going through several links and employing download? like i noticed that just after one finishes downloading, if i had ran it again during that period, the next one in the queue will start.. was wondering if it's a "running queue" and will continually keep downloading them on it's own or if i have to be patient and do each one at a time while keeping the page open? (also, can i close the page after downloading begins?) thanks vitor!

Link to comment
  • 3 weeks later...
  • 2 weeks later...

ghani1990 youtube-dl has a --get-url option that should get the direct url to the download file, instead of downloading it. In the Run Script node on the top right, there’s a getfile function you’ll need to change to accommodate this. It’s likely here that you should write your logic to open said url in your download accelerator.
 
I don’t use (or have any interest in) any of those download accelerators and they’re paid apps, so this is as far as I’ll go.

Link to comment
  • 1 month later...

Update. OS X Services.

You can now add DownVid actions as OS X Services, by running “installdownvidservices” (if you ever want to remove them, simply delete them from the ~/Library/Services directory).

ctIgv51.png

What this means is wherever you find a URL, you’ll be able to right click it and start the download right from the context menu.

nV7zwvl.png

Link to comment

Apparently youtube doesn't know what *best* quality means.  Even though there was a 1080p version of a video it downloaded the 720p version:

format code extension resolution  note
139         m4a       audio only  DASH audio   49k , audio@ 48k (22050Hz), 581.15KiB (worst)
140         m4a       audio only  DASH audio  129k , audio@128k (44100Hz), 1.51MiB
171         webm      audio only  DASH audio  132k , audio@128k (44100Hz), 1.30MiB
172         webm      audio only  DASH audio  193k , audio@256k (44100Hz), 1.90MiB
141         m4a       audio only  DASH audio  255k , audio@256k (44100Hz), 2.99MiB
278         webm      256x144     DASH video   97k , webm container, VP9, video only, 593.79KiB
160         mp4       256x144     DASH video  121k , video only, 1.17MiB
242         webm      426x240     DASH video  215k , video only, 1.05MiB
133         mp4       426x240     DASH video  296k , video only, 2.63MiB
243         webm      640x360     DASH video  382k , video only, 1.89MiB
134         mp4       640x360     DASH video  354k , video only, 2.26MiB
244         webm      854x480     DASH video  614k , video only, 3.04MiB
135         mp4       854x480     DASH video  676k , video only, 4.67MiB
247         webm      1280x720    DASH video 1161k , video only, 5.82MiB
136         mp4       1280x720    DASH video 1221k , video only, 9.26MiB
248         webm      1920x1080   DASH video 2010k , video only, 10.77MiB
137         mp4       1920x1080   DASH video 2342k , video only, 18.47MiB
17          3gp       176x144
36          3gp       320x240
5           flv       400x240
43          webm      640x360
18          mp4       640x360
22          mp4       1280x720    (best)

I added this flag into the getfile method to get it to download a 1080p version:

 

-f 137/22/18/17 

Link to comment

meflou Open the Run Script node on the top right. Very near the end you’ll find a line that reads downdir="${HOME}/Desktop"; change it to downdir="${HOME}/Downloads". Alternatively, if you have WatchList and add to it via this workflow, it’ll default to that directory.

scottfwalter. Not sure if the fault lies with youtube-dl or youtube, on that one. It’s more likely the former’s fault, though, so you should open a bug report. This workflow simply uses the default (supposedly the best).

Edited by Vítor
Link to comment

meflou Open the Run Script node on the top right. Very near the end you’ll find a line that reads downdir="${HOME}/Desktop"; change it to downdir="${HOME}/Downloads". Alternatively, if you have WatchList and add to it via this workflow, it’ll default to that directory.

 

 

When I download any file it got the format nameofvideo.mp4.part so every time I have to delete .part to be able to read the video, how can I fix this?

Also I changed the path to downdir=" /Users/q/Downloads/Downloads/Videos" but still it download them to Downloads not to Videos under the folder downloads. Thank You!

Link to comment

When I download any file it got the format nameofvideo.mp4.part

That should be only temporary, until the video finishes downloading. That way you know the download hasn’t finished, and can even continue it later, if it interrupts for some reason.

 

Also I changed the path to downdir="/Users/q/Downloads/Downloads/Videos"

You have Downloads twice (…/Downloads/Downloads/…), there, don’t you mean downdir="${HOME}/Downloads/Videos"? You can use ${HOME} literally; it’ll know what it means.

To make sure the directory you want to download to exists, you can open a terminal and run mkdir -p <path_to_directory>.

Edited by Vítor
Link to comment
  • 4 months later...

Fantastic workflow (not surprising really coming from you Vitor)...

 

I'm having an issue where I followed the steps to keep video & audio and it works. For some reason, it creates a second version of both the video & audio. For example, using the workflow, it downloaded a video called "Best DIY GoPro Mounts.mp4"... it also created another version entitled "Best DIY GoPro Mounts.f136.mp4". It does the same with the audio... two m4a versions one including .f141.m4a.

 

I just added --extract-audio --keep-video --quiet

 

The script I'm using for dv following the instructions...

export PATH="/usr/local/bin:$PATH"

# deal with special characters
export LANG=en_GB.UTF-8

IFS=$'\n'

# set notifications
notification() {
  ./_licensed/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier -title "DownVid" -message "${1}"
}

# update youtube-dl if it's more than 15 days old
if [[ $(find youtube-dl -mtime +15) ]]; then
  python youtube-dl --update
fi

gettitle() {
  # file location
  filename=$(python youtube-dl --no-playlist --extract-audio --keep-video --quiet --output "${downdir}/%(title)s.%(ext)s" --get-filename "${link}")

  # title
  title=$(basename ${filename%.*})

  # check if url is valid
  if [[ -z "${filename}" ]]; then
    notification "The url is invalid"
    exit 1
  else
    notification "Downloading “${title}”"
  fi
}

getfile() {
  progressfile="/tmp/downvidprogress"

  python youtube-dl --no-playlist --extract-audio --keep-video --quiet --newline --output "${downdir}/%(title)s.%(ext)s" "${link}" > "${progressfile}"

  # add metadata
  xmlencodedurl=$(echo "${link}" | perl -MHTML::Entities -CS -pe'$_ = encode_entities($_, q{&<>"'\''})')
  xattr -w com.apple.metadata:kMDItemWhereFroms '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array><string>'"${xmlencodedurl}"'</string></array></plist>' "${filename}"

  rm "${progressfile}"
}

# download
printf "{query}" > "/tmp/downvidcurrentquery"

if [[ "{query}" == "addToWatchList"* ]]; then
  link=$(cat "$(echo {query} | sed 's/addToWatchList //')")
  downdir="${HOME}/Downloads"
  gettitle
  getfile
  osascript -e "tell application \"Alfred 2\" to run trigger \"add_to_watchlist\" in workflow \"com.vitorgalvao.alfred.watchlist\" with argument \"${filename}\""
else
  link="$(cat {query})"
  downdir="${HOME}/Desktop"
  gettitle
  getfile
fi

notification "Downloaded “${title}”"
Link to comment

 

Fantastic workflow (not surprising really coming from you Vitor)...

 

I'm having an issue where I followed the steps to keep video & audio and it works. For some reason, it creates a second version of both the video & audio. For example, using the workflow, it downloaded a video called "Best DIY GoPro Mounts.mp4"... it also created another version entitled "Best DIY GoPro Mounts.f136.mp4". It does the same with the audio... two m4a versions one including .f141.m4a.

 

I just added --extract-audio --keep-video --quiet

 

The script I'm using for dv following the instructions...

export PATH="/usr/local/bin:$PATH"

# deal with special characters
export LANG=en_GB.UTF-8

IFS=$'\n'

# set notifications
notification() {
  ./_licensed/terminal-notifier/terminal-notifier.app/Contents/MacOS/terminal-notifier -title "DownVid" -message "${1}"
}

# update youtube-dl if it's more than 15 days old
if [[ $(find youtube-dl -mtime +15) ]]; then
  python youtube-dl --update
fi

gettitle() {
  # file location
  filename=$(python youtube-dl --no-playlist --extract-audio --keep-video --quiet --output "${downdir}/%(title)s.%(ext)s" --get-filename "${link}")

  # title
  title=$(basename ${filename%.*})

  # check if url is valid
  if [[ -z "${filename}" ]]; then
    notification "The url is invalid"
    exit 1
  else
    notification "Downloading “${title}”"
  fi
}

getfile() {
  progressfile="/tmp/downvidprogress"

  python youtube-dl --no-playlist --extract-audio --keep-video --quiet --newline --output "${downdir}/%(title)s.%(ext)s" "${link}" > "${progressfile}"

  # add metadata
  xmlencodedurl=$(echo "${link}" | perl -MHTML::Entities -CS -pe'$_ = encode_entities($_, q{&<>"'\''})')
  xattr -w com.apple.metadata:kMDItemWhereFroms '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array><string>'"${xmlencodedurl}"'</string></array></plist>' "${filename}"

  rm "${progressfile}"
}

# download
printf "{query}" > "/tmp/downvidcurrentquery"

if [[ "{query}" == "addToWatchList"* ]]; then
  link=$(cat "$(echo {query} | sed 's/addToWatchList //')")
  downdir="${HOME}/Downloads"
  gettitle
  getfile
  osascript -e "tell application \"Alfred 2\" to run trigger \"add_to_watchlist\" in workflow \"com.vitorgalvao.alfred.watchlist\" with argument \"${filename}\""
else
  link="$(cat {query})"
  downdir="${HOME}/Desktop"
  gettitle
  getfile
fi

notification "Downloaded “${title}”"

 

Per Scott's suggestion, adding -f 137/22/18/17 to the workflow got rid of the numbered versions and the workflow is now working correctly.

Link to comment

Fantastic workflow (not surprising really coming from you Vitor)...

Thank you for the kind words.

Per Scott's suggestion, adding -f 137/22/18/17 to the workflow got rid of the numbered versions and the workflow is now working correctly.

Glad you got it working. I took the chance to update the instructions, as they were slightly out-of-date.

Link to comment

Thank you for the kind words.

Glad you got it working. I took the chance to update the instructions, as they were slightly out-of-date.

 

I noticed from the youtube-dl readme file, as of April 26, 2015, youtube-dl uses -f bestvideo+bestaudio/best as the default. Is there a way to tell if the workflow is using the most current version of youtube-dl?

 

Thanks.

Link to comment

Is there a way to tell if the workflow is using the most current version of youtube-dl?

You can go into the workflow’s directory and run python youtube-dl -U to update. However, every time you run the workflow it checks if the version you have in it (the actual file) is over 15 days old, and if it is it updates it, so you should never be too far behind.

 

Rest assured, the only operations it performs to achieve this are checking how old the file is (using common local CLI tools) and that same youtube-dl -U (youtube-dl --update, in this case) command to update, so it isn’t “phoning home” or anything like that (well, unless youtube-dl itself is doing something nasty, but I seriously doubt that).

Edited by Vítor
Link to comment

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
×
×
  • Create New...