1. 找到影片ID。
2. 組合出正確影片網址:
1. Go to Skool.com and find the video you want to download.
2. Open your browser’s console (right-click - inspect - console).
3. Paste the script I provide in the console and press return.
4. Make sure the page fully loads to ensure the script finds the video.
5. Copy the generated yt-dlp command.
6. Open your terminal and run the command to download the video.
7. Let the download finish – it’s that easy!
8. Find the .webm file on your desktop and play it in your browser, or convert it to mp4 if you want.
程式碼:
-----------------------------------------------------------------------------------------------------
// Extract all lesson URLs from Skool classroom - paste in browser console
function extractAllLessonUrls() {
console.log("🔍 Searching for lesson URLs on this page...");
const urls = new Set();
// Dynamically get base URL from current page
const currentUrl = new URL(window.location.href);
const baseUrl = `${currentUrl.protocol}//${currentUrl.host}${currentUrl.pathname}`;
console.log(`📍 Auto-detected base URL: ${baseUrl}`);
console.log(`🌐 Current full URL: ${window.location.href}`);
// Method 1: Look for direct links with md= parameters
document.querySelectorAll('a[href*="classroom"]').forEach(link => {
if (link.href.includes('md=')) {
urls.add(link.href);
console.log("Found link:", link.href);
}
});
// Method 2: Look for any links containing md= in any attribute
document.querySelectorAll('*').forEach(el => {
// Check onclick handlers
const onclick = el.getAttribute('onclick');
if (onclick && onclick.includes('md=')) {
const mdMatch = onclick.match(/md=([a-f0-9]+)/);
if (mdMatch) {
const url = `${baseUrl}?md=${mdMatch[1]}`;
urls.add(url);
console.log("Found in onclick:", url);
}
}
// Check data attributes
['data-href', 'data-url', 'data-link', 'data-md'].forEach(attr => {
const value = el.getAttribute(attr);
if (value && value.includes('md=')) {
if (value.startsWith('http')) {
urls.add(value);
} else {
const mdMatch = value.match(/md=([a-f0-9]+)/);
if (mdMatch) {
const url = `${baseUrl}?md=${mdMatch[1]}`;
urls.add(url);
console.log(`Found in ${attr}:`, url);
}
}
}
});
// Check for md= in any attribute value
for (let attr of el.attributes) {
if (attr.value.includes('md=') && !attr.name.startsWith('data-react')) {
const mdMatch = attr.value.match(/md=([a-f0-9]+)/g);
if (mdMatch) {
mdMatch.forEach(match => {
const mdValue = match.replace('md=', '');
const url = `${baseUrl}?md=${mdValue}`;
urls.add(url);
console.log(`Found in ${attr.name}:`, url);
});
}
}
}
});
// Method 3: Look in page source/innerHTML for md= patterns
const pageSource = document.documentElement.innerHTML;
const mdMatches = pageSource.match(/md=([a-f0-9]{32})/g);
if (mdMatches) {
mdMatches.forEach(match => {
const mdValue = match.replace('md=', '');
const url = `${baseUrl}?md=${mdValue}`;
urls.add(url);
});
console.log(`Found ${mdMatches.length} md= patterns in page source`);
}
// Add current page URL if it has md=
if (window.location.href.includes('md=')) {
urls.add(window.location.href);
console.log("Added current page:", window.location.href);
}
const urlArray = Array.from(urls).sort();
console.log(`\n✅ Found ${urlArray.length} unique lesson URLs:`);
urlArray.forEach((url, index) => {
console.log(`${index + 1}. ${url}`);
});
if (urlArray.length === 0) {
console.log("\n❌ No lesson URLs found!");
console.log("💡 Try running this from the main classroom navigation page");
console.log("💡 Or manually add URLs to the list below");
// Add current URL as fallback
urlArray.push(window.location.href);
}
// Create urls.txt file and download it
const urlText = urlArray.join('\n');
const blob = new Blob([urlText], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'urls.txt';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
console.log("\n📁 Downloaded urls.txt with all found URLs");
console.log("📝 Next steps:");
console.log("1. Check the downloaded urls.txt file");
console.log("2. Add any missing URLs manually if needed");
console.log("3. Use: wget --input-file=urls.txt [other options]");
return urlArray;
}
// Run the extraction
extractAllLessonUrls();
--------------------------------------------------------------------------------------------------
參考以下影片。
https://www.youtube.com/watch?v=YH-oF2cWoDI
https://blog.devinschumacher.com/how-to-download-skoolcom-videos-wget
沒有留言:
張貼留言