How to download video ads from Youtube?

Viewed 27529

I'd like to download some (I mean a lot of) video ads from YouTube (not the videos, but the ads that are played before them) for research purposes.

Any suggestions for tools or ways this can be achieved? I won't mind some programming on my hack but I currently have no idea how. Also, YouTube is not an requirement; video ads from other video sites work for me too.

4 Answers

A far simpler solution is to right click on the video window and select Stats for nerds.

enter image description here

A list of stats will appear, look for Video ID and copy it - only copy the part of the string before the / character, as you only need the Video ID, not the sCPN string. (For example I was looking for a Sam Ovens video, but the advert video had no clickable link, so I used the Stats for nerds feature and found the ID: a-C4m7teAAU).

enter image description here

Then simply append the video ID onto the standard YouTube watch URL like so:

https://www.youtube.com/watch?v=a-C4m7teAAU

Update

Some people are saying that this no longer works. I just tried it on a Samsung video and it still works fine: https://www.youtube.com/watch?v=aw-qPNT7E0k

enter image description here

2020 May, these methods worked for me

Copy paste mode

  • Right click on the video ad while it is playing.
  • Select [Stats for nerds].
  • Open your developer browser console and paste this. Check the Explanation section if you worried about this javascript:
alert("https://www.youtube.com/watch?v="+$(".html5-video-info-panel-content").children[0].children[1].textContent.replace(" ","").split("/")[0])
  • You will be prompted with the url ready to copy and paste!!

url


Click mode

In the console of web browser, paste this:

var a = document.createElement('a');
var linkText = document.createTextNode("--> donwload ads");
a.appendChild(linkText);
a.title = "donwload ads";
a.target = "_blank";
a.href = "https://www.youtube.com/watch?v="+$(".html5-video-info-panel-content").children[0].children[1].textContent.replace(" ","").split("/")[0];
document.getElementsByClassName("html5-video-info-panel-content")[0].appendChild(a);

You will see a clickable link which will open the video in another tab

enter image description here


Javascript explanation

At the moment of write this, html of [Stats for nerds] was:

<div class="html5-video-info-panel" data-layer="4">
   <button class="html5-video-info-panel-close ytp-button" title="close">[x]</button>
   <div class="html5-video-info-panel-content">
      <div>
         <div>Video ID / sCPN</div>
         <span>I4VzIvGdTxI / GD6Y 2G9R N3W5</span>
      </div>
      <div>
         <div>Viewport / Frames</div>
         <span>640x360 / 0 dropped of 1706</span>
      </div>   
      <!-- a lot of divs    -->
   </div>
</div>

As you can see, our id is inside of span which is the second child of first child of div with class html5-video-info-panel-content.

Jquery help us to get the span value:

$(".html5-video-info-panel-content").children[0].children[1]

Then we need to delete empty spaces and split to get our video id:

.textContent.replace(" ","").split("/")[0]

Finally we concatenate this value to

"https://www.youtube.com/watch?v="

Manual mode

  • Right click on the video ad while it is playing.
  • Select [Copy Debug Info].
  • Then open any text editing program like Notepad in Windows and paste it there.
  • Search the pasted text for the line that says "ad_debug_videoId": "XXXXXXXXX"
  • The video url will be:
https://www.youtube.com/watch?v=XXXXXXXXX

References

OK. So, I've also been trying to do this...

After I mostly gave up, I right-clicked on the ad - and it offered to copy the 'video id.' For some reason - I just pasted that clipboard content into the url bar - and arrived at the youtube video of the advertisement. It might have been a fluke / but it worked that time. From there - I used one of those 'download from youtube' type sites (that are clearly trying to get you to install software - so be careful) - https://www.y2mate.com/ etc ---- and then I got the video.

( I haven't been able to do this since...) - but maybe it'll connect some dots for someone else - and you can explain why that happened.

UPDATE: It seems like it works sometimes... maybe certain ads are set up to be found. Here's some proof: https://vimeo.com/372764735

Related