Monday, 1 June 2020

Export YouTube Playlist to Excel using Excel Macro

Are you learning from YouTube videos and finding it difficult to track the progress? What if there is a way to extract all the video titles along with their duration into Excel and track their progress. Wouldn't that be easy !!!
Here is a simple Excel Macro to do just that.



Enter your Playlist ID in the Cell A2 (Sheet 'Playlist') and click on the button. Video titles alongwith their duration are extracted into 'Videos' sheet.

Note: This Macro uses InternetExplorer object.

You can find the Playlist ID in the YouTube URL. The value that comes after the keyword 'list='

For Example, the URL can be in the below formats:
https://www.youtube.com/playlist?list=PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3

https://www.youtube.com/watch?v=QXeEoD0pB3E&list=PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3&index=1

In the above URLs, the Playlist ID is:
PLsyeobzWxl7poL9JTVyndKe62ieoN-MZ3

Ignore the '&' or anything that comes after '&' in the second URL.

If you want to understand the macro better, here is a brief outline of what it does.

1. Clear the 'Videos' sheet.
2. Copy the Playlist ID and append to the YouTube URL.
3. Open the URL in Internet Explorer.
4. If there are more than 100 videos in the playlist, we click on Load more button till all the videos are listed.
5. For the Table ID, we extract the rows using <tr> HTML tag.
6. For each row, we extract the Video Title and the Video Time.
Note that the Video Title also includes the Owner. So, we extract only the first part of the Video Title.
7. Close Internet Explorer.
8. Clear the Formats on the 'Videos' sheet and AutoFit the contents.

You can get the Macro here.

Note: The element ID might change at a later time. So, please be sure to update them.
1. Open the Internet Explorer browser and enter any YouTube playlist.
2. Press the F12 to open the DOM Explorer.
3. Click on the Select element icon and take it to any video title on the playlist.
4. Video Title is displayed as <td class="pl-video-title">

No comments:

Post a Comment