Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alicanatas/a47eb1fe14c2f23c6a3e6febb01fa25c to your computer and use it in GitHub Desktop.
Save alicanatas/a47eb1fe14c2f23c6a3e6febb01fa25c to your computer and use it in GitHub Desktop.
YouTube oynatma listesi sayfasında tüm videoları listeleyen kod
// YouTube oynatma listesi sayfasında tüm videoları listeleyen kod
// Kullanım: YouTube playlist sayfasında tarayıcı konsolunda çalıştırın
function extractPlaylistVideos() {
// Video elementlerini seç
const videoElements = document.querySelectorAll('ytd-playlist-video-renderer');
if (videoElements.length === 0) {
console.log('Video bulunamadı. YouTube playlist sayfasında olduğunuzdan emin olun.');
return;
}
const videos = [];
videoElements.forEach((element, index) => {
// Video başlığını al
const titleElement = element.querySelector('#video-title');
const title = titleElement ? titleElement.textContent.trim() : 'Başlık bulunamadı';
// Video linkini al
const linkElement = element.querySelector('#video-title');
let videoUrl = 'Link bulunamadı';
if (linkElement && linkElement.href) {
videoUrl = linkElement.href;
}
videos.push({
index: index + 1,
title: title,
url: videoUrl
});
});
// Sonuçları konsola yazdır
console.log('=== YOUTUBE PLAYLIST VİDEOLARI ===');
console.log(`Toplam ${videos.length} video bulundu:\n`);
videos.forEach(video => {
console.log(`${video.index}. ${video.title}`);
console.log(` Link: ${video.url}\n`);
});
// JSON formatında da döndür
return videos;
}
// Alternatif fonksiyon - Daha detaylı bilgiler için
function extractPlaylistVideosDetailed() {
const videoElements = document.querySelectorAll('ytd-playlist-video-renderer');
if (videoElements.length === 0) {
console.log('Video bulunamadı.');
return;
}
const videos = [];
videoElements.forEach((element, index) => {
// Başlık
const titleElement = element.querySelector('#video-title');
const title = titleElement ? titleElement.textContent.trim() : 'Başlık yok';
// Link
const linkElement = element.querySelector('#video-title');
const videoUrl = linkElement ? linkElement.href : 'Link yok';
// Kanal adı
const channelElement = element.querySelector('#channel-name a');
const channelName = channelElement ? channelElement.textContent.trim() : 'Kanal bilgisi yok';
// Video süresi
const durationElement = element.querySelector('ytd-thumbnail-overlay-time-status-renderer span');
const duration = durationElement ? durationElement.textContent.trim() : 'Süre bilgisi yok';
videos.push({
index: index + 1,
title: title,
url: videoUrl,
channel: channelName,
duration: duration
});
});
console.log('=== DETAYLI PLAYLIST BİLGİLERİ ===');
console.log(`Toplam ${videos.length} video:\n`);
videos.forEach(video => {
console.log(`${video.index}. ${video.title}`);
console.log(` Kanal: ${video.channel}`);
console.log(` Süre: ${video.duration}`);
console.log(` Link: ${video.url}\n`);
});
return videos;
}
// CSV formatında dışa aktarma fonksiyonu
function exportToCSV() {
const videos = extractPlaylistVideos();
if (!videos || videos.length === 0) return;
let csv = 'Sıra,Başlık,Link\n';
videos.forEach(video => {
// CSV için özel karakterleri temizle
const cleanTitle = video.title.replace(/"/g, '""');
csv += `${video.index},"${cleanTitle}","${video.url}"\n`;
});
// CSV dosyasını indir
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.setAttribute('href', url);
link.setAttribute('download', 'youtube_playlist.csv');
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
console.log('CSV dosyası indirildi: youtube_playlist.csv');
}
// Kullanım talimatları
console.log(`
=== KULLANIM TALİMATLARI ===
1. Temel kullanım:
extractPlaylistVideos()
2. Detaylı bilgiler için:
extractPlaylistVideosDetailed()
3. CSV dosyası olarak indirmek için:
exportToCSV()
NOT: Bu kodları YouTube playlist sayfasında çalıştırın.
`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment