Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37849474e3 | ||
|
|
2b48dce79b | ||
|
|
875ee098bd | ||
|
|
d8e87f29d5 |
@@ -2283,15 +2283,33 @@ try {
|
|||||||
|
|
||||||
function sanitizeWatchPageLabels(videoTitle) {
|
function sanitizeWatchPageLabels(videoTitle) {
|
||||||
// 1. Next Video button in Video.js control bar
|
// 1. Next Video button in Video.js control bar
|
||||||
|
var firstRec =
|
||||||
|
typeof window.__yaktube_get_first_smart_rec === 'function' ? window.__yaktube_get_first_smart_rec() : null;
|
||||||
|
var nextLabel =
|
||||||
|
firstRec && firstRec.title
|
||||||
|
? 'Sonraki Video (İlk Öneri): ' + firstRec.title + ' (Shift+N)'
|
||||||
|
: 'Sonraki Video (Shift+N)';
|
||||||
var nextBtns = document.querySelectorAll(
|
var nextBtns = document.querySelectorAll(
|
||||||
'.vjs-next-video-control, .vjs-next-control, button[title*="Next video"], button[aria-label*="Next video"]'
|
'.vjs-next-video, .vjs-next-video-control, .vjs-next-control, button[title*="Next video"], button[aria-label*="Next video"]'
|
||||||
);
|
);
|
||||||
nextBtns.forEach(function (btn) {
|
nextBtns.forEach(function (btn) {
|
||||||
btn.setAttribute('aria-label', 'Sonraki Video (Shift+N)');
|
if (
|
||||||
btn.setAttribute('title', 'Sonraki Video (Shift+N)');
|
firstRec &&
|
||||||
|
!(typeof window.__yaktube_is_playlist_watch === 'function' && window.__yaktube_is_playlist_watch())
|
||||||
|
) {
|
||||||
|
btn.classList.remove('vjs-disabled');
|
||||||
|
btn.classList.remove('vjs-hidden');
|
||||||
|
btn.removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
if (btn.getAttribute('aria-label') !== nextLabel) {
|
||||||
|
btn.setAttribute('aria-label', nextLabel);
|
||||||
|
}
|
||||||
|
if (btn.getAttribute('title') !== nextLabel) {
|
||||||
|
btn.setAttribute('title', nextLabel);
|
||||||
|
}
|
||||||
var ctrlText = btn.querySelector('.vjs-control-text');
|
var ctrlText = btn.querySelector('.vjs-control-text');
|
||||||
if (ctrlText && ctrlText.textContent.includes('Next video')) {
|
if (ctrlText && ctrlText.textContent !== nextLabel) {
|
||||||
ctrlText.textContent = 'Sonraki Video (Shift+N)';
|
ctrlText.textContent = nextLabel;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2769,11 +2787,18 @@ try {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift+N: Next Video
|
// Shift+N: Next Video (Smart First Recommendation)
|
||||||
if (e.shiftKey && (e.key === 'n' || e.key === 'N')) {
|
if (e.shiftKey && (e.key === 'n' || e.key === 'N')) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var nextBtn = document.querySelector('.vjs-next-video-control, .vjs-next-control');
|
if (
|
||||||
|
!(typeof window.__yaktube_is_playlist_watch === 'function' && window.__yaktube_is_playlist_watch()) &&
|
||||||
|
typeof window.__yaktube_play_next_smart__ === 'function'
|
||||||
|
) {
|
||||||
|
window.__yaktube_play_next_smart__('player-shortcut-shift-n');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var nextBtn = document.querySelector('.vjs-next-video, .vjs-next-video-control, .vjs-next-control');
|
||||||
if (nextBtn) {
|
if (nextBtn) {
|
||||||
nextBtn.click();
|
nextBtn.click();
|
||||||
announce('Sonraki videoya geçiliyor...');
|
announce('Sonraki videoya geçiliyor...');
|
||||||
@@ -2827,9 +2852,22 @@ try {
|
|||||||
bar.setAttribute('role', 'toolbar');
|
bar.setAttribute('role', 'toolbar');
|
||||||
bar.setAttribute('aria-label', 'Video Araçları ve Ek Özellikler');
|
bar.setAttribute('aria-label', 'Video Araçları ve Ek Özellikler');
|
||||||
|
|
||||||
|
var initialAutoPlay = true;
|
||||||
|
try {
|
||||||
|
initialAutoPlay = localStorage.getItem('yaktube_smart_autoplay') !== 'false';
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
bar.innerHTML =
|
bar.innerHTML =
|
||||||
'<span class="yaktube-player-bar-label">🛠️ Video Araçları:</span>' +
|
'<span class="yaktube-player-bar-label">🛠️ Video Araçları:</span>' +
|
||||||
'<button id="yaktube-bar-back-btn" class="yaktube-player-action-btn" aria-label="Önceki Sayfaya Geri Dön (Alt+Sol Ok)" title="Önceki Sayfaya Geri Dön (Alt+Sol Ok)">⬅️ Geri Dön</button>' +
|
'<button id="yaktube-bar-back-btn" class="yaktube-player-action-btn" aria-label="Önceki Sayfaya Geri Dön (Alt+Sol Ok)" title="Önceki Sayfaya Geri Dön (Alt+Sol Ok)">⬅️ Geri Dön</button>' +
|
||||||
|
'<button id="yaktube-bar-next-btn" class="yaktube-player-action-btn" aria-label="Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)" title="Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)">⏭️ Sonraki</button>' +
|
||||||
|
'<button id="yaktube-bar-autoplay-btn" class="yaktube-player-action-btn" role="switch" aria-checked="' +
|
||||||
|
(initialAutoPlay ? 'true' : 'false') +
|
||||||
|
'" aria-label="Akıllı Otomatik Oynatma: ' +
|
||||||
|
(initialAutoPlay ? 'Açık' : 'Kapalı') +
|
||||||
|
'" title="Video bittiğinde ilk öneriyi otomatik oynat">' +
|
||||||
|
(initialAutoPlay ? '🔁 Oto-Oynat: Açık' : '🔁 Oto-Oynat: Kapalı') +
|
||||||
|
'</button>' +
|
||||||
'<button id="yaktube-bar-speed-btn" class="yaktube-player-action-btn" aria-label="Oynatma Hızını Değiştir (Alt+.)">⚡ Hız</button>' +
|
'<button id="yaktube-bar-speed-btn" class="yaktube-player-action-btn" aria-label="Oynatma Hızını Değiştir (Alt+.)">⚡ Hız</button>' +
|
||||||
'<button id="yaktube-bar-sleep-btn" class="yaktube-player-action-btn" aria-label="Uyku Zamanlayıcısı (Alt+U)">⏱️ Uyku</button>' +
|
'<button id="yaktube-bar-sleep-btn" class="yaktube-player-action-btn" aria-label="Uyku Zamanlayıcısı (Alt+U)">⏱️ Uyku</button>' +
|
||||||
'<button id="yaktube-bar-qr-btn" class="yaktube-player-action-btn" aria-label="Telefonda Devam Et / QR Kod (Alt+Q)">📱 Telefonda Aç</button>' +
|
'<button id="yaktube-bar-qr-btn" class="yaktube-player-action-btn" aria-label="Telefonda Devam Et / QR Kod (Alt+Q)">📱 Telefonda Aç</button>' +
|
||||||
@@ -2870,6 +2908,24 @@ try {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nextBarBtn = bar.querySelector('#yaktube-bar-next-btn');
|
||||||
|
if (nextBarBtn) {
|
||||||
|
nextBarBtn.addEventListener('click', function () {
|
||||||
|
if (typeof window.__yaktube_play_next_smart__ === 'function') {
|
||||||
|
window.__yaktube_play_next_smart__('action-bar-next');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var autoPlayBarBtn = bar.querySelector('#yaktube-bar-autoplay-btn');
|
||||||
|
if (autoPlayBarBtn) {
|
||||||
|
autoPlayBarBtn.addEventListener('click', function () {
|
||||||
|
if (typeof window.__yaktube_toggle_smart_autoplay__ === 'function') {
|
||||||
|
window.__yaktube_toggle_smart_autoplay__();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bar.querySelector('#yaktube-bar-speed-btn').addEventListener('click', function () {
|
bar.querySelector('#yaktube-bar-speed-btn').addEventListener('click', function () {
|
||||||
adjustPlaybackSpeed(true);
|
adjustPlaybackSpeed(true);
|
||||||
});
|
});
|
||||||
@@ -3147,6 +3203,19 @@ try {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
adjustPlaybackSpeed(false);
|
adjustPlaybackSpeed(false);
|
||||||
}
|
}
|
||||||
|
// Next Video: Shift+N or Alt+N (Plays #1 Smart Recommendation)
|
||||||
|
else if ((e.shiftKey && key === 'n') || (alt && key === 'n')) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (
|
||||||
|
!(typeof window.__yaktube_is_playlist_watch === 'function' && window.__yaktube_is_playlist_watch()) &&
|
||||||
|
typeof window.__yaktube_play_next_smart__ === 'function'
|
||||||
|
) {
|
||||||
|
window.__yaktube_play_next_smart__('global-shortcut-shift-n');
|
||||||
|
} else {
|
||||||
|
var nextBtnGlobal = document.querySelector('.vjs-next-video, .vjs-next-video-control, .vjs-next-control');
|
||||||
|
if (nextBtnGlobal) nextBtnGlobal.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
// Percentage Jumps (0 - 9)
|
// Percentage Jumps (0 - 9)
|
||||||
else if (key >= '0' && key <= '9' && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
else if (key >= '0' && key <= '9' && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -3615,6 +3684,7 @@ try {
|
|||||||
var cachedGuestImportLimit = null;
|
var cachedGuestImportLimit = null;
|
||||||
var cachedCategories = null;
|
var cachedCategories = null;
|
||||||
var cachedSmartPrefetchMode = 'auto-when-no-local';
|
var cachedSmartPrefetchMode = 'auto-when-no-local';
|
||||||
|
var cachedFederatedRecommendationsMode = 'smart-relevant';
|
||||||
|
|
||||||
function fetchGuestImportLimit() {
|
function fetchGuestImportLimit() {
|
||||||
if (cachedGuestImportLimit !== null && cachedCategories !== null) {
|
if (cachedGuestImportLimit !== null && cachedCategories !== null) {
|
||||||
@@ -3631,6 +3701,9 @@ try {
|
|||||||
if (d && typeof d.smartPrefetchMode === 'string') {
|
if (d && typeof d.smartPrefetchMode === 'string') {
|
||||||
cachedSmartPrefetchMode = d.smartPrefetchMode;
|
cachedSmartPrefetchMode = d.smartPrefetchMode;
|
||||||
}
|
}
|
||||||
|
if (d && typeof d.federatedRecommendationsMode === 'string') {
|
||||||
|
cachedFederatedRecommendationsMode = d.federatedRecommendationsMode;
|
||||||
|
}
|
||||||
if (d && Array.isArray(d.categories) && d.categories.length > 0) {
|
if (d && Array.isArray(d.categories) && d.categories.length > 0) {
|
||||||
cachedCategories = d.categories;
|
cachedCategories = d.categories;
|
||||||
try {
|
try {
|
||||||
@@ -4247,10 +4320,20 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!data || !data.ok) {
|
if (!data || !data.ok) {
|
||||||
throw new Error(data && data.error ? data.error : 'İçe aktarma başlatılamadı.');
|
throw new Error(
|
||||||
|
(data && (data.userMessage || data.error)) || 'İçe aktarma başlatılamadı. Lütfen tekrar deneyin.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loggedIn) {
|
if (data.alreadyImported && data.video && data.video.uuid) {
|
||||||
|
showModal('🎉 Video Hazır!', 'Bu video zaten sunucumuzda mevcut. Oynatıcı açılıyor...');
|
||||||
|
setTimeout(function () {
|
||||||
|
window.location.href = '/videos/watch/' + data.video.uuid;
|
||||||
|
}, 350);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!loggedIn && !data.inProgress) {
|
||||||
incrementGuestImportCount();
|
incrementGuestImportCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4258,14 +4341,18 @@ try {
|
|||||||
var videoUuid = data.video.uuid;
|
var videoUuid = data.video.uuid;
|
||||||
|
|
||||||
var attempts = 0;
|
var attempts = 0;
|
||||||
|
var isRequestInFlight = false;
|
||||||
var pollInterval = setInterval(function () {
|
var pollInterval = setInterval(function () {
|
||||||
|
if (isRequestInFlight) return;
|
||||||
attempts++;
|
attempts++;
|
||||||
|
isRequestInFlight = true;
|
||||||
fetchPluginJson('/status/' + videoId)
|
fetchPluginJson('/status/' + videoId)
|
||||||
.then(function (sData) {
|
.then(function (sData) {
|
||||||
|
isRequestInFlight = false;
|
||||||
if (sData.isImporting) {
|
if (sData.isImporting) {
|
||||||
showModal(
|
showModal(
|
||||||
'[1/2] 📥 Video İndiriliyor...',
|
'[1/2] 📥 Video İndiriliyor...',
|
||||||
'Video sunucuya indiriliyor (' + attempts * 2 + ' sn)...'
|
'Video yüksek hızla sunucuya indiriliyor (' + Math.round(attempts * 1.5) + ' sn)...'
|
||||||
);
|
);
|
||||||
} else if (sData.isTranscoding) {
|
} else if (sData.isTranscoding) {
|
||||||
showModal(
|
showModal(
|
||||||
@@ -4274,43 +4361,45 @@ try {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sData.isPublished || (sData.hasFiles && attempts >= 8)) {
|
if (sData.isPublished) {
|
||||||
clearInterval(pollInterval);
|
clearInterval(pollInterval);
|
||||||
showModal('🎉 Video Hazır!', 'Video kütüphanenize eklendi. Oynatıcı açılıyor...');
|
showModal('🎉 Video Hazır!', 'Video kütüphanenize eklendi. Oynatıcı açılıyor...');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.location.href = '/videos/watch/' + (sData.uuid || videoUuid);
|
window.location.href = '/videos/watch/' + (sData.uuid || videoUuid);
|
||||||
}, 600);
|
}, 400);
|
||||||
} else if (sData.isFailed) {
|
} else if (sData.isFailed) {
|
||||||
clearInterval(pollInterval);
|
clearInterval(pollInterval);
|
||||||
hideModal();
|
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
||||||
alert('Video indirme sırasında bir hata oluştu.');
|
var failMsg =
|
||||||
announce('Video indirme sırasında bir hata oluştu.', true);
|
sData.errorMessage ||
|
||||||
|
"Bu video şu anda YouTube'dan aktarılamadı. Lütfen tekrar deneyin veya başka bir video seçin.";
|
||||||
|
showModal('⚠️ Video Aktarma Hatası', failMsg);
|
||||||
|
announce(failMsg, true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
|
isRequestInFlight = false;
|
||||||
console.error('[YakTube] Status poll error:', e);
|
console.error('[YakTube] Status poll error:', e);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (attempts > 35) {
|
if (attempts > 120) {
|
||||||
clearInterval(pollInterval);
|
clearInterval(pollInterval);
|
||||||
hideModal();
|
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
||||||
alert(
|
var bgMsg =
|
||||||
'İndirme arka planda tamamlanıyor. Ana sayfada veya Videolarım sayfasında kısa süre içinde hazır olacaktır.'
|
'Bu video uzun süreli olduğu için arka planda indirilmeye devam ediyor. Kısa süre içinde hazır olacaktır.';
|
||||||
);
|
showModal('⏳ Arka Planda Tamamlanıyor', bgMsg);
|
||||||
announce('İndirme arka planda tamamlanıyor. Ana sayfada kısa süre içinde hazır olacaktır.');
|
announce(bgMsg);
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
hideModal();
|
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
btn.innerHTML = '📥 ' + escapeHtml(getInstanceName()) + "'a Aktar & İzle";
|
||||||
alert('İndirme hatası: ' + err.message);
|
var errMsg = (err && err.message) || 'Video aktarılırken beklenmeyen bir hata oluştu.';
|
||||||
announce('İndirme hatası: ' + err.message, true);
|
showModal('⚠️ Video Aktarma Hatası', errMsg);
|
||||||
|
announce('İndirme hatası: ' + errMsg, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -5690,6 +5779,172 @@ try {
|
|||||||
return interests.slice(0, 8);
|
return interests.slice(0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var showNativeFediverseDrawer = false;
|
||||||
|
|
||||||
|
function isPlaylistWatch() {
|
||||||
|
if (typeof window === 'undefined' || !window.location) return false;
|
||||||
|
var p = window.location.pathname || '';
|
||||||
|
var s = window.location.search || '';
|
||||||
|
return p.includes('/w/p/') || s.includes('playlistPosition=') || s.includes('videoPlaylist=');
|
||||||
|
}
|
||||||
|
window.__yaktube_is_playlist_watch = isPlaylistWatch;
|
||||||
|
|
||||||
|
function isYakTubeAutoplayEnabled() {
|
||||||
|
try {
|
||||||
|
return localStorage.getItem('yaktube_smart_autoplay') !== 'false';
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setYakTubeAutoplayEnabled(enabled) {
|
||||||
|
var val = Boolean(enabled);
|
||||||
|
try {
|
||||||
|
localStorage.setItem('yaktube_smart_autoplay', val ? 'true' : 'false');
|
||||||
|
} catch (e) {}
|
||||||
|
syncPlayerNextButtonAndAutoplayUI();
|
||||||
|
var relContainer = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (relContainer && cachedRelatedResults && cachedRelatedResults.length > 0) {
|
||||||
|
renderRelatedCards(relContainer, cachedRelatedResults, cachedRelatedQuery);
|
||||||
|
}
|
||||||
|
announce(
|
||||||
|
val
|
||||||
|
? 'Akıllı otomatik oynatma açıldı. Video bittiğinde ilk öneri otomatik oynatılacak.'
|
||||||
|
: 'Akıllı otomatik oynatma kapatıldı.'
|
||||||
|
);
|
||||||
|
showQuickToast(val ? '🔁 Otomatik Oynatma: Açık' : '🔁 Otomatik Oynatma: Kapalı');
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleYakTubeAutoplay() {
|
||||||
|
setYakTubeAutoplayEnabled(!isYakTubeAutoplayEnabled());
|
||||||
|
}
|
||||||
|
window.__yaktube_toggle_smart_autoplay__ = toggleYakTubeAutoplay;
|
||||||
|
|
||||||
|
function getFirstSmartRecommendation() {
|
||||||
|
if (cachedRelatedResults && cachedRelatedResults.length > 0 && cachedRelatedResults[0]) {
|
||||||
|
return cachedRelatedResults[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
window.__yaktube_get_first_smart_rec = getFirstSmartRecommendation;
|
||||||
|
|
||||||
|
function playFirstSmartRecommendation(triggerSource) {
|
||||||
|
clearUpNextOverlay();
|
||||||
|
var nextItem = getFirstSmartRecommendation();
|
||||||
|
if (!nextItem) {
|
||||||
|
announce('Henüz sıradaki öneri hazır değil.');
|
||||||
|
showQuickToast('⏳ Öneriler yükleniyor...');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextItem.isDownloaded && nextItem.localVideo && nextItem.localVideo.url) {
|
||||||
|
announce('Sıradaki ilk öneri oynatılıyor: ' + (nextItem.title || ''));
|
||||||
|
showQuickToast('⏭️ ' + (nextItem.title || 'Sıradaki Video'));
|
||||||
|
currentActiveVideoKey = null;
|
||||||
|
window.location.href = nextItem.localVideo.url;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextItem.url) {
|
||||||
|
announce(
|
||||||
|
'Sıradaki ilk öneri ' + getInstanceName() + "'a aktarılıp hemen oynatılıyor: " + (nextItem.title || '')
|
||||||
|
);
|
||||||
|
showQuickToast('📥 İlk öneri hazırlanıp oynatılıyor...');
|
||||||
|
var existingCardBtn = null;
|
||||||
|
var relContainer = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (relContainer) {
|
||||||
|
existingCardBtn = relContainer.querySelector('.yaktube-related-import');
|
||||||
|
}
|
||||||
|
var targetBtn = existingCardBtn || document.createElement('button');
|
||||||
|
handleImport(nextItem.url, targetBtn, nextItem.title || 'Sıradaki Video');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
window.__yaktube_play_next_smart__ = playFirstSmartRecommendation;
|
||||||
|
|
||||||
|
function syncPlayerNextButtonAndAutoplayUI() {
|
||||||
|
var firstRec = getFirstSmartRecommendation();
|
||||||
|
var autoOn = isYakTubeAutoplayEnabled();
|
||||||
|
|
||||||
|
var barAutoBtn = document.getElementById('yaktube-bar-autoplay-btn');
|
||||||
|
if (barAutoBtn) {
|
||||||
|
barAutoBtn.setAttribute('aria-checked', autoOn ? 'true' : 'false');
|
||||||
|
barAutoBtn.setAttribute('aria-label', 'Akıllı Otomatik Oynatma: ' + (autoOn ? 'Açık' : 'Kapalı'));
|
||||||
|
barAutoBtn.textContent = autoOn ? '🔁 Oto-Oynat: Açık' : '🔁 Oto-Oynat: Kapalı';
|
||||||
|
}
|
||||||
|
|
||||||
|
var barNextBtn = document.getElementById('yaktube-bar-next-btn');
|
||||||
|
if (barNextBtn) {
|
||||||
|
var barNextLabel =
|
||||||
|
firstRec && firstRec.title
|
||||||
|
? 'Sıradaki İlk Öneri: ' + firstRec.title + ' (Shift+N)'
|
||||||
|
: 'Sıradaki İlk Önerilen Videoyu Oynat (Shift+N)';
|
||||||
|
barNextBtn.setAttribute('aria-label', barNextLabel);
|
||||||
|
barNextBtn.setAttribute('title', barNextLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isPlaylistWatch()) {
|
||||||
|
// Hide PeerTube's native Fediverse upnext overlay inside Video.js so YakTube Smart Autoplay handles it
|
||||||
|
var nativeUpNext = document.querySelectorAll('.vjs-upnext-content');
|
||||||
|
nativeUpNext.forEach(function (el) {
|
||||||
|
el.style.setProperty('display', 'none', 'important');
|
||||||
|
el.setAttribute('aria-hidden', 'true');
|
||||||
|
});
|
||||||
|
|
||||||
|
var nextBtns = document.querySelectorAll('.vjs-next-video, .vjs-next-video-control, .vjs-next-control');
|
||||||
|
nextBtns.forEach(function (btn) {
|
||||||
|
if (firstRec) {
|
||||||
|
btn.classList.remove('vjs-disabled');
|
||||||
|
btn.classList.remove('vjs-hidden');
|
||||||
|
btn.removeAttribute('disabled');
|
||||||
|
var lbl = 'Sonraki Video (İlk Öneri): ' + (firstRec.title || '') + ' (Shift+N)';
|
||||||
|
btn.setAttribute('aria-label', lbl);
|
||||||
|
btn.setAttribute('title', lbl);
|
||||||
|
var ctrlTxt = btn.querySelector('.vjs-control-text');
|
||||||
|
if (ctrlTxt) ctrlTxt.textContent = lbl;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept clicks & keydowns on Video.js native ".vjs-next-video" button so it plays #1 Smart Recommendation instead of Fediverse
|
||||||
|
document.addEventListener(
|
||||||
|
'click',
|
||||||
|
function (e) {
|
||||||
|
if (!e.target || typeof e.target.closest !== 'function') return;
|
||||||
|
var nextBtn = e.target.closest(
|
||||||
|
'.vjs-next-video, .vjs-next-video-control, .vjs-next-control, .vjs-upnext-autoplay-icon'
|
||||||
|
);
|
||||||
|
if (nextBtn && !isPlaylistWatch() && getFirstSmartRecommendation()) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
playFirstSmartRecommendation('vjs-next-button');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
document.addEventListener(
|
||||||
|
'keydown',
|
||||||
|
function (e) {
|
||||||
|
if (e.key !== 'Enter' && e.key !== ' ') return;
|
||||||
|
if (!e.target || typeof e.target.closest !== 'function') return;
|
||||||
|
var nextBtn = e.target.closest(
|
||||||
|
'.vjs-next-video, .vjs-next-video-control, .vjs-next-control, .vjs-upnext-autoplay-icon'
|
||||||
|
);
|
||||||
|
if (nextBtn && !isPlaylistWatch() && getFirstSmartRecommendation()) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
e.stopImmediatePropagation();
|
||||||
|
playFirstSmartRecommendation('vjs-next-button-key');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
function suppressUnrelatedNativeRecommendations() {
|
function suppressUnrelatedNativeRecommendations() {
|
||||||
try {
|
try {
|
||||||
// Prevent PeerTube's native player from auto-redirecting to unrelated foreign/federated videos on video end
|
// Prevent PeerTube's native player from auto-redirecting to unrelated foreign/federated videos on video end
|
||||||
@@ -5697,14 +5952,25 @@ try {
|
|||||||
sessionStorage.setItem('auto-play-video', 'false');
|
sessionStorage.setItem('auto-play-video', 'false');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
syncPlayerNextButtonAndAutoplayUI();
|
||||||
|
|
||||||
|
var shouldShowNativeList =
|
||||||
|
cachedFederatedRecommendationsMode === 'show-all' ||
|
||||||
|
(cachedFederatedRecommendationsMode === 'smart-relevant' && showNativeFediverseDrawer);
|
||||||
|
|
||||||
var recContainers = document.querySelectorAll('my-recommended-videos, .other-videos, .video-watch-next');
|
var recContainers = document.querySelectorAll('my-recommended-videos, .other-videos, .video-watch-next');
|
||||||
recContainers.forEach(function (rec) {
|
recContainers.forEach(function (rec) {
|
||||||
Array.from(rec.children).forEach(function (child) {
|
Array.from(rec.children).forEach(function (child) {
|
||||||
if (child.id === 'yaktube-hybrid-related-container' || child.id === 'yaktube-upnext-overlay') {
|
if (child.id === 'yaktube-hybrid-related-container' || child.id === 'yaktube-upnext-overlay') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (shouldShowNativeList) {
|
||||||
|
child.style.removeProperty('display');
|
||||||
|
child.removeAttribute('aria-hidden');
|
||||||
|
} else {
|
||||||
child.style.setProperty('display', 'none', 'important');
|
child.style.setProperty('display', 'none', 'important');
|
||||||
child.setAttribute('aria-hidden', 'true');
|
child.setAttribute('aria-hidden', 'true');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -5723,18 +5989,29 @@ try {
|
|||||||
var displayed = results.slice(0, limit);
|
var displayed = results.slice(0, limit);
|
||||||
|
|
||||||
var cardsHtml = '';
|
var cardsHtml = '';
|
||||||
displayed.forEach(function (item) {
|
displayed.forEach(function (item, idx) {
|
||||||
var isLocal = !!item.isDownloaded;
|
var isLocal = !!item.isDownloaded;
|
||||||
var badgeLabel = item.reasonBadge || (isLocal ? '✅ ' + getInstanceName() + "'da İzle" : '🔥 Benzer İçerik');
|
var isFed = !!item.isFederated;
|
||||||
|
var isFirstRec = idx === 0;
|
||||||
|
var badgeLabel =
|
||||||
|
item.reasonBadge ||
|
||||||
|
(isFed ? "🌐 Fediverse'de İzle" : isLocal ? '✅ ' + getInstanceName() + "'da İzle" : '🔥 Benzer İçerik');
|
||||||
var isHistoryMatch = badgeLabel.indexOf('Geçmişinize Göre') !== -1;
|
var isHistoryMatch = badgeLabel.indexOf('Geçmişinize Göre') !== -1;
|
||||||
|
|
||||||
var badgeStyle = isLocal
|
var badgeStyle = isFed
|
||||||
|
? 'background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); color: #fff;'
|
||||||
|
: isLocal
|
||||||
? 'background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #fff;'
|
? 'background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #fff;'
|
||||||
: isHistoryMatch
|
: isHistoryMatch
|
||||||
? 'background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); color: #fff;'
|
? 'background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); color: #fff;'
|
||||||
: 'background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); color: #fff;';
|
: 'background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); color: #fff;';
|
||||||
|
|
||||||
|
var firstBadgeHtml = isFirstRec
|
||||||
|
? '<span class="yaktube-badge" style="background: #ff8f37; color: #000; margin-bottom: 4px; margin-right: 4px; display: inline-block; font-size:10px; padding:2px 7px; font-weight:800;">⏭️ İLK ÖNERİ</span>'
|
||||||
|
: '';
|
||||||
|
|
||||||
var statusBadge =
|
var statusBadge =
|
||||||
|
firstBadgeHtml +
|
||||||
'<span class="yaktube-badge" style="' +
|
'<span class="yaktube-badge" style="' +
|
||||||
badgeStyle +
|
badgeStyle +
|
||||||
' margin-bottom: 4px; display: inline-block; font-size:10px; padding:2px 8px; font-weight:700;">' +
|
' margin-bottom: 4px; display: inline-block; font-size:10px; padding:2px 8px; font-weight:700;">' +
|
||||||
@@ -5746,11 +6023,15 @@ try {
|
|||||||
isLocal && item.localVideo && item.localVideo.url
|
isLocal && item.localVideo && item.localVideo.url
|
||||||
? '<a href="' +
|
? '<a href="' +
|
||||||
escapeHtml(item.localVideo.url) +
|
escapeHtml(item.localVideo.url) +
|
||||||
'" class="yaktube-play-btn yaktube-related-play-link" style="font-size:11px; padding:6px 10px;" aria-label="' +
|
'" class="yaktube-play-btn yaktube-related-play-link" style="font-size:11px; padding:6px 10px;' +
|
||||||
|
(isFed ? ' background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); color:#fff;' : '') +
|
||||||
|
'" aria-label="' +
|
||||||
safeTitleAttr +
|
safeTitleAttr +
|
||||||
' videosunu ' +
|
' videosunu ' +
|
||||||
escapeHtml(getInstanceName()) +
|
(isFed ? 'Fediverse ağından' : escapeHtml(getInstanceName()) + "'dan") +
|
||||||
'\'dan hemen izle">▶️ Hemen İzle</a>'
|
' hemen izle">' +
|
||||||
|
(isFed ? "🌐 Fediverse'den İzle" : '▶️ Hemen İzle') +
|
||||||
|
'</a>'
|
||||||
: '<button class="yaktube-import-btn yaktube-related-import" data-yt-id="' +
|
: '<button class="yaktube-import-btn yaktube-related-import" data-yt-id="' +
|
||||||
escapeHtml(item.id || '') +
|
escapeHtml(item.id || '') +
|
||||||
'" data-url="' +
|
'" data-url="' +
|
||||||
@@ -5764,9 +6045,18 @@ try {
|
|||||||
'\'a indir ve izle">📥 İndir ve İzle</button>';
|
'\'a indir ve izle">📥 İndir ve İzle</button>';
|
||||||
|
|
||||||
var cardLabel =
|
var cardLabel =
|
||||||
item.title + ' (' + badgeLabel + '), ' + item.channel + ' kanalı, Süre: ' + (item.durationFormatted || '');
|
(isFirstRec ? 'İlk Öneri: ' : '') +
|
||||||
|
item.title +
|
||||||
|
' (' +
|
||||||
|
badgeLabel +
|
||||||
|
'), ' +
|
||||||
|
item.channel +
|
||||||
|
' kanalı, Süre: ' +
|
||||||
|
(item.durationFormatted || '');
|
||||||
cardsHtml +=
|
cardsHtml +=
|
||||||
'<div class="yaktube-card" role="article" tabindex="0" style="margin-bottom:10px;" aria-label="' +
|
'<div class="yaktube-card" role="article" tabindex="0" style="margin-bottom:10px;' +
|
||||||
|
(isFirstRec ? ' border: 1.5px solid rgba(255,143,55,0.65);' : '') +
|
||||||
|
'" aria-label="' +
|
||||||
cardLabel.replace(/"/g, '"') +
|
cardLabel.replace(/"/g, '"') +
|
||||||
'">' +
|
'">' +
|
||||||
'<div class="yaktube-thumb-wrap">' +
|
'<div class="yaktube-thumb-wrap">' +
|
||||||
@@ -5813,6 +6103,18 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fediverseDrawerBtn = '';
|
||||||
|
if (cachedFederatedRecommendationsMode === 'smart-relevant') {
|
||||||
|
fediverseDrawerBtn =
|
||||||
|
'<button id="yaktube-toggle-native-fediverse-btn" class="yaktube-shortcuts-btn" style="width:100%; margin-top:10px; padding:9px 12px; justify-content:center; font-size:12px; font-weight:600; background:rgba(14,165,233,0.1); border:1px solid rgba(14,165,233,0.35); color:#7dd3fc;" aria-expanded="' +
|
||||||
|
(showNativeFediverseDrawer ? 'true' : 'false') +
|
||||||
|
'" aria-label="Fediverse ağındaki diğer videoları göster veya gizle">' +
|
||||||
|
(showNativeFediverseDrawer
|
||||||
|
? '🔼 Fediverse Ağındaki Diğer Videoları Gizle'
|
||||||
|
: '🌐 Fediverse Ağındaki Diğer Videoları Göster (İsteğe Bağlı)') +
|
||||||
|
'</button>';
|
||||||
|
}
|
||||||
|
|
||||||
var headerCountText = count > 12 && !relatedShowAll ? displayed.length + ' / ' + count : count;
|
var headerCountText = count > 12 && !relatedShowAll ? displayed.length + ' / ' + count : count;
|
||||||
var prefetchStatusHtml = '';
|
var prefetchStatusHtml = '';
|
||||||
if (smartPrefetchState.videoKey === currentActiveVideoKey) {
|
if (smartPrefetchState.videoKey === currentActiveVideoKey) {
|
||||||
@@ -5825,6 +6127,11 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var autoPlayEnabled = isYakTubeAutoplayEnabled();
|
||||||
|
var autoPlayBtnStyle = autoPlayEnabled
|
||||||
|
? 'background:rgba(16,185,129,0.18); border-color:#10b981; color:#6ee7b7; font-weight:700;'
|
||||||
|
: 'background:rgba(148,163,184,0.12); border-color:rgba(148,163,184,0.35); color:#cbd5e1;';
|
||||||
|
|
||||||
container.innerHTML =
|
container.innerHTML =
|
||||||
'<div class="yaktube-header" style="flex-wrap:wrap; gap:8px;">' +
|
'<div class="yaktube-header" style="flex-wrap:wrap; gap:8px;">' +
|
||||||
'<div class="yaktube-header-left" style="flex-wrap:wrap; gap:8px;">' +
|
'<div class="yaktube-header-left" style="flex-wrap:wrap; gap:8px;">' +
|
||||||
@@ -5838,14 +6145,43 @@ try {
|
|||||||
')</h3>' +
|
')</h3>' +
|
||||||
prefetchStatusHtml +
|
prefetchStatusHtml +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
'<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">' +
|
||||||
|
'<button id="yaktube-related-play-first-btn" class="yaktube-shortcuts-btn" style="background:rgba(255,143,55,0.16); border-color:#ff8f37; color:#fff; font-weight:700;" aria-label="Sıradaki ilk önerilen videoyu oynat (Shift+N)" title="Sıradaki ilk önerilen videoyu oynat (Shift+N)">' +
|
||||||
|
'⏭️ İlk Öneriyi Oynat' +
|
||||||
|
'</button>' +
|
||||||
|
'<button id="yaktube-related-autoplay-btn" class="yaktube-shortcuts-btn" role="switch" aria-checked="' +
|
||||||
|
(autoPlayEnabled ? 'true' : 'false') +
|
||||||
|
'" style="' +
|
||||||
|
autoPlayBtnStyle +
|
||||||
|
'" aria-label="Akıllı Otomatik Oynatma: ' +
|
||||||
|
(autoPlayEnabled ? 'Açık' : 'Kapalı') +
|
||||||
|
'" title="Video bittiğinde ilk öneriyi otomatik oynat">' +
|
||||||
|
(autoPlayEnabled ? '🔁 Otomatik Oynat: Açık' : '🔁 Otomatik Oynat: Kapalı') +
|
||||||
|
'</button>' +
|
||||||
'<button id="yaktube-related-refresh-btn" class="yaktube-shortcuts-btn" aria-label="Önerileri Yenile">' +
|
'<button id="yaktube-related-refresh-btn" class="yaktube-shortcuts-btn" aria-label="Önerileri Yenile">' +
|
||||||
'🔄 Yenile' +
|
'🔄 Yenile' +
|
||||||
'</button>' +
|
'</button>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
'<div class="yaktube-grid" style="grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:12px;">' +
|
'<div class="yaktube-grid" style="grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap:12px;">' +
|
||||||
cardsHtml +
|
cardsHtml +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
loadMoreBtn;
|
loadMoreBtn +
|
||||||
|
fediverseDrawerBtn;
|
||||||
|
|
||||||
|
var playFirstBtn = document.getElementById('yaktube-related-play-first-btn');
|
||||||
|
if (playFirstBtn) {
|
||||||
|
playFirstBtn.addEventListener('click', function () {
|
||||||
|
playFirstSmartRecommendation('related-header-btn');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var autoPlayHeaderBtn = document.getElementById('yaktube-related-autoplay-btn');
|
||||||
|
if (autoPlayHeaderBtn) {
|
||||||
|
autoPlayHeaderBtn.addEventListener('click', function () {
|
||||||
|
toggleYakTubeAutoplay();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var toggleBtn = document.getElementById('yaktube-related-toggle-more');
|
var toggleBtn = document.getElementById('yaktube-related-toggle-more');
|
||||||
if (toggleBtn) {
|
if (toggleBtn) {
|
||||||
@@ -5858,6 +6194,20 @@ try {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var fedDrawerBtn = document.getElementById('yaktube-toggle-native-fediverse-btn');
|
||||||
|
if (fedDrawerBtn) {
|
||||||
|
fedDrawerBtn.addEventListener('click', function () {
|
||||||
|
showNativeFediverseDrawer = !showNativeFediverseDrawer;
|
||||||
|
suppressUnrelatedNativeRecommendations();
|
||||||
|
renderRelatedCards(container, cachedRelatedResults, cachedRelatedQuery);
|
||||||
|
announce(
|
||||||
|
showNativeFediverseDrawer
|
||||||
|
? 'Fediverse ağındaki diğer videolar gösteriliyor.'
|
||||||
|
: 'Fediverse ağındaki diğer videolar gizlendi.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var refreshBtn = document.getElementById('yaktube-related-refresh-btn');
|
var refreshBtn = document.getElementById('yaktube-related-refresh-btn');
|
||||||
if (refreshBtn) {
|
if (refreshBtn) {
|
||||||
refreshBtn.addEventListener('click', function () {
|
refreshBtn.addEventListener('click', function () {
|
||||||
@@ -5942,18 +6292,43 @@ try {
|
|||||||
}
|
}
|
||||||
var videoId = data.video.id;
|
var videoId = data.video.id;
|
||||||
var videoUuid = data.video.uuid;
|
var videoUuid = data.video.uuid;
|
||||||
|
|
||||||
|
if (data.alreadyImported && videoUuid) {
|
||||||
|
var immediateWatchUrl = '/videos/watch/' + videoUuid;
|
||||||
|
smartPrefetchState.status = 'ready';
|
||||||
|
smartPrefetchState.readyUrl = immediateWatchUrl;
|
||||||
|
smartHasLocalMatch = true;
|
||||||
|
cachedRelatedResults.forEach(function (it) {
|
||||||
|
if ((candidate.id && it.id === candidate.id) || (candidate.url && it.url === candidate.url)) {
|
||||||
|
it.isDownloaded = true;
|
||||||
|
it.reasonBadge = '⚡ Sıradaki Öneri Hazır';
|
||||||
|
it.localVideo = {
|
||||||
|
id: videoId,
|
||||||
|
uuid: videoUuid,
|
||||||
|
name: (data.video && data.video.name) || candidate.title,
|
||||||
|
url: immediateWatchUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var relC = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (relC && cachedRelatedResults.length > 0) {
|
||||||
|
renderRelatedCards(relC, cachedRelatedResults, cachedRelatedQuery);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var attempts = 0;
|
var attempts = 0;
|
||||||
|
|
||||||
smartPrefetchState.pollTimer = setInterval(function () {
|
smartPrefetchState.pollTimer = setInterval(function () {
|
||||||
attempts++;
|
attempts++;
|
||||||
if (currentActiveVideoKey !== videoKey || attempts > 45) {
|
if (currentActiveVideoKey !== videoKey || attempts > 90) {
|
||||||
clearInterval(smartPrefetchState.pollTimer);
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
smartPrefetchState.pollTimer = null;
|
smartPrefetchState.pollTimer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPluginJson('/status/' + videoId)
|
fetchPluginJson('/status/' + videoId)
|
||||||
.then(function (sData) {
|
.then(function (sData) {
|
||||||
if (sData && (sData.isPublished || (sData.hasFiles && attempts >= 8))) {
|
if (sData && sData.isPublished) {
|
||||||
clearInterval(smartPrefetchState.pollTimer);
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
smartPrefetchState.pollTimer = null;
|
smartPrefetchState.pollTimer = null;
|
||||||
var watchUrl = '/videos/watch/' + (sData.uuid || videoUuid);
|
var watchUrl = '/videos/watch/' + (sData.uuid || videoUuid);
|
||||||
@@ -5994,16 +6369,29 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkSmartPrefetchOnTimeUpdate(video) {
|
function checkSmartPrefetchOnTimeUpdate(video) {
|
||||||
if (!video || !currentActiveVideoKey || !smartPrefetchCandidate) return;
|
if (!video || !currentActiveVideoKey) return;
|
||||||
if (smartPrefetchState.videoKey === currentActiveVideoKey && smartPrefetchState.status !== 'idle') return;
|
if (smartPrefetchState.videoKey === currentActiveVideoKey && smartPrefetchState.status !== 'idle') return;
|
||||||
if (cachedSmartPrefetchMode === 'disabled') return;
|
if (cachedSmartPrefetchMode === 'disabled') return;
|
||||||
if (cachedSmartPrefetchMode === 'auto-when-no-local' && smartHasLocalMatch) return;
|
|
||||||
|
var firstRec = getFirstSmartRecommendation();
|
||||||
|
var firstNeedsPrefetch = Boolean(firstRec && !firstRec.isDownloaded && firstRec.url);
|
||||||
|
var targetCandidate = firstNeedsPrefetch ? firstRec : smartPrefetchCandidate;
|
||||||
|
if (!targetCandidate) return;
|
||||||
|
|
||||||
|
// If #1 recommendation is not downloaded yet and autoplay is enabled, always pre-fetch #1 so autoplay is instant!
|
||||||
|
if (
|
||||||
|
cachedSmartPrefetchMode === 'auto-when-no-local' &&
|
||||||
|
smartHasLocalMatch &&
|
||||||
|
!(firstNeedsPrefetch && isYakTubeAutoplayEnabled())
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var cur = video.currentTime || 0;
|
var cur = video.currentTime || 0;
|
||||||
var dur = video.duration || 0;
|
var dur = video.duration || 0;
|
||||||
var threshold = dur > 0 && dur < 65 ? Math.max(8, dur * 0.35) : 25;
|
var threshold = dur > 0 && dur < 65 ? Math.max(8, dur * 0.35) : 20;
|
||||||
if (cur >= threshold) {
|
if (cur >= threshold) {
|
||||||
triggerSilentBackgroundPrefetch(smartPrefetchCandidate, currentActiveVideoKey);
|
triggerSilentBackgroundPrefetch(targetCandidate, currentActiveVideoKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6020,19 +6408,16 @@ try {
|
|||||||
clearUpNextOverlay();
|
clearUpNextOverlay();
|
||||||
if (!cachedRelatedResults || cachedRelatedResults.length === 0) return;
|
if (!cachedRelatedResults || cachedRelatedResults.length === 0) return;
|
||||||
|
|
||||||
// Pick #1 ready local match first; otherwise #1 topic match
|
// Always pick the very first recommendation (#1 in Smart Recommendations)
|
||||||
var nextItem =
|
var nextItem = getFirstSmartRecommendation();
|
||||||
cachedRelatedResults.find(function (it) {
|
|
||||||
return it && it.isDownloaded && it.localVideo && it.localVideo.url;
|
|
||||||
}) || cachedRelatedResults[0];
|
|
||||||
|
|
||||||
if (!nextItem) return;
|
if (!nextItem) return;
|
||||||
|
|
||||||
var isReadyLocal = !!(nextItem.isDownloaded && nextItem.localVideo && nextItem.localVideo.url);
|
var isReadyLocal = !!(nextItem.isDownloaded && nextItem.localVideo && nextItem.localVideo.url);
|
||||||
|
var autoPlayOn = isYakTubeAutoplayEnabled();
|
||||||
var banner = document.createElement('div');
|
var banner = document.createElement('div');
|
||||||
banner.id = 'yaktube-upnext-overlay';
|
banner.id = 'yaktube-upnext-overlay';
|
||||||
banner.setAttribute('role', 'region');
|
banner.setAttribute('role', 'region');
|
||||||
banner.setAttribute('aria-label', 'Sıradaki İlgili Video Önerisi');
|
banner.setAttribute('aria-label', 'Sıradaki İlk Önerilen Video');
|
||||||
banner.style.cssText =
|
banner.style.cssText =
|
||||||
'margin: 14px 0 18px 0; padding: 16px 20px; border-radius: 14px; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); border: 2px solid #ff8f37; box-shadow: 0 10px 30px rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;';
|
'margin: 14px 0 18px 0; padding: 16px 20px; border-radius: 14px; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); border: 2px solid #ff8f37; box-shadow: 0 10px 30px rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;';
|
||||||
|
|
||||||
@@ -6050,7 +6435,7 @@ try {
|
|||||||
'" alt="" style="width:96px; height:56px; object-fit:cover; border-radius:8px; flex-shrink:0; border:1px solid rgba(255,255,255,0.15);" onerror="this.src=\'/client/assets/images/default-thumbnail.jpg\'" />' +
|
'" alt="" style="width:96px; height:56px; object-fit:cover; border-radius:8px; flex-shrink:0; border:1px solid rgba(255,255,255,0.15);" onerror="this.src=\'/client/assets/images/default-thumbnail.jpg\'" />' +
|
||||||
'<div style="min-width:0;">' +
|
'<div style="min-width:0;">' +
|
||||||
'<div style="display:flex; align-items:center; gap:8px; margin-bottom:4px; flex-wrap:wrap;">' +
|
'<div style="display:flex; align-items:center; gap:8px; margin-bottom:4px; flex-wrap:wrap;">' +
|
||||||
'<span style="background:#ff8f37; color:#000; font-size:11px; font-weight:800; padding:2px 8px; border-radius:6px;">⏭️ SIRADAKİ İLGİLİ VİDEO</span>' +
|
'<span style="background:#ff8f37; color:#000; font-size:11px; font-weight:800; padding:2px 8px; border-radius:6px;">⏭️ SIRADAKİ İLK ÖNERİ</span>' +
|
||||||
'<span style="font-size:11px; color:#5eead4; font-weight:600;">' +
|
'<span style="font-size:11px; color:#5eead4; font-weight:600;">' +
|
||||||
safeBadge +
|
safeBadge +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
@@ -6060,11 +6445,13 @@ try {
|
|||||||
'</div>' +
|
'</div>' +
|
||||||
'<div style="font-size:12px; color:#94a3b8; margin-top:2px;">' +
|
'<div style="font-size:12px; color:#94a3b8; margin-top:2px;">' +
|
||||||
safeChannel +
|
safeChannel +
|
||||||
(isReadyLocal
|
(autoPlayOn
|
||||||
? ' • <span id="yaktube-upnext-countdown-txt" style="color:#ff8f37; font-weight:700;">' +
|
? ' • <span id="yaktube-upnext-countdown-txt" style="color:#ff8f37; font-weight:700;">' +
|
||||||
secondsLeft +
|
secondsLeft +
|
||||||
' saniye içinde başlıyor...</span>'
|
' saniye içinde ' +
|
||||||
: '') +
|
(isReadyLocal ? 'başlıyor...' : 'otomatik aktarılıp başlıyor...') +
|
||||||
|
'</span>'
|
||||||
|
: ' • <span id="yaktube-upnext-countdown-txt" style="color:#94a3b8;">Otomatik oynatma kapalı</span>') +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
@@ -6075,7 +6462,7 @@ try {
|
|||||||
'" style="background:linear-gradient(135deg, #10b981 0%, #059669 100%); color:#fff; text-decoration:none; padding:10px 18px; border-radius:10px; font-weight:800; font-size:13px; display:inline-flex; align-items:center; gap:6px;">▶️ Hemen İzle</a>'
|
'" style="background:linear-gradient(135deg, #10b981 0%, #059669 100%); color:#fff; text-decoration:none; padding:10px 18px; border-radius:10px; font-weight:800; font-size:13px; display:inline-flex; align-items:center; gap:6px;">▶️ Hemen İzle</a>'
|
||||||
: '<button type="button" id="yaktube-upnext-import-btn" style="background:linear-gradient(135deg, #ff8f37 0%, #ea580c 100%); color:#000; border:none; padding:10px 18px; border-radius:10px; font-weight:800; font-size:13px; cursor:pointer; display:inline-flex; align-items:center; gap:6px;">📥 İndir ve Hemen İzle</button>') +
|
: '<button type="button" id="yaktube-upnext-import-btn" style="background:linear-gradient(135deg, #ff8f37 0%, #ea580c 100%); color:#000; border:none; padding:10px 18px; border-radius:10px; font-weight:800; font-size:13px; cursor:pointer; display:inline-flex; align-items:center; gap:6px;">📥 İndir ve Hemen İzle</button>') +
|
||||||
'<button type="button" id="yaktube-upnext-cancel-btn" style="background:#334155; color:#e2e8f0; border:1px solid rgba(255,255,255,0.15); padding:10px 14px; border-radius:10px; font-weight:600; font-size:12px; cursor:pointer;">' +
|
'<button type="button" id="yaktube-upnext-cancel-btn" style="background:#334155; color:#e2e8f0; border:1px solid rgba(255,255,255,0.15); padding:10px 14px; border-radius:10px; font-weight:600; font-size:12px; cursor:pointer;">' +
|
||||||
(isReadyLocal ? '✕ Otomatik Geçişi Durdur' : '✕ Kapat') +
|
(autoPlayOn ? '✕ Otomatik Geçişi Durdur' : '✕ Kapat') +
|
||||||
'</button>' +
|
'</button>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
@@ -6109,13 +6496,13 @@ try {
|
|||||||
if (importBtn) {
|
if (importBtn) {
|
||||||
importBtn.addEventListener('click', function () {
|
importBtn.addEventListener('click', function () {
|
||||||
clearUpNextOverlay();
|
clearUpNextOverlay();
|
||||||
handleImport(nextItem.url, importBtn, nextItem.title);
|
playFirstSmartRecommendation('upnext-banner-click');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReadyLocal) {
|
if (autoPlayOn) {
|
||||||
announce(
|
announce(
|
||||||
'Video sona erdi. Sıradaki ilgili video 6 saniye içinde başlayacak: ' +
|
'Video sona erdi. Sıradaki ilk önerilen video 6 saniye içinde başlayacak: ' +
|
||||||
nextItem.title +
|
nextItem.title +
|
||||||
'. Durdurmak için Otomatik Geçişi Durdur düğmesine basabilirsiniz.'
|
'. Durdurmak için Otomatik Geçişi Durdur düğmesine basabilirsiniz.'
|
||||||
);
|
);
|
||||||
@@ -6123,16 +6510,17 @@ try {
|
|||||||
secondsLeft--;
|
secondsLeft--;
|
||||||
var cdTxt = document.getElementById('yaktube-upnext-countdown-txt');
|
var cdTxt = document.getElementById('yaktube-upnext-countdown-txt');
|
||||||
if (cdTxt && secondsLeft > 0) {
|
if (cdTxt && secondsLeft > 0) {
|
||||||
cdTxt.textContent = secondsLeft + ' saniye içinde başlıyor...';
|
cdTxt.textContent =
|
||||||
|
secondsLeft + ' saniye içinde ' + (isReadyLocal ? 'başlıyor...' : 'otomatik aktarılıp başlıyor...');
|
||||||
}
|
}
|
||||||
if (secondsLeft <= 0) {
|
if (secondsLeft <= 0) {
|
||||||
clearInterval(upNextCountdownTimer);
|
clearInterval(upNextCountdownTimer);
|
||||||
upNextCountdownTimer = null;
|
upNextCountdownTimer = null;
|
||||||
window.location.href = nextItem.localVideo.url;
|
playFirstSmartRecommendation('autoplay-ended');
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} else {
|
} else {
|
||||||
announce('Video sona erdi. Sıradaki ilgili öneri: ' + nextItem.title);
|
announce('Video sona erdi. Sıradaki ilk öneri: ' + nextItem.title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6268,6 +6656,9 @@ try {
|
|||||||
if (data && typeof data.smartPrefetchMode === 'string') {
|
if (data && typeof data.smartPrefetchMode === 'string') {
|
||||||
cachedSmartPrefetchMode = data.smartPrefetchMode;
|
cachedSmartPrefetchMode = data.smartPrefetchMode;
|
||||||
}
|
}
|
||||||
|
if (data && typeof data.federatedRecommendationsMode === 'string') {
|
||||||
|
cachedFederatedRecommendationsMode = data.federatedRecommendationsMode;
|
||||||
|
}
|
||||||
smartHasLocalMatch = Boolean(data && data.hasLocalMatch);
|
smartHasLocalMatch = Boolean(data && data.hasLocalMatch);
|
||||||
smartPrefetchCandidate = (data && data.topPrefetchCandidate) || null;
|
smartPrefetchCandidate = (data && data.topPrefetchCandidate) || null;
|
||||||
if (smartPrefetchState.videoKey !== thisVideoKey) {
|
if (smartPrefetchState.videoKey !== thisVideoKey) {
|
||||||
@@ -6296,6 +6687,7 @@ try {
|
|||||||
cachedRelatedQuery = (data && data.query) || searchQuery;
|
cachedRelatedQuery = (data && data.query) || searchQuery;
|
||||||
currentActiveVideoKey = thisVideoKey;
|
currentActiveVideoKey = thisVideoKey;
|
||||||
relatedShowAll = false;
|
relatedShowAll = false;
|
||||||
|
showNativeFediverseDrawer = false;
|
||||||
|
|
||||||
renderRelatedCards(container, uniqueResults, cachedRelatedQuery);
|
renderRelatedCards(container, uniqueResults, cachedRelatedQuery);
|
||||||
|
|
||||||
@@ -6808,6 +7200,11 @@ try {
|
|||||||
videoState.pausedByUser = true;
|
videoState.pausedByUser = true;
|
||||||
video.pause();
|
video.pause();
|
||||||
});
|
});
|
||||||
|
navigator.mediaSession.setActionHandler('nexttrack', function () {
|
||||||
|
if (typeof window.__yaktube_play_next_smart__ === 'function') {
|
||||||
|
window.__yaktube_play_next_smart__('media-session-next');
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6973,6 +7370,61 @@ try {
|
|||||||
|
|
||||||
// PeerTube Plugin Client Hook Registration
|
// PeerTube Plugin Client Hook Registration
|
||||||
export async function register({ registerHook, peertubeHelpers } = {}) {
|
export async function register({ registerHook, peertubeHelpers } = {}) {
|
||||||
|
if (typeof registerHook === 'function') {
|
||||||
|
try {
|
||||||
|
registerHook({
|
||||||
|
target: 'filter:internal.video-watch.player.load-options.result',
|
||||||
|
handler: function (result) {
|
||||||
|
if (!result || typeof result !== 'object') return result;
|
||||||
|
var origNextVideo = result.nextVideo;
|
||||||
|
result.nextVideo = function () {
|
||||||
|
var orig = typeof origNextVideo === 'function' ? origNextVideo() : {};
|
||||||
|
if (typeof window !== 'undefined' && typeof window.__yaktube_is_playlist_watch === 'function') {
|
||||||
|
if (window.__yaktube_is_playlist_watch()) return orig;
|
||||||
|
}
|
||||||
|
var firstRec =
|
||||||
|
typeof window !== 'undefined' && typeof window.__yaktube_get_first_smart_rec === 'function'
|
||||||
|
? window.__yaktube_get_first_smart_rec()
|
||||||
|
: null;
|
||||||
|
return Object.assign({}, orig, {
|
||||||
|
enabled: Boolean(firstRec) || Boolean(orig && orig.enabled),
|
||||||
|
displayControlBarButton: true,
|
||||||
|
getClipTitle: function () {
|
||||||
|
var rec =
|
||||||
|
typeof window !== 'undefined' && typeof window.__yaktube_get_first_smart_rec === 'function'
|
||||||
|
? window.__yaktube_get_first_smart_rec()
|
||||||
|
: null;
|
||||||
|
if (rec && rec.title) return rec.title;
|
||||||
|
return orig && typeof orig.getClipTitle === 'function' ? orig.getClipTitle() : 'Sonraki Önerilen Video';
|
||||||
|
},
|
||||||
|
handler: function () {
|
||||||
|
if (typeof window !== 'undefined' && typeof window.__yaktube_play_next_smart__ === 'function') {
|
||||||
|
window.__yaktube_play_next_smart__('peertube-player-hook');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (orig && typeof orig.handler === 'function') orig.handler();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (result.upnext && typeof result.upnext === 'object') {
|
||||||
|
var origUpnext = result.upnext;
|
||||||
|
result.upnext = Object.assign({}, origUpnext, {
|
||||||
|
isEnabled: function () {
|
||||||
|
if (typeof window !== 'undefined' && typeof window.__yaktube_is_playlist_watch === 'function') {
|
||||||
|
if (window.__yaktube_is_playlist_watch()) {
|
||||||
|
return origUpnext && typeof origUpnext.isEnabled === 'function' ? origUpnext.isEnabled() : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
let maxDiskUsagePercent = 85;
|
let maxDiskUsagePercent = 85;
|
||||||
let yaknetSsoEnabled = true;
|
let yaknetSsoEnabled = true;
|
||||||
let smartPrefetchMode = 'auto-when-no-local';
|
let smartPrefetchMode = 'auto-when-no-local';
|
||||||
|
let federatedRecommendationsMode = 'smart-relevant';
|
||||||
let customChannelId = '';
|
let customChannelId = '';
|
||||||
let customYtDlpPath = '';
|
let customYtDlpPath = '';
|
||||||
let safeSearchEnabled = true;
|
let safeSearchEnabled = true;
|
||||||
@@ -279,6 +280,32 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
default: 'auto-when-no-local'
|
default: 'auto-when-no-local'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
name: 'federated-recommendations-mode',
|
||||||
|
label: 'Fediverse (Diğer PeerTube Sunucuları) Öneri Görünümü',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label:
|
||||||
|
'Akıllı Alaka Süzgeci (Önerilen — Konuyla ve geçmişle alakalı Fediverse videolarını 🌐 rozetiyle önerilere dahil et, diğerlerini açılır buton altında tut)',
|
||||||
|
value: 'smart-relevant'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label:
|
||||||
|
'Tam Açık (Akıllı önerilerin altında PeerTube standart Fediverse öneri listesini de her zaman açık bırak)',
|
||||||
|
value: 'show-all'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Kapalı (Önerilerde yalnızca bu sunucudaki yerel videoları ve YouTube sonuçlarını göster)',
|
||||||
|
value: 'disabled'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
description:
|
||||||
|
'İzleme sayfasındaki önerilerde Fediverse (diğer PeerTube sunucularından gelen federe videolar) içeriklerinin nasıl sunulacağını belirler. Varsayılan "Akıllı Alaka Süzgeci" modu Fediverse videolarını engellemez; izlenen videoyla, dille veya kullanıcı geçmişiyle alakalı olan Fediverse videolarını "🌐 Fediverse\'de İzle" rozetiyle doğrudan önerilere dahil eder, alakasız/yabancı yayınları ise isteğe bağlı "🌐 Fediverse Ağındaki Diğer Videoları Göster" çekmecesi altında toplar.',
|
||||||
|
private: false,
|
||||||
|
default: 'smart-relevant'
|
||||||
|
});
|
||||||
|
|
||||||
registerSetting({
|
registerSetting({
|
||||||
name: 'safe-search-enabled',
|
name: 'safe-search-enabled',
|
||||||
label: 'Güvenli Okul & Aile Araması (SafeSearch)',
|
label: 'Güvenli Okul & Aile Araması (SafeSearch)',
|
||||||
@@ -637,6 +664,15 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const fedVal = await settingsManager.getSetting('federated-recommendations-mode');
|
||||||
|
if (fedVal && ['smart-relevant', 'show-all', 'disabled'].includes(String(fedVal).trim())) {
|
||||||
|
federatedRecommendationsMode = String(fedVal).trim();
|
||||||
|
} else {
|
||||||
|
federatedRecommendationsMode = 'smart-relevant';
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const safeVal = await settingsManager.getSetting('safe-search-enabled');
|
const safeVal = await settingsManager.getSetting('safe-search-enabled');
|
||||||
if (safeVal !== undefined && safeVal !== null) {
|
if (safeVal !== undefined && safeVal !== null) {
|
||||||
@@ -865,6 +901,8 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
FROM "videoImport" vi
|
FROM "videoImport" vi
|
||||||
INNER JOIN "video" v ON v.id = vi."videoId"
|
INNER JOIN "video" v ON v.id = vi."videoId"
|
||||||
WHERE vi."targetUrl" IS NOT NULL
|
WHERE vi."targetUrl" IS NOT NULL
|
||||||
|
AND v.state = 1
|
||||||
|
AND (vi.state IS NULL OR vi.state != 3)
|
||||||
ORDER BY vi.id DESC`
|
ORDER BY vi.id DESC`
|
||||||
);
|
);
|
||||||
const localVideos = await dbQuery(
|
const localVideos = await dbQuery(
|
||||||
@@ -1079,6 +1117,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
ok: true,
|
ok: true,
|
||||||
yaknetSsoEnabled,
|
yaknetSsoEnabled,
|
||||||
smartPrefetchMode,
|
smartPrefetchMode,
|
||||||
|
federatedRecommendationsMode,
|
||||||
guestImportLimit,
|
guestImportLimit,
|
||||||
maxDiskUsagePercent,
|
maxDiskUsagePercent,
|
||||||
safeSearchEnabled,
|
safeSearchEnabled,
|
||||||
@@ -1201,9 +1240,59 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isCrawlerBotRequest(req) {
|
||||||
|
const ua = String((req && req.headers && req.headers['user-agent']) || '').toLowerCase();
|
||||||
|
if (!ua) return false;
|
||||||
|
return /applebot|reflectionbot|googlebot|bingbot|yandexbot|baiduspider|duckduckbot|slurp|ahrefsbot|semrushbot|mj12bot|dotbot|petalbot|bytespider|facebookexternalhit|twitterbot|discordbot|telegrambot|whatsapp|linkedinbot|headlesschrome/i.test(
|
||||||
|
ua
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractYouTubeIdFromUrl(urlStr) {
|
||||||
|
if (!urlStr || typeof urlStr !== 'string') return null;
|
||||||
|
const m =
|
||||||
|
urlStr.match(/[?&]v=([a-zA-Z0-9_-]{11})/) ||
|
||||||
|
urlStr.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/) ||
|
||||||
|
urlStr.match(/shorts\/([a-zA-Z0-9_-]{11})/) ||
|
||||||
|
urlStr.match(/embed\/([a-zA-Z0-9_-]{11})/);
|
||||||
|
return m ? m[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function translateImportErrorMessage(rawErrStr) {
|
||||||
|
const s = String(rawErrStr || '').toLowerCase();
|
||||||
|
if (
|
||||||
|
s.includes('confirm your age') ||
|
||||||
|
s.includes('age-restricted') ||
|
||||||
|
s.includes('age_restriction') ||
|
||||||
|
s.includes('inappropriate for some users')
|
||||||
|
) {
|
||||||
|
return 'Bu video YouTube tarafından +18 yaş kısıtlamalı (oturum açma zorunlu) olarak işaretlendiği için sunucuya aktarılamamaktadır.';
|
||||||
|
}
|
||||||
|
if (s.includes('live streaming') || s.includes('is_live') || s.includes('live event')) {
|
||||||
|
return 'Canlı yayınlar video dosyası olarak indirilemez. Lütfen Canlı Yayını İzle modunu kullanın.';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
s.includes('private video') ||
|
||||||
|
s.includes('video unavailable') ||
|
||||||
|
s.includes('has been removed') ||
|
||||||
|
s.includes('not available in your country')
|
||||||
|
) {
|
||||||
|
return "Bu video YouTube'da gizli, silinmiş veya erişime kapalı durumda olduğu için aktarılamadı.";
|
||||||
|
}
|
||||||
|
if (s.includes('confirm you’re not a bot') || s.includes('confirm you are not a bot') || s.includes(' 429 ')) {
|
||||||
|
return 'YouTube geçici yoğunluk sınırı nedeniyle bağlantıyı kısıtladı. Lütfen birkaç saniye sonra tekrar deneyin.';
|
||||||
|
}
|
||||||
|
return "Bu video şu anda YouTube'dan aktarılamadı. Lütfen tekrar deneyin veya başka bir video seçin.";
|
||||||
|
}
|
||||||
|
|
||||||
|
const inFlightImportPromises = new Map();
|
||||||
|
|
||||||
// 2. YouTube Search Route (aliases: /youtube-search and /search)
|
// 2. YouTube Search Route (aliases: /youtube-search and /search)
|
||||||
async function handleYouTubeSearch(req, res) {
|
async function handleYouTubeSearch(req, res) {
|
||||||
await loadPluginSettings();
|
await loadPluginSettings();
|
||||||
|
if (isCrawlerBotRequest(req)) {
|
||||||
|
return res.json({ results: [], cached: true, botIgnored: true, guestImportLimit });
|
||||||
|
}
|
||||||
const query = (req.query.q || '').trim();
|
const query = (req.query.q || '').trim();
|
||||||
if (!query || query.length < 2) {
|
if (!query || query.length < 2) {
|
||||||
return res.json({ results: [], guestImportLimit });
|
return res.json({ results: [], guestImportLimit });
|
||||||
@@ -1299,6 +1388,16 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
|
|
||||||
router.get('/smart-recommendations', async (req, res) => {
|
router.get('/smart-recommendations', async (req, res) => {
|
||||||
await loadPluginSettings();
|
await loadPluginSettings();
|
||||||
|
if (isCrawlerBotRequest(req)) {
|
||||||
|
return res.json({
|
||||||
|
ok: true,
|
||||||
|
results: [],
|
||||||
|
hasLocalMatch: false,
|
||||||
|
botIgnored: true,
|
||||||
|
smartPrefetchMode,
|
||||||
|
guestImportLimit
|
||||||
|
});
|
||||||
|
}
|
||||||
const rawUuid = (req.query.uuid || '').trim();
|
const rawUuid = (req.query.uuid || '').trim();
|
||||||
const rawTitle = (req.query.title || '').trim();
|
const rawTitle = (req.query.title || '').trim();
|
||||||
const rawChannel = (req.query.channel || '').trim();
|
const rawChannel = (req.query.channel || '').trim();
|
||||||
@@ -1515,6 +1614,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
durationFormatted: formatDurationLabel(lv.duration || 0),
|
durationFormatted: formatDurationLabel(lv.duration || 0),
|
||||||
isLive: false,
|
isLive: false,
|
||||||
isDownloaded: true,
|
isDownloaded: true,
|
||||||
|
isFederated: false,
|
||||||
reasonBadge: reasonBadge ? `✅ ${reasonBadge.replace(/^[🔥🎯📂]\s*/, '')}` : "✅ YakTube'da İzle",
|
reasonBadge: reasonBadge ? `✅ ${reasonBadge.replace(/^[🔥🎯📂]\s*/, '')}` : "✅ YakTube'da İzle",
|
||||||
relevanceScore: finalScore,
|
relevanceScore: finalScore,
|
||||||
url: lv.importUrl || `/videos/watch/${lv.uuid}`,
|
url: lv.importUrl || `/videos/watch/${lv.uuid}`,
|
||||||
@@ -1531,6 +1631,118 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
if (logger) logger.warn('[YakTube SmartRec] Local DB query warning: ' + e.message);
|
if (logger) logger.warn('[YakTube SmartRec] Local DB query warning: ' + e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1.5. Score Relevant Fediverse (Remote PeerTube) Videos when federatedRecommendationsMode !== 'disabled'
|
||||||
|
if (federatedRecommendationsMode !== 'disabled') {
|
||||||
|
try {
|
||||||
|
const searchPatterns = Array.from(
|
||||||
|
new Set(
|
||||||
|
[...(artistNorm && artistNorm.length >= 3 ? [artistNorm] : []), ...currentKeywords, ...historyKeywords]
|
||||||
|
.filter(k => k && k.length >= 3)
|
||||||
|
.slice(0, 8)
|
||||||
|
.map(k => `%${k}%`)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (searchPatterns.length > 0) {
|
||||||
|
const fedRows = await dbQuery(
|
||||||
|
`SELECT DISTINCT ON (v.id)
|
||||||
|
v.id, v.uuid, v.name, v.category, v.language, v.duration, v.views, v."isLive", v.nsfw,
|
||||||
|
t.filename AS "thumbFilename"
|
||||||
|
FROM "video" v
|
||||||
|
LEFT JOIN "thumbnail" t ON t."videoId" = v.id
|
||||||
|
WHERE v.remote = true
|
||||||
|
AND v.state = 1
|
||||||
|
AND v.privacy = 1
|
||||||
|
AND v.nsfw = false
|
||||||
|
AND (v.name ILIKE ANY($1) OR v.language = 'tr')
|
||||||
|
ORDER BY v.id DESC, t.type ASC
|
||||||
|
LIMIT 80`,
|
||||||
|
[searchPatterns]
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const fv of fedRows) {
|
||||||
|
if (!fv || !fv.name) continue;
|
||||||
|
if (resolvedUuid && fv.uuid === resolvedUuid) continue;
|
||||||
|
if (safeSearchEnabled && (fv.nsfw || isContentBlocked(fv.name, blockedKeywordsList))) continue;
|
||||||
|
|
||||||
|
const normFv = normalizeTitleForMatch(fv.name);
|
||||||
|
if (!normFv || normFv === normCurrentTitle) continue;
|
||||||
|
|
||||||
|
let fedScore = 0;
|
||||||
|
let fedBadge = '';
|
||||||
|
|
||||||
|
if (artistNorm && artistNorm.length >= 3 && normFv.includes(artistNorm)) {
|
||||||
|
fedScore += 65;
|
||||||
|
fedBadge = '🌐 Fediverse • Aynı Sanatçı';
|
||||||
|
}
|
||||||
|
|
||||||
|
const fvKeywords = extractRecommendationKeywords(fv.name);
|
||||||
|
let kwOverlap = 0;
|
||||||
|
for (const kw of currentKeywords) {
|
||||||
|
if (fvKeywords.includes(kw) || (kw.length >= 4 && normFv.includes(kw))) {
|
||||||
|
kwOverlap++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (kwOverlap > 0) {
|
||||||
|
fedScore += kwOverlap * 30;
|
||||||
|
if (!fedBadge) fedBadge = '🌐 Fediverse • Benzer İçerik';
|
||||||
|
}
|
||||||
|
|
||||||
|
let histOverlap = 0;
|
||||||
|
for (const hkw of historyKeywords) {
|
||||||
|
if (fvKeywords.includes(hkw) || (hkw.length >= 4 && normFv.includes(hkw))) {
|
||||||
|
histOverlap++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (histOverlap > 0) {
|
||||||
|
fedScore += Math.min(48, histOverlap * 24);
|
||||||
|
if (!fedBadge) fedBadge = '🌐 Fediverse • Geçmişinize Göre';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
currentCategory &&
|
||||||
|
fv.category &&
|
||||||
|
Number(fv.category) === currentCategory &&
|
||||||
|
String(fv.language || '').toLowerCase() === 'tr'
|
||||||
|
) {
|
||||||
|
fedScore += 22;
|
||||||
|
if (!fedBadge) fedBadge = '🌐 Fediverse • Aynı Kategori';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Require strong relevance (score >= 28) so random foreign webcams never slip in
|
||||||
|
if (fedScore < 28) continue;
|
||||||
|
|
||||||
|
const thumbUrl = fv.thumbFilename
|
||||||
|
? `/lazy-static/thumbnails/${fv.thumbFilename}`
|
||||||
|
: '/client/assets/images/default-thumbnail.jpg';
|
||||||
|
|
||||||
|
scoredLocalItems.push({
|
||||||
|
id: `fed-${fv.uuid}`,
|
||||||
|
title: fv.name,
|
||||||
|
channel: 'Fediverse Ağı',
|
||||||
|
duration: fv.duration || 0,
|
||||||
|
durationFormatted: fv.isLive ? 'CANLI' : formatDurationLabel(fv.duration || 0),
|
||||||
|
isLive: Boolean(fv.isLive),
|
||||||
|
isDownloaded: true,
|
||||||
|
isFederated: true,
|
||||||
|
reasonBadge: fedBadge || "🌐 Fediverse'de İzle",
|
||||||
|
relevanceScore: fedScore + 20,
|
||||||
|
url: `/videos/watch/${fv.uuid}`,
|
||||||
|
thumbnail: thumbUrl,
|
||||||
|
localVideo: {
|
||||||
|
id: fv.id,
|
||||||
|
uuid: fv.uuid,
|
||||||
|
name: fv.name,
|
||||||
|
url: `/videos/watch/${fv.uuid}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (logger) logger.warn('[YakTube SmartRec] Federated DB query warning: ' + e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Query YouTube On-Demand for Current Video Topic + User History in Parallel
|
// 2. Query YouTube On-Demand for Current Video Topic + User History in Parallel
|
||||||
let primaryYtResults = [];
|
let primaryYtResults = [];
|
||||||
let historyYtResults = [];
|
let historyYtResults = [];
|
||||||
@@ -1655,6 +1867,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
historyQuery: historyQuery || null,
|
historyQuery: historyQuery || null,
|
||||||
hasLocalMatch: hasDirectLocalMatch,
|
hasLocalMatch: hasDirectLocalMatch,
|
||||||
smartPrefetchMode,
|
smartPrefetchMode,
|
||||||
|
federatedRecommendationsMode,
|
||||||
topPrefetchCandidate: topPrefetchCandidate
|
topPrefetchCandidate: topPrefetchCandidate
|
||||||
? {
|
? {
|
||||||
id: topPrefetchCandidate.id,
|
id: topPrefetchCandidate.id,
|
||||||
@@ -1671,14 +1884,21 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
// 3. On-Demand Video Import Route (aliases: /ondemand-import and /import)
|
// 3. On-Demand Video Import Route (aliases: /ondemand-import and /import)
|
||||||
async function handleOnDemandImport(req, res) {
|
async function handleOnDemandImport(req, res) {
|
||||||
await loadPluginSettings();
|
await loadPluginSettings();
|
||||||
|
if (isCrawlerBotRequest(req)) {
|
||||||
|
return res.status(403).json({ ok: false, error: 'Automated bot requests are not allowed to import videos.' });
|
||||||
|
}
|
||||||
const { targetUrl, title, channelId, isAuthenticated, guestImportCount } = req.body || {};
|
const { targetUrl, title, channelId, isAuthenticated, guestImportCount } = req.body || {};
|
||||||
if (!targetUrl || (!targetUrl.includes('youtube.com') && !targetUrl.includes('youtu.be'))) {
|
if (!targetUrl || (!targetUrl.includes('youtube.com') && !targetUrl.includes('youtu.be'))) {
|
||||||
return res.status(400).json({ error: 'Invalid YouTube URL' });
|
return res.status(400).json({ error: 'Invalid YouTube URL' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ytId = extractYouTubeIdFromUrl(targetUrl);
|
||||||
|
const normalizedTargetUrl = ytId ? `https://www.youtube.com/watch?v=${ytId}` : targetUrl.trim();
|
||||||
|
const dedupeKey = ytId || normalizedTargetUrl;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
safeSearchEnabled &&
|
safeSearchEnabled &&
|
||||||
(isContentBlocked(title, blockedKeywordsList) || isContentBlocked(targetUrl, blockedKeywordsList))
|
(isContentBlocked(title, blockedKeywordsList) || isContentBlocked(normalizedTargetUrl, blockedKeywordsList))
|
||||||
) {
|
) {
|
||||||
return res.status(403).json({
|
return res.status(403).json({
|
||||||
ok: false,
|
ok: false,
|
||||||
@@ -1688,6 +1908,90 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1. Check DB for already published, currently importing, or previously failed records for this YouTube video
|
||||||
|
try {
|
||||||
|
const searchPattern = ytId ? `%${ytId}%` : normalizedTargetUrl;
|
||||||
|
const existingRows = await dbQuery(
|
||||||
|
`SELECT vi.id AS "importId", vi.state AS "importState",
|
||||||
|
v.id, v.uuid, v.name, v.state AS "videoState", v."updatedAt"
|
||||||
|
FROM "videoImport" vi
|
||||||
|
INNER JOIN "video" v ON v.id = vi."videoId"
|
||||||
|
WHERE vi."targetUrl" LIKE $1
|
||||||
|
ORDER BY vi.id DESC`,
|
||||||
|
[searchPattern]
|
||||||
|
);
|
||||||
|
|
||||||
|
const publishedRow = existingRows.find(r => Number(r.videoState) === 1);
|
||||||
|
if (publishedRow) {
|
||||||
|
return res.json({
|
||||||
|
ok: true,
|
||||||
|
alreadyImported: true,
|
||||||
|
importId: publishedRow.importId,
|
||||||
|
video: {
|
||||||
|
id: publishedRow.id,
|
||||||
|
uuid: publishedRow.uuid,
|
||||||
|
name: publishedRow.name,
|
||||||
|
url: '/videos/watch/' + publishedRow.uuid
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeRow = existingRows.find(r => {
|
||||||
|
const vState = Number(r.videoState);
|
||||||
|
const iState = Number(r.importState);
|
||||||
|
const ageMs = r.updatedAt ? Date.now() - new Date(r.updatedAt).getTime() : 0;
|
||||||
|
return (vState === 2 || vState === 3) && iState !== 3 && iState !== 4 && ageMs < 10 * 60 * 1000;
|
||||||
|
});
|
||||||
|
if (activeRow) {
|
||||||
|
return res.json({
|
||||||
|
ok: true,
|
||||||
|
inProgress: true,
|
||||||
|
importId: activeRow.importId,
|
||||||
|
video: {
|
||||||
|
id: activeRow.id,
|
||||||
|
uuid: activeRow.uuid,
|
||||||
|
name: activeRow.name,
|
||||||
|
url: '/videos/watch/' + activeRow.uuid
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up any failed (v.state = 12 / vi.state = 3) or stale (>15 min in state 3) rows before re-importing
|
||||||
|
const staleOrFailedRows = existingRows.filter(r => {
|
||||||
|
const vState = Number(r.videoState);
|
||||||
|
const iState = Number(r.importState);
|
||||||
|
const ageMs = r.updatedAt ? Date.now() - new Date(r.updatedAt).getTime() : 0;
|
||||||
|
return vState === 12 || iState === 3 || (vState === 3 && ageMs >= 15 * 60 * 1000);
|
||||||
|
});
|
||||||
|
if (staleOrFailedRows.length > 0) {
|
||||||
|
const badImportIds = staleOrFailedRows.map(r => r.importId).filter(Boolean);
|
||||||
|
const badVideoIds = staleOrFailedRows.map(r => r.id).filter(Boolean);
|
||||||
|
if (badImportIds.length > 0) {
|
||||||
|
await dbQuery(`DELETE FROM "videoImport" WHERE id = ANY($1::int[])`, [badImportIds]);
|
||||||
|
}
|
||||||
|
if (badVideoIds.length > 0) {
|
||||||
|
await dbQuery(
|
||||||
|
`DELETE FROM "video" v
|
||||||
|
WHERE v.id = ANY($1::int[])
|
||||||
|
AND v.state IN (3, 12)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM "videoFile" vf WHERE vf."videoId" = v.id)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM "videoStreamingPlaylist" vsp WHERE vsp."videoId" = v.id)`,
|
||||||
|
[badVideoIds]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (dbCheckErr) {}
|
||||||
|
|
||||||
|
// 2. If another request is already initiating an import for this exact video right now, await it
|
||||||
|
if (inFlightImportPromises.has(dedupeKey)) {
|
||||||
|
try {
|
||||||
|
const sharedResult = await inFlightImportPromises.get(dedupeKey);
|
||||||
|
return res.status(sharedResult.status).json(sharedResult.payload);
|
||||||
|
} catch (sharedErr) {
|
||||||
|
return res.status(500).json({ error: sharedErr.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const isLoggedUser = await isRequestAuthenticated(req, res, isAuthenticated);
|
const isLoggedUser = await isRequestAuthenticated(req, res, isAuthenticated);
|
||||||
if (!isLoggedUser && guestImportLimit > 0) {
|
if (!isLoggedUser && guestImportLimit > 0) {
|
||||||
const clientCount = parseInt(String(guestImportCount || '0'), 10) || 0;
|
const clientCount = parseInt(String(guestImportCount || '0'), 10) || 0;
|
||||||
@@ -1705,16 +2009,17 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
// Non-blocking background check to prune old videos if disk usage exceeds maxDiskUsagePercent
|
// Non-blocking background check to prune old videos if disk usage exceeds maxDiskUsagePercent
|
||||||
checkAndPruneStorage().catch(() => {});
|
checkAndPruneStorage().catch(() => {});
|
||||||
|
|
||||||
try {
|
const importPromise = (async () => {
|
||||||
const token = await getAdminToken();
|
const token = await getAdminToken();
|
||||||
const resolvedChannelId = await resolveTargetChannelId(title, channelId);
|
const resolvedChannelId = await resolveTargetChannelId(title, channelId);
|
||||||
const { hostname, port, hostHeader } = getLocalServerTarget();
|
const { hostname, port, hostHeader } = getLocalServerTarget();
|
||||||
const postData = new URLSearchParams({
|
const postData = new URLSearchParams({
|
||||||
targetUrl: targetUrl,
|
targetUrl: normalizedTargetUrl,
|
||||||
channelId: resolvedChannelId,
|
channelId: resolvedChannelId,
|
||||||
privacy: '1'
|
privacy: '1'
|
||||||
}).toString();
|
}).toString();
|
||||||
|
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
const importReq = http.request(
|
const importReq = http.request(
|
||||||
{
|
{
|
||||||
hostname,
|
hostname,
|
||||||
@@ -1735,7 +2040,9 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
try {
|
try {
|
||||||
const data = JSON.parse(body);
|
const data = JSON.parse(body);
|
||||||
if (data && data.video) {
|
if (data && data.video) {
|
||||||
return res.json({
|
return resolve({
|
||||||
|
status: 200,
|
||||||
|
payload: {
|
||||||
ok: true,
|
ok: true,
|
||||||
importId: data.id,
|
importId: data.id,
|
||||||
video: {
|
video: {
|
||||||
@@ -1745,25 +2052,53 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
name: data.video.name,
|
name: data.video.name,
|
||||||
url: data.video.url
|
url: data.video.url
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return res.status(400).json({ error: 'Import initiation failed', details: data });
|
const friendlyMsg = translateImportErrorMessage(body);
|
||||||
|
return resolve({
|
||||||
|
status: 400,
|
||||||
|
payload: {
|
||||||
|
ok: false,
|
||||||
|
error: friendlyMsg,
|
||||||
|
userMessage: friendlyMsg,
|
||||||
|
details: data
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return res.status(500).json({ error: 'Error parsing import response', raw: body });
|
const friendlyMsg = translateImportErrorMessage(body);
|
||||||
|
return resolve({
|
||||||
|
status: 500,
|
||||||
|
payload: {
|
||||||
|
ok: false,
|
||||||
|
error: friendlyMsg,
|
||||||
|
userMessage: friendlyMsg,
|
||||||
|
raw: body
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
importReq.on('error', err => {
|
importReq.on('error', err => {
|
||||||
return res.status(500).json({ error: 'HTTP error connecting to PeerTube API', details: err.message });
|
reject(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
importReq.write(postData);
|
importReq.write(postData);
|
||||||
importReq.end();
|
importReq.end();
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
inFlightImportPromises.set(dedupeKey, importPromise);
|
||||||
|
try {
|
||||||
|
const outcome = await importPromise;
|
||||||
|
return res.status(outcome.status).json(outcome.payload);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(500).json({ error: 'Admin authentication failed', details: err.message });
|
return res.status(500).json({ error: 'Admin authentication or HTTP connection failed', details: err.message });
|
||||||
|
} finally {
|
||||||
|
inFlightImportPromises.delete(dedupeKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1785,7 +2120,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
resVideo => {
|
resVideo => {
|
||||||
let body = '';
|
let body = '';
|
||||||
resVideo.on('data', c => (body += c));
|
resVideo.on('data', c => (body += c));
|
||||||
resVideo.on('end', () => {
|
resVideo.on('end', async () => {
|
||||||
try {
|
try {
|
||||||
const video = JSON.parse(body);
|
const video = JSON.parse(body);
|
||||||
const isPublished = video.state && video.state.id === 1;
|
const isPublished = video.state && video.state.id === 1;
|
||||||
@@ -1796,6 +2131,30 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
(video.files && video.files.length > 0) ||
|
(video.files && video.files.length > 0) ||
|
||||||
(video.streamingPlaylists && video.streamingPlaylists.length > 0);
|
(video.streamingPlaylists && video.streamingPlaylists.length > 0);
|
||||||
|
|
||||||
|
let errorMessage = null;
|
||||||
|
if (isFailed && video.id) {
|
||||||
|
try {
|
||||||
|
const errRows = await dbQuery(
|
||||||
|
`SELECT id, error FROM "videoImport" WHERE "videoId" = $1 ORDER BY id DESC LIMIT 1`,
|
||||||
|
[video.id]
|
||||||
|
);
|
||||||
|
const rawErr = errRows.length > 0 ? errRows[0].error : '';
|
||||||
|
errorMessage = translateImportErrorMessage(rawErr);
|
||||||
|
// Auto-cleanup failed import and orphan state=12 video so it never pollutes search or library
|
||||||
|
await dbQuery(`DELETE FROM "videoImport" WHERE "videoId" = $1 AND state = 3`, [video.id]);
|
||||||
|
if (!hasFiles) {
|
||||||
|
await dbQuery(
|
||||||
|
`DELETE FROM "video" v
|
||||||
|
WHERE v.id = $1
|
||||||
|
AND v.state = 12
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM "videoFile" vf WHERE vf."videoId" = v.id)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM "videoStreamingPlaylist" vsp WHERE vsp."videoId" = v.id)`,
|
||||||
|
[video.id]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (cleanErr) {}
|
||||||
|
}
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
id: video.id,
|
id: video.id,
|
||||||
uuid: video.uuid,
|
uuid: video.uuid,
|
||||||
@@ -1807,6 +2166,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
isImporting,
|
isImporting,
|
||||||
isFailed,
|
isFailed,
|
||||||
hasFiles,
|
hasFiles,
|
||||||
|
errorMessage,
|
||||||
url: video.url,
|
url: video.url,
|
||||||
isLocal: video.isLocal
|
isLocal: video.isLocal
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "peertube-plugin-yaktube-ondemand",
|
"name": "peertube-plugin-yaktube-ondemand",
|
||||||
"version": "1.7.7",
|
"version": "1.7.11",
|
||||||
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
|
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"library": "./main.js",
|
"library": "./main.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user