Last active
April 7, 2024 23:38
-
-
Save lihuelworks/63c857ded1c13887093588e537070396 to your computer and use it in GitHub Desktop.
Bookmarklet - recover private/deleted video video via Wayback Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function() { | |
var ytUrl = window.location.href; | |
var useVideoId = false; | |
if (ytUrl.includes("youtube.com") || ytUrl.includes("youtu.be")) { | |
var useVideoIdInput = confirm("Do you want to use the video ID of the current YouTube video?"); | |
if (useVideoIdInput) { | |
useVideoId = true; | |
} | |
} | |
var inputUrl; | |
if (useVideoId) { | |
inputUrl = "https://web.archive.org/web/20130720113437oe_/http://wayback-fakeurl.archive.org/yt/"; | |
var videoId = getYouTubeVideoId(ytUrl); | |
if (videoId !== null) { | |
inputUrl += videoId; | |
} else { | |
alert("Failed to extract video ID."); | |
return; | |
} | |
} else { | |
var inputUrl = prompt("Please enter the URL:"); | |
if (inputUrl === null || inputUrl.trim() === "") { | |
return; | |
} | |
if (inputUrl.includes("youtube.com") || inputUrl.includes("youtu.be")) { | |
var useVideoIdInput = confirm("Do you want to use the video ID of the provided YouTube video?"); | |
if (useVideoIdInput) { | |
var videoId = getYouTubeVideoId(inputUrl); | |
if (videoId !== null) { | |
inputUrl = "https://web.archive.org/web/20130720113437oe_/http://wayback-fakeurl.archive.org/yt/" + videoId; | |
} else { | |
alert("Failed to extract video ID from the provided URL."); | |
return; | |
} | |
} else { | |
inputUrl = "https://web.archive.org/web/20130720113437oe_/http://wayback-fakeurl.archive.org/yt/" + inputUrl; | |
} | |
} else { | |
inputUrl = "https://web.archive.org/web/20130720113437oe_/http://wayback-fakeurl.archive.org/yt/" + inputUrl; | |
} | |
} | |
window.location.href = inputUrl; | |
function getYouTubeVideoId(url) { | |
var videoId = null; | |
if (url.includes("youtube.com")) { | |
var match = url.match(/[?&]v=([^?&]+)/); | |
if (match) { | |
videoId = match[1]; | |
} | |
} else if (url.includes("youtu.be")) { | |
var match = url.match(/youtu\.be\/([^?]+)/); | |
if (match) { | |
videoId = match[1]; | |
} | |
} | |
return videoId; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: This tool is NOT foolproof, it depends exclusively if someone has made a snapshot into the Wayback Machine before. So, if you like a video a lot, be sure to put it in the Wayback Machine. Be kind, archive.
NOTE 2: If you're unlucky, you may get the video but not the audio. Happened to me for a single video of the many I've tried, but just keep that in mind.
This Bookmarklet (i.e bookmark that you click and does stuff) is made so it appends a youtub. While trying to backup my favorites playlist
Original idea goes to this specific reddit comment that shared it (Thanks colethedj, wherever you are)
If you want a less bookmark-y solution, also check from the this tool from the same thread (thanks TheHopeOfItAll_): https://www.waybackyt.download/