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 | |
|---|---|---|---|
|
|
d8e87f29d5 | ||
|
|
64a961bc74 | ||
|
|
1fb61b784e |
@@ -1,3 +1,4 @@
|
|||||||
|
var cachedYakNetSsoEnabled = null;
|
||||||
// 100% Incompatible Browser Suppression & Error Guardian
|
// 100% Incompatible Browser Suppression & Error Guardian
|
||||||
// CRITICAL: PeerTube's Angular app (my-app ngOnInit) relies on document.getElementById('incompatible-browser')
|
// CRITICAL: PeerTube's Angular app (my-app ngOnInit) relies on document.getElementById('incompatible-browser')
|
||||||
// to exist so it can do .className += " browser-ok" before calling this.loadUser()!
|
// to exist so it can do .className += " browser-ok" before calling this.loadUser()!
|
||||||
@@ -582,6 +583,10 @@ try {
|
|||||||
btn.setAttribute('tabindex', '-1');
|
btn.setAttribute('tabindex', '-1');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!isYakNetSsoEnabled()) {
|
||||||
|
if (liveWidget) liveWidget.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!liveWidget && isOfficialYakTubeServer()) {
|
if (!liveWidget && isOfficialYakTubeServer()) {
|
||||||
var widgetWrap = document.createElement('div');
|
var widgetWrap = document.createElement('div');
|
||||||
widgetWrap.id = 'yaknet-header-account-widget';
|
widgetWrap.id = 'yaknet-header-account-widget';
|
||||||
@@ -684,7 +689,7 @@ try {
|
|||||||
btn.removeAttribute('tabindex');
|
btn.removeAttribute('tabindex');
|
||||||
|
|
||||||
var loginAnchor = btn.tagName.toLowerCase() === 'a' ? btn : btn.querySelector('a');
|
var loginAnchor = btn.tagName.toLowerCase() === 'a' ? btn : btn.querySelector('a');
|
||||||
if (loginAnchor) {
|
if (loginAnchor && isYakNetSsoEnabled()) {
|
||||||
loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
|
loginAnchor.setAttribute('aria-label', 'YakNet ile Giriş Yap');
|
||||||
loginAnchor.setAttribute('title', 'YakNet ile Giriş Yap');
|
loginAnchor.setAttribute('title', 'YakNet ile Giriş Yap');
|
||||||
var spanText = loginAnchor.querySelector('span');
|
var spanText = loginAnchor.querySelector('span');
|
||||||
@@ -707,7 +712,7 @@ try {
|
|||||||
document.querySelector('form[action*="login"]') ||
|
document.querySelector('form[action*="login"]') ||
|
||||||
document.querySelector('my-login-modal');
|
document.querySelector('my-login-modal');
|
||||||
|
|
||||||
if (loginCard && !document.getElementById('yaknet-login-section')) {
|
if (loginCard && isYakNetSsoEnabled() && !document.getElementById('yaknet-login-section')) {
|
||||||
var isLocalLogin = window.location.search.includes('local=true') || window.location.pathname.includes('/admin');
|
var isLocalLogin = window.location.search.includes('local=true') || window.location.pathname.includes('/admin');
|
||||||
|
|
||||||
var ssoBox = document.createElement('div');
|
var ssoBox = document.createElement('div');
|
||||||
@@ -3579,7 +3584,7 @@ try {
|
|||||||
var customUrl = '/api-custom' + cleanPath;
|
var customUrl = '/api-custom' + cleanPath;
|
||||||
|
|
||||||
if (!preferredApiPrefix) {
|
if (!preferredApiPrefix) {
|
||||||
preferredApiPrefix = isOfficialYakTubeServer() ? '/api-custom' : '/plugins/yaktube-ondemand/router';
|
preferredApiPrefix = '/plugins/yaktube-ondemand/router';
|
||||||
}
|
}
|
||||||
|
|
||||||
var primaryUrl = preferredApiPrefix + cleanPath;
|
var primaryUrl = preferredApiPrefix + cleanPath;
|
||||||
@@ -3609,6 +3614,8 @@ try {
|
|||||||
// --- Guest Video Import Quota & PeerTube Login Redirect Engine ---
|
// --- Guest Video Import Quota & PeerTube Login Redirect Engine ---
|
||||||
var cachedGuestImportLimit = null;
|
var cachedGuestImportLimit = null;
|
||||||
var cachedCategories = null;
|
var cachedCategories = null;
|
||||||
|
var cachedSmartPrefetchMode = 'auto-when-no-local';
|
||||||
|
var cachedFederatedRecommendationsMode = 'smart-relevant';
|
||||||
|
|
||||||
function fetchGuestImportLimit() {
|
function fetchGuestImportLimit() {
|
||||||
if (cachedGuestImportLimit !== null && cachedCategories !== null) {
|
if (cachedGuestImportLimit !== null && cachedCategories !== null) {
|
||||||
@@ -3619,6 +3626,15 @@ try {
|
|||||||
if (d && typeof d.guestImportLimit === 'number') {
|
if (d && typeof d.guestImportLimit === 'number') {
|
||||||
cachedGuestImportLimit = d.guestImportLimit;
|
cachedGuestImportLimit = d.guestImportLimit;
|
||||||
}
|
}
|
||||||
|
if (d && typeof d.yaknetSsoEnabled === 'boolean') {
|
||||||
|
cachedYakNetSsoEnabled = d.yaknetSsoEnabled;
|
||||||
|
}
|
||||||
|
if (d && typeof d.smartPrefetchMode === 'string') {
|
||||||
|
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 {
|
||||||
@@ -5037,9 +5053,12 @@ try {
|
|||||||
'<div style="display: flex; align-items: center; gap: 8px;">';
|
'<div style="display: flex; align-items: center; gap: 8px;">';
|
||||||
|
|
||||||
if (loggedIn) {
|
if (loggedIn) {
|
||||||
|
var isYakNet = isYakNetSsoEnabled();
|
||||||
var syncTitle = syncEnabled
|
var syncTitle = syncEnabled
|
||||||
? 'YakNet Bulut Eşitlemesi Aktif (Tüm cihazlarınızda senkronize edilir. Kapatmak için tıklayın.)'
|
? isYakNet
|
||||||
: 'Eşitleme Kapalı (Aramalar sadece bu cihazda saklanır. Açmak için tıklayın.)';
|
? 'YakNet Bulut Eşitlemesi Aktif (Tüm cihazlarınızda senkronize edilir)'
|
||||||
|
: 'Hesap Arama Eşitlemesi Aktif (Sunucu hesabınızla senkronize edilir)'
|
||||||
|
: 'Eşitleme Kapalı (Aramalar sadece bu cihazda saklanır)';
|
||||||
var syncText = syncEnabled ? '☁️ Eşitleme: Açık' : '☁️ Eşitleme: Kapalı';
|
var syncText = syncEnabled ? '☁️ Eşitleme: Açık' : '☁️ Eşitleme: Kapalı';
|
||||||
var syncBg = syncEnabled ? '#0f766e' : '#334155';
|
var syncBg = syncEnabled ? '#0f766e' : '#334155';
|
||||||
var syncColor = syncEnabled ? '#5eead4' : '#94a3b8';
|
var syncColor = syncEnabled ? '#5eead4' : '#94a3b8';
|
||||||
@@ -5553,12 +5572,157 @@ try {
|
|||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
// 7.5. Reactive Hybrid Related Videos Engine (Watch Page)
|
// 7.5. YouTube-Style Smart Recommendation, History Profiler & Up-Next Engine (Watch Page)
|
||||||
var currentActiveVideoKey = null;
|
var currentActiveVideoKey = null;
|
||||||
var isFetchingRelated = false;
|
var isFetchingRelated = false;
|
||||||
var relatedShowAll = false;
|
var relatedShowAll = false;
|
||||||
var cachedRelatedResults = [];
|
var cachedRelatedResults = [];
|
||||||
var cachedRelatedQuery = '';
|
var cachedRelatedQuery = '';
|
||||||
|
var smartHasLocalMatch = false;
|
||||||
|
var smartPrefetchCandidate = null;
|
||||||
|
var smartPrefetchState = {
|
||||||
|
videoKey: null,
|
||||||
|
status: 'idle', // 'idle' | 'preparing' | 'ready' | 'failed'
|
||||||
|
pollTimer: null,
|
||||||
|
readyUrl: null,
|
||||||
|
readyTitle: null
|
||||||
|
};
|
||||||
|
var upNextCountdownTimer = null;
|
||||||
|
|
||||||
|
function cleanVideoTopicString(rawTitle) {
|
||||||
|
if (!rawTitle) return '';
|
||||||
|
return String(rawTitle)
|
||||||
|
.replace(/YakTube/gi, '')
|
||||||
|
.replace(/[\(\[].*?[\)\]]/g, '')
|
||||||
|
.replace(
|
||||||
|
/official\s*video|video\s*klip|klip|hd|4k|lyric\s*video|audio|remix|feat\.?|ft\.?|şarkı\s*sözleri/gi,
|
||||||
|
''
|
||||||
|
)
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function recordWatchedVideo(uuid, rawTitle, rawChannel) {
|
||||||
|
if (!rawTitle || rawTitle.length < 3) return;
|
||||||
|
try {
|
||||||
|
var cleanTopic = cleanVideoTopicString(rawTitle);
|
||||||
|
var words = cleanTopic.split(/\s+/).filter(function (w) {
|
||||||
|
return w.length >= 2;
|
||||||
|
});
|
||||||
|
var compactTopic = words.slice(0, 4).join(' ') || cleanTopic;
|
||||||
|
if (!compactTopic || compactTopic.length < 3) return;
|
||||||
|
|
||||||
|
var rawList = localStorage.getItem('yaktube_watch_history');
|
||||||
|
var list = [];
|
||||||
|
if (rawList) {
|
||||||
|
try {
|
||||||
|
var parsed = JSON.parse(rawList);
|
||||||
|
if (Array.isArray(parsed)) list = parsed;
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
list = list.filter(function (entry) {
|
||||||
|
if (!entry) return false;
|
||||||
|
if (uuid && entry.uuid === uuid) return false;
|
||||||
|
if (entry.topic && entry.topic.toLowerCase() === compactTopic.toLowerCase()) return false;
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
list.unshift({
|
||||||
|
uuid: uuid || '',
|
||||||
|
title: rawTitle,
|
||||||
|
topic: compactTopic,
|
||||||
|
channel: rawChannel || '',
|
||||||
|
ts: Date.now()
|
||||||
|
});
|
||||||
|
|
||||||
|
if (list.length > 25) list = list.slice(0, 25);
|
||||||
|
localStorage.setItem('yaktube_watch_history', JSON.stringify(list));
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getUserInterestHistory(excludeTopic) {
|
||||||
|
var interests = [];
|
||||||
|
var seen = {};
|
||||||
|
var normExclude = (excludeTopic || '').toLowerCase().trim();
|
||||||
|
if (normExclude) seen[normExclude] = true;
|
||||||
|
|
||||||
|
var defaultPlaceholders = {
|
||||||
|
tarkan: true,
|
||||||
|
'barış manço': true,
|
||||||
|
'yapay zeka': true,
|
||||||
|
'canlı haber': true
|
||||||
|
};
|
||||||
|
|
||||||
|
// 1. Recent watched video topics
|
||||||
|
try {
|
||||||
|
var rawWatch = localStorage.getItem('yaktube_watch_history');
|
||||||
|
if (rawWatch) {
|
||||||
|
var watchList = JSON.parse(rawWatch);
|
||||||
|
if (Array.isArray(watchList)) {
|
||||||
|
watchList.forEach(function (w) {
|
||||||
|
var t = w && (w.topic || w.title) ? String(w.topic || w.title).trim() : '';
|
||||||
|
var low = t.toLowerCase();
|
||||||
|
if (t.length >= 3 && !seen[low]) {
|
||||||
|
seen[low] = true;
|
||||||
|
interests.push(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// 2. Recent user search queries
|
||||||
|
try {
|
||||||
|
var searches = getRecentSearches();
|
||||||
|
if (Array.isArray(searches)) {
|
||||||
|
var hasRealSearches = searches.some(function (s) {
|
||||||
|
return s && !defaultPlaceholders[String(s).toLowerCase().trim()];
|
||||||
|
});
|
||||||
|
searches.forEach(function (s) {
|
||||||
|
var term = String(s || '').trim();
|
||||||
|
var low = term.toLowerCase();
|
||||||
|
if (hasRealSearches && defaultPlaceholders[low]) return;
|
||||||
|
if (term.length >= 3 && !seen[low]) {
|
||||||
|
seen[low] = true;
|
||||||
|
interests.push(term);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return interests.slice(0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
var showNativeFediverseDrawer = false;
|
||||||
|
|
||||||
|
function suppressUnrelatedNativeRecommendations() {
|
||||||
|
try {
|
||||||
|
// Prevent PeerTube's native player from auto-redirecting to unrelated foreign/federated videos on video end
|
||||||
|
localStorage.setItem('auto-play-video', 'false');
|
||||||
|
sessionStorage.setItem('auto-play-video', 'false');
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
var shouldShowNativeList =
|
||||||
|
cachedFederatedRecommendationsMode === 'show-all' ||
|
||||||
|
(cachedFederatedRecommendationsMode === 'smart-relevant' && showNativeFediverseDrawer);
|
||||||
|
|
||||||
|
var recContainers = document.querySelectorAll('my-recommended-videos, .other-videos, .video-watch-next');
|
||||||
|
recContainers.forEach(function (rec) {
|
||||||
|
Array.from(rec.children).forEach(function (child) {
|
||||||
|
if (child.id === 'yaktube-hybrid-related-container' || child.id === 'yaktube-upnext-overlay') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (shouldShowNativeList) {
|
||||||
|
child.style.removeProperty('display');
|
||||||
|
child.removeAttribute('aria-hidden');
|
||||||
|
} else {
|
||||||
|
child.style.setProperty('display', 'none', 'important');
|
||||||
|
child.setAttribute('aria-hidden', 'true');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function renderRelatedCards(container, results, query) {
|
function renderRelatedCards(container, results, query) {
|
||||||
var count = results ? results.length : 0;
|
var count = results ? results.length : 0;
|
||||||
@@ -5568,67 +5732,87 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.style.display = 'block';
|
container.style.display = 'block';
|
||||||
|
suppressUnrelatedNativeRecommendations();
|
||||||
|
|
||||||
var limit = relatedShowAll ? count : Math.min(count, 12);
|
var limit = relatedShowAll ? count : Math.min(count, 12);
|
||||||
var displayed = results.slice(0, limit);
|
var displayed = results.slice(0, limit);
|
||||||
|
|
||||||
var cardsHtml = '';
|
var cardsHtml = '';
|
||||||
displayed.forEach(function (item) {
|
displayed.forEach(function (item) {
|
||||||
var isLocal = !!item.isDownloaded;
|
var isLocal = !!item.isDownloaded;
|
||||||
var statusBadge = isLocal
|
var isFed = !!item.isFederated;
|
||||||
? '<span class="yaktube-badge" style="background: linear-gradient(135deg, #10b981 0%, #059669 100%); margin-bottom: 4px; display: inline-block; font-size:10px; padding:2px 8px;">✅ ' +
|
var badgeLabel =
|
||||||
getInstanceName() +
|
item.reasonBadge ||
|
||||||
"'da İzle</span>"
|
(isFed ? "🌐 Fediverse'de İzle" : isLocal ? '✅ ' + getInstanceName() + "'da İzle" : '🔥 Benzer İçerik');
|
||||||
: '<span class="yaktube-badge" style="background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); margin-bottom: 4px; display: inline-block; font-size:10px; padding:2px 8px;">⚡ Canlı Keşif</span>';
|
var isHistoryMatch = badgeLabel.indexOf('Geçmişinize Göre') !== -1;
|
||||||
|
|
||||||
var actionButton = isLocal
|
var badgeStyle = isFed
|
||||||
? '<a href="' +
|
? 'background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%); color: #fff;'
|
||||||
item.localVideo.url +
|
: isLocal
|
||||||
'" class="yaktube-play-btn yaktube-related-play-link" style="font-size:11px; padding:6px 10px;" aria-label="' +
|
? 'background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #fff;'
|
||||||
item.title.replace(/"/g, '"') +
|
: isHistoryMatch
|
||||||
' videosunu ' +
|
? 'background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); color: #fff;'
|
||||||
escapeHtml(getInstanceName()) +
|
: 'background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%); color: #fff;';
|
||||||
'\'dan hemen izle">▶️ Hemen İzle</a>'
|
|
||||||
: '<button class="yaktube-import-btn yaktube-related-import" data-url="' +
|
var statusBadge =
|
||||||
item.url +
|
'<span class="yaktube-badge" style="' +
|
||||||
'" data-title="' +
|
badgeStyle +
|
||||||
item.title.replace(/"/g, '"') +
|
' margin-bottom: 4px; display: inline-block; font-size:10px; padding:2px 8px; font-weight:700;">' +
|
||||||
'" style="font-size:11px; padding:6px 10px;" aria-label="' +
|
escapeHtml(badgeLabel) +
|
||||||
item.title.replace(/"/g, '"') +
|
'</span>';
|
||||||
' videosunu ' +
|
|
||||||
getInstanceName() +
|
var safeTitleAttr = (item.title || '').replace(/"/g, '"');
|
||||||
'\'a indir ve izle">📥 İndir ve İzle</button>';
|
var actionButton =
|
||||||
|
isLocal && item.localVideo && item.localVideo.url
|
||||||
|
? '<a href="' +
|
||||||
|
escapeHtml(item.localVideo.url) +
|
||||||
|
'" 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 +
|
||||||
|
' videosunu ' +
|
||||||
|
(isFed ? 'Fediverse ağından' : escapeHtml(getInstanceName()) + "'dan") +
|
||||||
|
' hemen izle">' +
|
||||||
|
(isFed ? "🌐 Fediverse'den İzle" : '▶️ Hemen İzle') +
|
||||||
|
'</a>'
|
||||||
|
: '<button class="yaktube-import-btn yaktube-related-import" data-yt-id="' +
|
||||||
|
escapeHtml(item.id || '') +
|
||||||
|
'" data-url="' +
|
||||||
|
escapeHtml(item.url || '') +
|
||||||
|
'" data-title="' +
|
||||||
|
safeTitleAttr +
|
||||||
|
'" style="font-size:11px; padding:6px 10px;" aria-label="' +
|
||||||
|
safeTitleAttr +
|
||||||
|
' videosunu ' +
|
||||||
|
escapeHtml(getInstanceName()) +
|
||||||
|
'\'a indir ve izle">📥 İndir ve İzle</button>';
|
||||||
|
|
||||||
var cardLabel =
|
var cardLabel =
|
||||||
item.title +
|
item.title + ' (' + badgeLabel + '), ' + item.channel + ' kanalı, Süre: ' + (item.durationFormatted || '');
|
||||||
(isLocal ? ' (' + getInstanceName() + ' kütüphanenizde mevcut)' : ' (Canlı YouTube keşfi)') +
|
|
||||||
', ' +
|
|
||||||
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;" aria-label="' +
|
||||||
cardLabel.replace(/"/g, '"') +
|
cardLabel.replace(/"/g, '"') +
|
||||||
'">' +
|
'">' +
|
||||||
'<div class="yaktube-thumb-wrap">' +
|
'<div class="yaktube-thumb-wrap">' +
|
||||||
'<img class="yaktube-thumb-img" src="' +
|
'<img class="yaktube-thumb-img" src="' +
|
||||||
item.thumbnail +
|
escapeHtml(item.thumbnail || '/client/assets/images/default-thumbnail.jpg') +
|
||||||
'" alt="' +
|
'" alt="' +
|
||||||
item.title.replace(/"/g, '"') +
|
safeTitleAttr +
|
||||||
'" loading="lazy" />' +
|
'" loading="lazy" onerror="this.src=\'/client/assets/images/default-thumbnail.jpg\'" />' +
|
||||||
'<span class="yaktube-duration-badge" aria-label="Süre">' +
|
'<span class="yaktube-duration-badge" aria-label="Süre">' +
|
||||||
item.durationFormatted +
|
escapeHtml(item.durationFormatted || '') +
|
||||||
'</span>' +
|
'</span>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="yaktube-info">' +
|
'<div class="yaktube-info">' +
|
||||||
'<div>' +
|
'<div>' +
|
||||||
statusBadge +
|
statusBadge +
|
||||||
'<h4 class="yaktube-video-name" title="' +
|
'<h4 class="yaktube-video-name" title="' +
|
||||||
item.title +
|
safeTitleAttr +
|
||||||
'" style="margin:0; font-size:12px; font-weight:600; line-height:1.35;">' +
|
'" style="margin:0; font-size:12px; font-weight:600; line-height:1.35;">' +
|
||||||
item.title +
|
escapeHtml(item.title || '') +
|
||||||
'</h4>' +
|
'</h4>' +
|
||||||
'<div class="yaktube-channel-name" style="font-size:10px;">' +
|
'<div class="yaktube-channel-name" style="font-size:10px;">' +
|
||||||
item.channel +
|
escapeHtml(item.channel || '') +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
actionButton +
|
actionButton +
|
||||||
@@ -5653,19 +5837,42 @@ 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 = '';
|
||||||
|
if (smartPrefetchState.videoKey === currentActiveVideoKey) {
|
||||||
|
if (smartPrefetchState.status === 'preparing') {
|
||||||
|
prefetchStatusHtml =
|
||||||
|
'<span id="yaktube-smart-prefetch-status" style="font-size:11px; color:#38bdf8; background:rgba(56,189,248,0.12); border:1px solid rgba(56,189,248,0.3); padding:3px 9px; border-radius:20px; font-weight:600;">⚡ Sıradaki öneri arka planda hazırlanıyor...</span>';
|
||||||
|
} else if (smartPrefetchState.status === 'ready') {
|
||||||
|
prefetchStatusHtml =
|
||||||
|
'<span id="yaktube-smart-prefetch-status" style="font-size:11px; color:#10b981; background:rgba(16,185,129,0.14); border:1px solid rgba(16,185,129,0.35); padding:3px 9px; border-radius:20px; font-weight:700;">✅ Sıradaki öneri kesintisiz izlemeye hazır!</span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container.innerHTML =
|
container.innerHTML =
|
||||||
'<div class="yaktube-header">' +
|
'<div class="yaktube-header" style="flex-wrap:wrap; gap:8px;">' +
|
||||||
'<div class="yaktube-header-left">' +
|
'<div class="yaktube-header-left" style="flex-wrap:wrap; gap:8px;">' +
|
||||||
'<span class="yaktube-badge">🔥 ' +
|
'<span class="yaktube-badge">🔥 ' +
|
||||||
getInstanceName() +
|
escapeHtml(getInstanceName()) +
|
||||||
' Akıllı Önerilenler</span>' +
|
' Akıllı Önerilenler</span>' +
|
||||||
'<h3 class="yaktube-title-h3" style="margin:0; font-size:1.05rem;">"' +
|
'<h3 class="yaktube-title-h3" style="margin:0; font-size:1.05rem;">Size ve "' +
|
||||||
query +
|
escapeHtml(query) +
|
||||||
'" ile İlgili Öneriler (' +
|
'" İçeriğine Özel Öneriler (' +
|
||||||
headerCountText +
|
headerCountText +
|
||||||
')</h3>' +
|
')</h3>' +
|
||||||
|
prefetchStatusHtml +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<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' +
|
||||||
@@ -5674,7 +5881,8 @@ try {
|
|||||||
'<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 toggleBtn = document.getElementById('yaktube-related-toggle-more');
|
var toggleBtn = document.getElementById('yaktube-related-toggle-more');
|
||||||
if (toggleBtn) {
|
if (toggleBtn) {
|
||||||
@@ -5687,6 +5895,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 () {
|
||||||
@@ -5710,12 +5932,268 @@ try {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function triggerSilentBackgroundPrefetch(candidate, videoKey) {
|
||||||
|
if (!candidate || !candidate.url || !videoKey) return;
|
||||||
|
if (smartPrefetchState.videoKey === videoKey && smartPrefetchState.status !== 'idle') return;
|
||||||
|
|
||||||
|
// Avoid duplicate background imports in the same browser session
|
||||||
|
try {
|
||||||
|
var sessionKey = 'yaktube_prefetched_' + (candidate.id || candidate.url);
|
||||||
|
if (sessionStorage.getItem(sessionKey)) return;
|
||||||
|
sessionStorage.setItem(sessionKey, 'true');
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// Respect guest quota: do not trigger silent prefetch if guest has reached limit
|
||||||
|
var loggedIn = isUserLoggedIn();
|
||||||
|
var currentGuestCount = getGuestImportCount();
|
||||||
|
if (
|
||||||
|
!loggedIn &&
|
||||||
|
cachedGuestImportLimit !== null &&
|
||||||
|
cachedGuestImportLimit > 0 &&
|
||||||
|
currentGuestCount >= cachedGuestImportLimit
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smartPrefetchState.pollTimer) {
|
||||||
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
|
smartPrefetchState.pollTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
smartPrefetchState.videoKey = videoKey;
|
||||||
|
smartPrefetchState.status = 'preparing';
|
||||||
|
smartPrefetchState.readyUrl = null;
|
||||||
|
smartPrefetchState.readyTitle = candidate.title;
|
||||||
|
|
||||||
|
var relContainer = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (relContainer && cachedRelatedResults.length > 0) {
|
||||||
|
renderRelatedCards(relContainer, cachedRelatedResults, cachedRelatedQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
var headers = { 'Content-Type': 'application/json' };
|
||||||
|
try {
|
||||||
|
var token = localStorage.getItem('access_token');
|
||||||
|
if (token) headers['Authorization'] = 'Bearer ' + token;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
fetchPluginJson('/ondemand-import', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: headers,
|
||||||
|
body: JSON.stringify({
|
||||||
|
targetUrl: candidate.url,
|
||||||
|
title: candidate.title,
|
||||||
|
isAuthenticated: loggedIn,
|
||||||
|
guestImportCount: currentGuestCount
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(function (data) {
|
||||||
|
if (!data || !data.ok || !data.video || !data.video.id) {
|
||||||
|
smartPrefetchState.status = 'failed';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var videoId = data.video.id;
|
||||||
|
var videoUuid = data.video.uuid;
|
||||||
|
var attempts = 0;
|
||||||
|
|
||||||
|
smartPrefetchState.pollTimer = setInterval(function () {
|
||||||
|
attempts++;
|
||||||
|
if (currentActiveVideoKey !== videoKey || attempts > 45) {
|
||||||
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
|
smartPrefetchState.pollTimer = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchPluginJson('/status/' + videoId)
|
||||||
|
.then(function (sData) {
|
||||||
|
if (sData && (sData.isPublished || (sData.hasFiles && attempts >= 8))) {
|
||||||
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
|
smartPrefetchState.pollTimer = null;
|
||||||
|
var watchUrl = '/videos/watch/' + (sData.uuid || videoUuid);
|
||||||
|
smartPrefetchState.status = 'ready';
|
||||||
|
smartPrefetchState.readyUrl = watchUrl;
|
||||||
|
smartHasLocalMatch = true;
|
||||||
|
|
||||||
|
// Upgrade candidate inside cachedRelatedResults to ready-to-play local video
|
||||||
|
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: sData.uuid || videoUuid,
|
||||||
|
name: sData.name || candidate.title,
|
||||||
|
url: watchUrl
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var c = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (c && cachedRelatedResults.length > 0) {
|
||||||
|
renderRelatedCards(c, cachedRelatedResults, cachedRelatedQuery);
|
||||||
|
}
|
||||||
|
} else if (sData && sData.isFailed) {
|
||||||
|
clearInterval(smartPrefetchState.pollTimer);
|
||||||
|
smartPrefetchState.pollTimer = null;
|
||||||
|
smartPrefetchState.status = 'failed';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function () {});
|
||||||
|
}, 2500);
|
||||||
|
})
|
||||||
|
.catch(function () {
|
||||||
|
smartPrefetchState.status = 'failed';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSmartPrefetchOnTimeUpdate(video) {
|
||||||
|
if (!video || !currentActiveVideoKey || !smartPrefetchCandidate) return;
|
||||||
|
if (smartPrefetchState.videoKey === currentActiveVideoKey && smartPrefetchState.status !== 'idle') return;
|
||||||
|
if (cachedSmartPrefetchMode === 'disabled') return;
|
||||||
|
if (cachedSmartPrefetchMode === 'auto-when-no-local' && smartHasLocalMatch) return;
|
||||||
|
|
||||||
|
var cur = video.currentTime || 0;
|
||||||
|
var dur = video.duration || 0;
|
||||||
|
var threshold = dur > 0 && dur < 65 ? Math.max(8, dur * 0.35) : 25;
|
||||||
|
if (cur >= threshold) {
|
||||||
|
triggerSilentBackgroundPrefetch(smartPrefetchCandidate, currentActiveVideoKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearUpNextOverlay() {
|
||||||
|
if (upNextCountdownTimer) {
|
||||||
|
clearInterval(upNextCountdownTimer);
|
||||||
|
upNextCountdownTimer = null;
|
||||||
|
}
|
||||||
|
var existing = document.getElementById('yaktube-upnext-overlay');
|
||||||
|
if (existing) existing.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showPostVideoUpNextOverlay() {
|
||||||
|
clearUpNextOverlay();
|
||||||
|
if (!cachedRelatedResults || cachedRelatedResults.length === 0) return;
|
||||||
|
|
||||||
|
// Pick #1 ready local match first; otherwise #1 topic match
|
||||||
|
var nextItem =
|
||||||
|
cachedRelatedResults.find(function (it) {
|
||||||
|
return it && it.isDownloaded && it.localVideo && it.localVideo.url;
|
||||||
|
}) || cachedRelatedResults[0];
|
||||||
|
|
||||||
|
if (!nextItem) return;
|
||||||
|
|
||||||
|
var isReadyLocal = !!(nextItem.isDownloaded && nextItem.localVideo && nextItem.localVideo.url);
|
||||||
|
var banner = document.createElement('div');
|
||||||
|
banner.id = 'yaktube-upnext-overlay';
|
||||||
|
banner.setAttribute('role', 'region');
|
||||||
|
banner.setAttribute('aria-label', 'Sıradaki İlgili Video Önerisi');
|
||||||
|
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;';
|
||||||
|
|
||||||
|
var safeTitle = escapeHtml(nextItem.title || 'İlgili Video');
|
||||||
|
var safeChannel = escapeHtml(nextItem.channel || getInstanceName());
|
||||||
|
var safeBadge = escapeHtml(nextItem.reasonBadge || '🔥 Benzer İçerik');
|
||||||
|
var safeThumb = escapeHtml(nextItem.thumbnail || '/client/assets/images/default-thumbnail.jpg');
|
||||||
|
|
||||||
|
var secondsLeft = 6;
|
||||||
|
|
||||||
|
banner.innerHTML =
|
||||||
|
'<div style="display:flex; align-items:center; gap:14px; min-width:240px; flex:1;">' +
|
||||||
|
'<img src="' +
|
||||||
|
safeThumb +
|
||||||
|
'" 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="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="font-size:11px; color:#5eead4; font-weight:600;">' +
|
||||||
|
safeBadge +
|
||||||
|
'</span>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="font-size:14px; font-weight:700; color:#f8fafc; line-height:1.35;">' +
|
||||||
|
safeTitle +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="font-size:12px; color:#94a3b8; margin-top:2px;">' +
|
||||||
|
safeChannel +
|
||||||
|
(isReadyLocal
|
||||||
|
? ' • <span id="yaktube-upnext-countdown-txt" style="color:#ff8f37; font-weight:700;">' +
|
||||||
|
secondsLeft +
|
||||||
|
' saniye içinde başlıyor...</span>'
|
||||||
|
: '') +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div style="display:flex; align-items:center; gap:10px; flex-wrap:wrap;">' +
|
||||||
|
(isReadyLocal
|
||||||
|
? '<a id="yaktube-upnext-play-btn" href="' +
|
||||||
|
escapeHtml(nextItem.localVideo.url) +
|
||||||
|
'" 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-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') +
|
||||||
|
'</button>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
var actionBar = document.getElementById('yaktube-player-action-bar');
|
||||||
|
var relContainer = document.getElementById('yaktube-hybrid-related-container');
|
||||||
|
if (actionBar && actionBar.parentNode) {
|
||||||
|
actionBar.insertAdjacentElement('afterend', banner);
|
||||||
|
} else if (relContainer && relContainer.parentNode) {
|
||||||
|
relContainer.parentNode.insertBefore(banner, relContainer);
|
||||||
|
} else {
|
||||||
|
document.body.appendChild(banner);
|
||||||
|
}
|
||||||
|
|
||||||
|
var cancelBtn = document.getElementById('yaktube-upnext-cancel-btn');
|
||||||
|
if (cancelBtn) {
|
||||||
|
cancelBtn.addEventListener('click', function () {
|
||||||
|
if (upNextCountdownTimer) {
|
||||||
|
clearInterval(upNextCountdownTimer);
|
||||||
|
upNextCountdownTimer = null;
|
||||||
|
var cdTxt = document.getElementById('yaktube-upnext-countdown-txt');
|
||||||
|
if (cdTxt) cdTxt.textContent = 'Otomatik geçiş durduruldu';
|
||||||
|
cancelBtn.textContent = '✕ Kapat';
|
||||||
|
announce('Otomatik video geçişi durduruldu.');
|
||||||
|
} else {
|
||||||
|
clearUpNextOverlay();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var importBtn = document.getElementById('yaktube-upnext-import-btn');
|
||||||
|
if (importBtn) {
|
||||||
|
importBtn.addEventListener('click', function () {
|
||||||
|
clearUpNextOverlay();
|
||||||
|
handleImport(nextItem.url, importBtn, nextItem.title);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isReadyLocal) {
|
||||||
|
announce(
|
||||||
|
'Video sona erdi. Sıradaki ilgili video 6 saniye içinde başlayacak: ' +
|
||||||
|
nextItem.title +
|
||||||
|
'. Durdurmak için Otomatik Geçişi Durdur düğmesine basabilirsiniz.'
|
||||||
|
);
|
||||||
|
upNextCountdownTimer = setInterval(function () {
|
||||||
|
secondsLeft--;
|
||||||
|
var cdTxt = document.getElementById('yaktube-upnext-countdown-txt');
|
||||||
|
if (cdTxt && secondsLeft > 0) {
|
||||||
|
cdTxt.textContent = secondsLeft + ' saniye içinde başlıyor...';
|
||||||
|
}
|
||||||
|
if (secondsLeft <= 0) {
|
||||||
|
clearInterval(upNextCountdownTimer);
|
||||||
|
upNextCountdownTimer = null;
|
||||||
|
window.location.href = nextItem.localVideo.url;
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
announce('Video sona erdi. Sıradaki ilgili öneri: ' + nextItem.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkAndInjectRelatedVideos(forceReload) {
|
function checkAndInjectRelatedVideos(forceReload) {
|
||||||
var isWatchPage =
|
var isWatchPage =
|
||||||
window.location.pathname.includes('/videos/watch/') || window.location.pathname.startsWith('/w/');
|
window.location.pathname.includes('/videos/watch/') || window.location.pathname.startsWith('/w/');
|
||||||
if (!isWatchPage) {
|
if (!isWatchPage) {
|
||||||
var existing = document.getElementById('yaktube-hybrid-related-container');
|
var existing = document.getElementById('yaktube-hybrid-related-container');
|
||||||
if (existing) existing.remove();
|
if (existing) existing.remove();
|
||||||
|
clearUpNextOverlay();
|
||||||
currentActiveVideoKey = null;
|
currentActiveVideoKey = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -5733,6 +6211,13 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var currentPath = window.location.pathname;
|
var currentPath = window.location.pathname;
|
||||||
|
var uuidMatch =
|
||||||
|
currentPath.match(/\/videos\/watch\/([a-zA-Z0-9_-]+)/) || currentPath.match(/\/w\/([a-zA-Z0-9_-]+)/);
|
||||||
|
var currentUuid = uuidMatch ? uuidMatch[1] : '';
|
||||||
|
|
||||||
|
var channelElem = document.querySelector('.video-channel-name, .channel-name, .actor-name, a.actor-link');
|
||||||
|
var rawChannel = channelElem ? (channelElem.textContent || '').trim() : '';
|
||||||
|
|
||||||
var thisVideoKey = currentPath + '::' + rawTitle.toLowerCase();
|
var thisVideoKey = currentPath + '::' + rawTitle.toLowerCase();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -5740,22 +6225,23 @@ try {
|
|||||||
thisVideoKey === currentActiveVideoKey &&
|
thisVideoKey === currentActiveVideoKey &&
|
||||||
document.getElementById('yaktube-hybrid-related-container')
|
document.getElementById('yaktube-hybrid-related-container')
|
||||||
) {
|
) {
|
||||||
|
suppressUnrelatedNativeRecommendations();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFetchingRelated) return;
|
if (isFetchingRelated) return;
|
||||||
isFetchingRelated = true;
|
isFetchingRelated = true;
|
||||||
|
clearUpNextOverlay();
|
||||||
|
|
||||||
var cleanTopic = rawTitle
|
var cleanTopic = cleanVideoTopicString(rawTitle);
|
||||||
.replace(/YakTube/gi, '')
|
|
||||||
.replace(/[\(\[].*?[\)\]]/g, '')
|
|
||||||
.replace(/official video|video klip|klip|hd|4k|lyric video|audio|remix|feat\.?|ft\.?/gi, '')
|
|
||||||
.trim();
|
|
||||||
|
|
||||||
var words = cleanTopic.split(/\s+/).filter(function (w) {
|
var words = cleanTopic.split(/\s+/).filter(function (w) {
|
||||||
return w.length > 2;
|
return w.length >= 2;
|
||||||
});
|
});
|
||||||
var searchQuery = words.slice(0, 3).join(' ') || cleanTopic;
|
var searchQuery = words.slice(0, 4).join(' ') || cleanTopic || rawTitle;
|
||||||
|
|
||||||
|
// Record current video in user watch history & gather user interest history
|
||||||
|
var userHistoryList = getUserInterestHistory(searchQuery);
|
||||||
|
recordWatchedVideo(currentUuid, rawTitle, rawChannel);
|
||||||
|
|
||||||
var container = document.getElementById('yaktube-hybrid-related-container');
|
var container = document.getElementById('yaktube-hybrid-related-container');
|
||||||
if (!container) {
|
if (!container) {
|
||||||
@@ -5792,61 +6278,91 @@ try {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suppressUnrelatedNativeRecommendations();
|
||||||
|
|
||||||
container.innerHTML =
|
container.innerHTML =
|
||||||
'<div class="yaktube-header">' +
|
'<div class="yaktube-header">' +
|
||||||
'<div class="yaktube-header-left">' +
|
'<div class="yaktube-header-left">' +
|
||||||
'<span class="yaktube-badge">🔥 ' +
|
'<span class="yaktube-badge">🔥 ' +
|
||||||
getInstanceName() +
|
escapeHtml(getInstanceName()) +
|
||||||
' Akıllı Önerilenler</span>' +
|
' Akıllı Önerilenler</span>' +
|
||||||
'<h3 class="yaktube-title-h3" style="margin:0; font-size:1.05rem;">"' +
|
'<h3 class="yaktube-title-h3" style="margin:0; font-size:1.05rem;">"' +
|
||||||
searchQuery +
|
escapeHtml(searchQuery) +
|
||||||
'" için Öneriler Taranıyor...</h3>' +
|
'" ve İzleme Geçmişinize Göre Öneriler Hazırlanıyor...</h3>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div style="padding: 18px; text-align: center; color: #ff8f37;">' +
|
'<div style="padding: 18px; text-align: center; color: #ff8f37;">' +
|
||||||
'<div class="yaktube-spinner" style="width: 30px; height: 30px; border-width: 3px;" aria-hidden="true"></div>' +
|
'<div class="yaktube-spinner" style="width: 30px; height: 30px; border-width: 3px;" aria-hidden="true"></div>' +
|
||||||
'<div style="margin-top: 10px; font-size: 13px;">YouTube ve Fediverse\'deki en alakalı videolar getiriliyor...</div>' +
|
'<div style="margin-top: 10px; font-size: 13px;">Bu videoyla, kategorisiyle ve geçmişinizle en alakalı videolar analiz ediliyor...</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
announce(searchQuery + ' için ilgili video önerileri yükleniyor.');
|
announce(searchQuery + ' için ilgili video önerileri yükleniyor.');
|
||||||
|
|
||||||
fetchPluginJson('/youtube-search?q=' + encodeURIComponent(searchQuery))
|
var smartUrl =
|
||||||
|
'/smart-recommendations?uuid=' +
|
||||||
|
encodeURIComponent(currentUuid) +
|
||||||
|
'&title=' +
|
||||||
|
encodeURIComponent(rawTitle) +
|
||||||
|
'&channel=' +
|
||||||
|
encodeURIComponent(rawChannel) +
|
||||||
|
'&history=' +
|
||||||
|
encodeURIComponent(userHistoryList.join('|'));
|
||||||
|
|
||||||
|
fetchPluginJson(smartUrl)
|
||||||
|
.catch(function () {
|
||||||
|
return fetchPluginJson('/youtube-search?q=' + encodeURIComponent(searchQuery));
|
||||||
|
})
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
if (data && typeof data.guestImportLimit === 'number') {
|
if (data && typeof data.guestImportLimit === 'number') {
|
||||||
cachedGuestImportLimit = data.guestImportLimit;
|
cachedGuestImportLimit = data.guestImportLimit;
|
||||||
}
|
}
|
||||||
var rawResults = data.results || [];
|
if (data && typeof data.smartPrefetchMode === 'string') {
|
||||||
|
cachedSmartPrefetchMode = data.smartPrefetchMode;
|
||||||
|
}
|
||||||
|
if (data && typeof data.federatedRecommendationsMode === 'string') {
|
||||||
|
cachedFederatedRecommendationsMode = data.federatedRecommendationsMode;
|
||||||
|
}
|
||||||
|
smartHasLocalMatch = Boolean(data && data.hasLocalMatch);
|
||||||
|
smartPrefetchCandidate = (data && data.topPrefetchCandidate) || null;
|
||||||
|
if (smartPrefetchState.videoKey !== thisVideoKey) {
|
||||||
|
smartPrefetchState.videoKey = thisVideoKey;
|
||||||
|
smartPrefetchState.status = 'idle';
|
||||||
|
}
|
||||||
|
|
||||||
|
var rawResults = (data && data.results) || [];
|
||||||
var normalizedCurrentTitle = rawTitle.toLowerCase().trim();
|
var normalizedCurrentTitle = rawTitle.toLowerCase().trim();
|
||||||
|
|
||||||
var uniqueResults = [];
|
var uniqueResults = [];
|
||||||
var seenIds = {};
|
var seenIds = {};
|
||||||
|
|
||||||
rawResults.forEach(function (item) {
|
rawResults.forEach(function (item) {
|
||||||
if (item && item.id && !seenIds[item.id] && item.title) {
|
var itemKey = (item && (item.id || (item.localVideo && item.localVideo.uuid))) || '';
|
||||||
|
if (item && itemKey && !seenIds[itemKey] && item.title) {
|
||||||
var itemTitle = item.title.toLowerCase().trim();
|
var itemTitle = item.title.toLowerCase().trim();
|
||||||
if (itemTitle !== normalizedCurrentTitle && !itemTitle.includes(normalizedCurrentTitle)) {
|
if (itemTitle !== normalizedCurrentTitle) {
|
||||||
seenIds[item.id] = true;
|
seenIds[itemKey] = true;
|
||||||
uniqueResults.push(item);
|
uniqueResults.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cachedRelatedResults = uniqueResults;
|
cachedRelatedResults = uniqueResults;
|
||||||
cachedRelatedQuery = searchQuery;
|
cachedRelatedQuery = (data && data.query) || searchQuery;
|
||||||
currentActiveVideoKey = thisVideoKey;
|
currentActiveVideoKey = thisVideoKey;
|
||||||
relatedShowAll = false;
|
relatedShowAll = false;
|
||||||
|
showNativeFediverseDrawer = false;
|
||||||
|
|
||||||
renderRelatedCards(container, uniqueResults, searchQuery);
|
renderRelatedCards(container, uniqueResults, cachedRelatedQuery);
|
||||||
|
|
||||||
var initialCount = Math.min(uniqueResults.length, 12);
|
var initialCount = Math.min(uniqueResults.length, 12);
|
||||||
if (uniqueResults.length === 0) {
|
if (uniqueResults.length === 0) {
|
||||||
announce(searchQuery + ' için ilgili öneri bulunamadı.');
|
announce(cachedRelatedQuery + ' için ilgili öneri bulunamadı.');
|
||||||
} else {
|
} else {
|
||||||
announce(
|
announce(
|
||||||
searchQuery +
|
cachedRelatedQuery +
|
||||||
' için ' +
|
' için ' +
|
||||||
initialCount +
|
initialCount +
|
||||||
' öneri gösteriliyor' +
|
' alakalı öneri listelendi' +
|
||||||
(uniqueResults.length > 12 ? ', toplam ' + uniqueResults.length + ' video bulundu' : '') +
|
(uniqueResults.length > 12 ? ', toplam ' + uniqueResults.length + ' video bulundu' : '') +
|
||||||
'.'
|
'.'
|
||||||
);
|
);
|
||||||
@@ -6122,6 +6638,11 @@ try {
|
|||||||
headerButtons.prepend(installBtn);
|
headerButtons.prepend(installBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isYakNetSsoEnabled() {
|
||||||
|
if (cachedYakNetSsoEnabled !== null) return cachedYakNetSsoEnabled;
|
||||||
|
return isOfficialYakTubeServer();
|
||||||
|
}
|
||||||
|
|
||||||
function isOfficialYakTubeServer() {
|
function isOfficialYakTubeServer() {
|
||||||
var host = (window.location.hostname || '').toLowerCase();
|
var host = (window.location.hostname || '').toLowerCase();
|
||||||
// Sadece ve sadece resmi YakTube alan adında veya yerel test ortamında çalışsın
|
// Sadece ve sadece resmi YakTube alan adında veya yerel test ortamında çalışsın
|
||||||
@@ -6231,16 +6752,23 @@ try {
|
|||||||
videoState.hasPlayed = true;
|
videoState.hasPlayed = true;
|
||||||
videoState.explicitlyPausedByClick = false;
|
videoState.explicitlyPausedByClick = false;
|
||||||
videoState.lastPlayTime = Date.now();
|
videoState.lastPlayTime = Date.now();
|
||||||
|
clearUpNextOverlay();
|
||||||
updateMediaSessionMetadata(video);
|
updateMediaSessionMetadata(video);
|
||||||
});
|
});
|
||||||
|
|
||||||
video.addEventListener('ended', function () {
|
video.addEventListener('ended', function () {
|
||||||
videoState.hasPlayed = false;
|
videoState.hasPlayed = false;
|
||||||
videoState.explicitlyPausedByClick = true;
|
videoState.explicitlyPausedByClick = true;
|
||||||
|
try {
|
||||||
|
showPostVideoUpNextOverlay();
|
||||||
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
video.addEventListener('timeupdate', function () {
|
video.addEventListener('timeupdate', function () {
|
||||||
updateMediaSessionPosition(video);
|
updateMediaSessionPosition(video);
|
||||||
|
try {
|
||||||
|
checkSmartPrefetchOnTimeUpdate(video);
|
||||||
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,16 @@ const DEFAULT_BLOCKED_KEYWORDS = [
|
|||||||
'sheer',
|
'sheer',
|
||||||
'babydoll',
|
'babydoll',
|
||||||
'gravure',
|
'gravure',
|
||||||
|
'bra',
|
||||||
|
'plus-size bra',
|
||||||
|
'try on',
|
||||||
|
'try-on',
|
||||||
|
'underwear',
|
||||||
|
'panties',
|
||||||
|
'thong',
|
||||||
|
'cleavage',
|
||||||
|
'twerk',
|
||||||
|
'cameltoe',
|
||||||
'nude',
|
'nude',
|
||||||
'nudes',
|
'nudes',
|
||||||
'nudist',
|
'nudist',
|
||||||
@@ -136,6 +146,7 @@ const DEFAULT_BLOCKED_KEYWORDS = [
|
|||||||
'+18',
|
'+18',
|
||||||
'nsfw',
|
'nsfw',
|
||||||
'xxx',
|
'xxx',
|
||||||
|
'xvideos',
|
||||||
'onlyfans',
|
'onlyfans',
|
||||||
'sissy',
|
'sissy',
|
||||||
'seduce',
|
'seduce',
|
||||||
@@ -181,8 +192,17 @@ function isContentBlocked(text, list = DEFAULT_BLOCKED_KEYWORDS) {
|
|||||||
async function register({ registerHook, getRouter, registerSetting, settingsManager, peertubeHelpers, logger }) {
|
async function register({ registerHook, getRouter, registerSetting, settingsManager, peertubeHelpers, logger }) {
|
||||||
const router = getRouter();
|
const router = getRouter();
|
||||||
|
|
||||||
// YakTube Bildirim Filtresi: Başarılı video içe aktarımları (type 7) bildirim kutusunu doldurmasın,
|
let guestImportLimit = 5;
|
||||||
// Sadece başarısız olanlar (type 8 / MY_VIDEO_IMPORT_ERROR) bildirim olarak düşsün
|
let maxDiskUsagePercent = 85;
|
||||||
|
let yaknetSsoEnabled = true;
|
||||||
|
let smartPrefetchMode = 'auto-when-no-local';
|
||||||
|
let federatedRecommendationsMode = 'smart-relevant';
|
||||||
|
let customChannelId = '';
|
||||||
|
let customYtDlpPath = '';
|
||||||
|
let safeSearchEnabled = true;
|
||||||
|
let blockedKeywordsList = [...DEFAULT_BLOCKED_KEYWORDS];
|
||||||
|
|
||||||
|
// YakTube Bildirim Filtresi & SafeSearch Video Listesi Filtresi
|
||||||
if (typeof registerHook === 'function') {
|
if (typeof registerHook === 'function') {
|
||||||
registerHook({
|
registerHook({
|
||||||
target: 'filter:notifier.notification.enabled.result',
|
target: 'filter:notifier.notification.enabled.result',
|
||||||
@@ -196,20 +216,96 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (logger)
|
|
||||||
logger.info(
|
const filterVideoListResult = async result => {
|
||||||
'[YakTube OnDemand] Registered filter:notifier.notification.enabled.result (suppressing successful import notifications).'
|
if (!safeSearchEnabled || !result || !Array.isArray(result.data)) return result;
|
||||||
);
|
const beforeLen = result.data.length;
|
||||||
|
result.data = result.data.filter(v => !v || !isContentBlocked(v.name || '', blockedKeywordsList));
|
||||||
|
const diff = beforeLen - result.data.length;
|
||||||
|
if (diff > 0 && typeof result.total === 'number') {
|
||||||
|
result.total = Math.max(0, result.total - diff);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
registerHook({
|
||||||
|
target: 'filter:api.videos.list.result',
|
||||||
|
handler: filterVideoListResult
|
||||||
|
});
|
||||||
|
|
||||||
|
registerHook({
|
||||||
|
target: 'filter:api.overviews.videos.list.result',
|
||||||
|
handler: filterVideoListResult
|
||||||
|
});
|
||||||
|
|
||||||
|
if (logger) logger.info('[YakTube OnDemand] Registered notification filter & SafeSearch video list hooks.');
|
||||||
}
|
}
|
||||||
|
|
||||||
let guestImportLimit = 5;
|
|
||||||
let maxDiskUsagePercent = 85;
|
|
||||||
let customChannelId = '';
|
|
||||||
let customYtDlpPath = '';
|
|
||||||
let safeSearchEnabled = true;
|
|
||||||
let blockedKeywordsList = [...DEFAULT_BLOCKED_KEYWORDS];
|
|
||||||
|
|
||||||
if (typeof registerSetting === 'function') {
|
if (typeof registerSetting === 'function') {
|
||||||
|
registerSetting({
|
||||||
|
name: 'enable-yaknet-sso',
|
||||||
|
label: 'YakNet SSO ve Merkezi Hesap Entegrasyonu',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{ label: 'Açık (Resmi YakNet Giriş & Hesap Entegrasyonu)', value: 'true' },
|
||||||
|
{ label: 'Kapalı (Standart Bağımsız PeerTube Girişi)', value: 'false' }
|
||||||
|
],
|
||||||
|
description:
|
||||||
|
'YakNet SSO ile tek tıkla oturum açma, YakNet hesap kartı ve merkezi arama geçmişi eşitlemesini etkinleştirir. Bu özelliği kullanmak için peertube-plugin-auth-yaknet eklentisinin de kurulu olması önerilir. Kapatıldığında platform standart bağımsız PeerTube hesap sistemiyle çalışır.',
|
||||||
|
private: false,
|
||||||
|
default: 'true'
|
||||||
|
});
|
||||||
|
|
||||||
|
registerSetting({
|
||||||
|
name: 'smart-prefetch-mode',
|
||||||
|
label: 'Akıllı Arka Plan Öneri Hazırlama (Smart Pre-Fetch)',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Otomatik (Önerilen — Yerel benzer video yoksa en alakalı 1. öneriyi arka planda hazırla)',
|
||||||
|
value: 'auto-when-no-local'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Her Zaman (İzlenen her videoda en alakalı 1. YouTube önerisini arka planda hazırla)',
|
||||||
|
value: 'always'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Kapalı (Sadece kullanıcı İndir ve İzle butonuna tıkladığında aktar)',
|
||||||
|
value: 'disabled'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
description:
|
||||||
|
'İzleyici bir videoyu en az 25 saniye izlediğinde, sunucuda o konuyla ilgili yerel video yoksa en alakalı 1. YouTube önerisini arka planda sessizce hazırlar. Böylece video bittiğinde alakasız videolar yerine doğrudan ilgili içerik kesintisiz oynatılır. Sunucu kaynaklarını korumak isteyen yöneticiler bu ayarı kapatabilir.',
|
||||||
|
private: false,
|
||||||
|
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)',
|
||||||
@@ -382,7 +478,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const item of lines) {
|
for (const item of lines) {
|
||||||
const lower = item.toLowerCase();
|
const lower = item.toLocaleLowerCase('tr').replace(/i\u0307/g, 'i');
|
||||||
if (lower === 'tümü' || lower === 'all' || lower === 'hepsi') {
|
if (lower === 'tümü' || lower === 'all' || lower === 'hepsi') {
|
||||||
result.push({
|
result.push({
|
||||||
label: item,
|
label: item,
|
||||||
@@ -550,6 +646,33 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
parsedHomeCategories = parseHomeCategories(rawHomeCategories);
|
parsedHomeCategories = parseHomeCategories(rawHomeCategories);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ssoVal = await settingsManager.getSetting('enable-yaknet-sso');
|
||||||
|
if (ssoVal !== undefined && ssoVal !== null) {
|
||||||
|
yaknetSsoEnabled = String(ssoVal).trim() !== 'false';
|
||||||
|
} else {
|
||||||
|
yaknetSsoEnabled = true;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pfVal = await settingsManager.getSetting('smart-prefetch-mode');
|
||||||
|
if (pfVal && ['auto-when-no-local', 'always', 'disabled'].includes(String(pfVal).trim())) {
|
||||||
|
smartPrefetchMode = String(pfVal).trim();
|
||||||
|
} else {
|
||||||
|
smartPrefetchMode = 'auto-when-no-local';
|
||||||
|
}
|
||||||
|
} 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) {
|
||||||
@@ -564,7 +687,11 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
.split(/[\n,]+/)
|
.split(/[\n,]+/)
|
||||||
.map(w => w.trim().toLowerCase())
|
.map(w => w.trim().toLowerCase())
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
if (list.length > 0) blockedKeywordsList = list;
|
if (list.length > 0) {
|
||||||
|
blockedKeywordsList = Array.from(new Set([...DEFAULT_BLOCKED_KEYWORDS, ...list]));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
blockedKeywordsList = [...DEFAULT_BLOCKED_KEYWORDS];
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
@@ -986,6 +1113,9 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
await loadPluginSettings();
|
await loadPluginSettings();
|
||||||
return res.json({
|
return res.json({
|
||||||
ok: true,
|
ok: true,
|
||||||
|
yaknetSsoEnabled,
|
||||||
|
smartPrefetchMode,
|
||||||
|
federatedRecommendationsMode,
|
||||||
guestImportLimit,
|
guestImportLimit,
|
||||||
maxDiskUsagePercent,
|
maxDiskUsagePercent,
|
||||||
safeSearchEnabled,
|
safeSearchEnabled,
|
||||||
@@ -1026,6 +1156,88 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
return res.json(result);
|
return res.json(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reusable YouTube Raw Search Helper (with Cache & SafeSearch)
|
||||||
|
function searchYouTubeRaw(query, maxCount = 24) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const cleanQ = (query || '').trim();
|
||||||
|
if (!cleanQ || cleanQ.length < 2) return resolve({ results: [], cached: false });
|
||||||
|
if (safeSearchEnabled && isContentBlocked(cleanQ, blockedKeywordsList)) {
|
||||||
|
return resolve({ results: [], cached: false, blocked: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheKey = `${cleanQ.toLocaleLowerCase('tr')}__${maxCount}`;
|
||||||
|
const cached = getCached(cacheKey) || (maxCount <= 24 ? getCached(cleanQ) : null);
|
||||||
|
if (cached) {
|
||||||
|
const filteredCached = safeSearchEnabled
|
||||||
|
? cached.filter(e => !isContentBlocked(e.title, blockedKeywordsList))
|
||||||
|
: cached;
|
||||||
|
return resolve({ results: filteredCached.slice(0, maxCount), cached: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const ytdlpPath = resolveYtDlpPath(logger, customYtDlpPath);
|
||||||
|
const args = [
|
||||||
|
`ytsearch${maxCount}:${cleanQ}`,
|
||||||
|
'--dump-single-json',
|
||||||
|
'--flat-playlist',
|
||||||
|
'--skip-download',
|
||||||
|
'--no-warnings'
|
||||||
|
];
|
||||||
|
|
||||||
|
execFile(ytdlpPath, args, { maxBuffer: 10 * 1024 * 1024, timeout: 15000 }, (error, stdout) => {
|
||||||
|
if (error) {
|
||||||
|
return reject(error);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const rawStr = stdout.trim();
|
||||||
|
const startIdx = rawStr.indexOf('{');
|
||||||
|
const endIdx = rawStr.lastIndexOf('}');
|
||||||
|
if (startIdx === -1 || endIdx === -1) {
|
||||||
|
throw new Error('No JSON object found in output');
|
||||||
|
}
|
||||||
|
const json = JSON.parse(rawStr.substring(startIdx, endIdx + 1));
|
||||||
|
const entries = json.entries || [];
|
||||||
|
let rawResults = entries
|
||||||
|
.filter(e => e && e.id)
|
||||||
|
.map(e => {
|
||||||
|
const duration = e.duration || 0;
|
||||||
|
const mins = Math.floor(duration / 60);
|
||||||
|
const secs = Math.floor(duration % 60);
|
||||||
|
const isLive = e.is_live === true || e.live_status === 'is_live' || (!e.duration && e.was_live !== true);
|
||||||
|
const durationFormatted = isLive
|
||||||
|
? 'CANLI'
|
||||||
|
: (mins < 10 ? '0' + mins : mins) + ':' + (secs < 10 ? '0' + secs : secs);
|
||||||
|
let thumbnail =
|
||||||
|
e.thumbnail || (e.thumbnails && e.thumbnails.length ? e.thumbnails[e.thumbnails.length - 1].url : '');
|
||||||
|
if (!thumbnail && e.id) {
|
||||||
|
thumbnail = `https://i.ytimg.com/vi/${e.id}/hqdefault.jpg`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: e.id,
|
||||||
|
title: e.title,
|
||||||
|
channel: e.uploader || e.channel || 'YouTube',
|
||||||
|
duration,
|
||||||
|
durationFormatted,
|
||||||
|
isLive,
|
||||||
|
url: e.url || `https://www.youtube.com/watch?v=${e.id}`,
|
||||||
|
thumbnail
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (safeSearchEnabled) {
|
||||||
|
rawResults = rawResults.filter(e => !isContentBlocked(e.title, blockedKeywordsList));
|
||||||
|
}
|
||||||
|
|
||||||
|
setCache(cacheKey, rawResults);
|
||||||
|
if (maxCount >= 18) setCache(cleanQ, rawResults);
|
||||||
|
return resolve({ results: rawResults, cached: false });
|
||||||
|
} catch (parseErr) {
|
||||||
|
return reject(parseErr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 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();
|
||||||
@@ -1044,78 +1256,569 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const cached = getCached(query);
|
try {
|
||||||
if (cached) {
|
const { results: rawResults, cached } = await searchYouTubeRaw(query, 24);
|
||||||
const filteredCached = safeSearchEnabled
|
const enrichedResults = await enrichResultsWithLocalStatus(rawResults);
|
||||||
? cached.filter(e => !isContentBlocked(e.title, blockedKeywordsList))
|
return res.json({ results: enrichedResults, cached, guestImportLimit });
|
||||||
: cached;
|
} catch (err) {
|
||||||
const enriched = await enrichResultsWithLocalStatus(filteredCached);
|
if (logger) logger.error('YouTube search error: ' + err.message);
|
||||||
return res.json({ results: enriched, cached: true, guestImportLimit });
|
return res.status(500).json({ error: 'Search failed', details: err.message });
|
||||||
}
|
}
|
||||||
|
|
||||||
const ytdlpPath = resolveYtDlpPath(logger, customYtDlpPath);
|
|
||||||
const args = ['ytsearch24:' + query, '--dump-single-json', '--flat-playlist', '--skip-download', '--no-warnings'];
|
|
||||||
|
|
||||||
execFile(ytdlpPath, args, { maxBuffer: 10 * 1024 * 1024, timeout: 15000 }, async (error, stdout) => {
|
|
||||||
if (error) {
|
|
||||||
if (logger) logger.error('YouTube search error: ' + error.message);
|
|
||||||
return res.status(500).json({ error: 'Search failed', details: error.message });
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const rawStr = stdout.trim();
|
|
||||||
const startIdx = rawStr.indexOf('{');
|
|
||||||
const endIdx = rawStr.lastIndexOf('}');
|
|
||||||
if (startIdx === -1 || endIdx === -1) {
|
|
||||||
throw new Error('No JSON object found in output');
|
|
||||||
}
|
|
||||||
const json = JSON.parse(rawStr.substring(startIdx, endIdx + 1));
|
|
||||||
const entries = json.entries || [];
|
|
||||||
let rawResults = entries
|
|
||||||
.filter(e => e && e.id)
|
|
||||||
.map(e => {
|
|
||||||
const duration = e.duration || 0;
|
|
||||||
const mins = Math.floor(duration / 60);
|
|
||||||
const secs = Math.floor(duration % 60);
|
|
||||||
const isLive = e.is_live === true || e.live_status === 'is_live' || (!e.duration && e.was_live !== true);
|
|
||||||
const durationFormatted = isLive
|
|
||||||
? 'CANLI'
|
|
||||||
: (mins < 10 ? '0' + mins : mins) + ':' + (secs < 10 ? '0' + secs : secs);
|
|
||||||
let thumbnail =
|
|
||||||
e.thumbnail || (e.thumbnails && e.thumbnails.length ? e.thumbnails[e.thumbnails.length - 1].url : '');
|
|
||||||
if (!thumbnail && e.id) {
|
|
||||||
thumbnail = `https://i.ytimg.com/vi/${e.id}/hqdefault.jpg`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: e.id,
|
|
||||||
title: e.title,
|
|
||||||
channel: e.uploader || e.channel || 'YouTube',
|
|
||||||
duration,
|
|
||||||
durationFormatted,
|
|
||||||
isLive,
|
|
||||||
url: e.url || `https://www.youtube.com/watch?v=${e.id}`,
|
|
||||||
thumbnail
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
if (safeSearchEnabled) {
|
|
||||||
rawResults = rawResults.filter(e => !isContentBlocked(e.title, blockedKeywordsList));
|
|
||||||
}
|
|
||||||
|
|
||||||
setCache(query, rawResults);
|
|
||||||
const enrichedResults = await enrichResultsWithLocalStatus(rawResults);
|
|
||||||
return res.json({ results: enrichedResults, cached: false, guestImportLimit });
|
|
||||||
} catch (parseErr) {
|
|
||||||
if (logger) logger.error('JSON parse error in search: ' + parseErr.message);
|
|
||||||
return res.status(500).json({ error: 'Failed to parse search results' });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
router.get('/youtube-search', handleYouTubeSearch);
|
router.get('/youtube-search', handleYouTubeSearch);
|
||||||
router.get('/search', handleYouTubeSearch);
|
router.get('/search', handleYouTubeSearch);
|
||||||
|
|
||||||
|
// 2.5. YouTube-Style Smart Recommendation & Personalized Up-Next Engine
|
||||||
|
const RECOMMENDATION_STOP_WORDS = new Set([
|
||||||
|
'official',
|
||||||
|
'video',
|
||||||
|
'klip',
|
||||||
|
'music',
|
||||||
|
'audio',
|
||||||
|
'lyrics',
|
||||||
|
'lyric',
|
||||||
|
'sözleri',
|
||||||
|
'sozleri',
|
||||||
|
'şarkı',
|
||||||
|
'sarki',
|
||||||
|
'hd',
|
||||||
|
'4k',
|
||||||
|
'1080p',
|
||||||
|
'full',
|
||||||
|
'izle',
|
||||||
|
'yeni',
|
||||||
|
'bölüm',
|
||||||
|
'bolum',
|
||||||
|
've',
|
||||||
|
'ile',
|
||||||
|
'için',
|
||||||
|
'icin',
|
||||||
|
'bir',
|
||||||
|
'bu',
|
||||||
|
'da',
|
||||||
|
'de',
|
||||||
|
'mi',
|
||||||
|
'mu',
|
||||||
|
'the',
|
||||||
|
'and',
|
||||||
|
'for',
|
||||||
|
'with',
|
||||||
|
'from',
|
||||||
|
'feat',
|
||||||
|
'ft',
|
||||||
|
'prod',
|
||||||
|
'remix',
|
||||||
|
'version',
|
||||||
|
'canlı',
|
||||||
|
'canli',
|
||||||
|
'performans',
|
||||||
|
'konser',
|
||||||
|
'yaktube',
|
||||||
|
'youtube'
|
||||||
|
]);
|
||||||
|
|
||||||
|
function extractRecommendationKeywords(text) {
|
||||||
|
const norm = normalizeTitleForMatch(text);
|
||||||
|
if (!norm) return [];
|
||||||
|
return norm
|
||||||
|
.split(/\s+/)
|
||||||
|
.map(w => w.replace(/i\u0307/g, 'i'))
|
||||||
|
.filter(w => w.length >= 3 && !RECOMMENDATION_STOP_WORDS.has(w) && !/^\d+$/.test(w));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDurationLabel(seconds) {
|
||||||
|
const dur = Math.max(0, Math.floor(Number(seconds) || 0));
|
||||||
|
const mins = Math.floor(dur / 60);
|
||||||
|
const secs = dur % 60;
|
||||||
|
return (mins < 10 ? '0' + mins : String(mins)) + ':' + (secs < 10 ? '0' + secs : String(secs));
|
||||||
|
}
|
||||||
|
|
||||||
|
router.get('/smart-recommendations', async (req, res) => {
|
||||||
|
await loadPluginSettings();
|
||||||
|
const rawUuid = (req.query.uuid || '').trim();
|
||||||
|
const rawTitle = (req.query.title || '').trim();
|
||||||
|
const rawChannel = (req.query.channel || '').trim();
|
||||||
|
const rawHistory = (req.query.history || '').trim();
|
||||||
|
|
||||||
|
if (!rawTitle && !rawUuid) {
|
||||||
|
return res.json({
|
||||||
|
ok: true,
|
||||||
|
results: [],
|
||||||
|
hasLocalMatch: false,
|
||||||
|
smartPrefetchMode,
|
||||||
|
guestImportLimit
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolvedUuid = rawUuid ? shortToUuid(rawUuid) : '';
|
||||||
|
let currentVideoRow = null;
|
||||||
|
|
||||||
|
if (resolvedUuid) {
|
||||||
|
try {
|
||||||
|
const currentRows = await dbQuery(
|
||||||
|
`SELECT v.id, v.uuid, v.name, v.category, v."channelId", vi."targetUrl"
|
||||||
|
FROM "video" v
|
||||||
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
|
WHERE v.uuid::text = $1 OR v.id::text = $2
|
||||||
|
LIMIT 1`,
|
||||||
|
[resolvedUuid, rawUuid]
|
||||||
|
);
|
||||||
|
if (currentRows.length > 0) {
|
||||||
|
currentVideoRow = currentRows[0];
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const effectiveTitle = rawTitle || (currentVideoRow && currentVideoRow.name) || '';
|
||||||
|
const normCurrentTitle = normalizeTitleForMatch(effectiveTitle);
|
||||||
|
const currentCategory = currentVideoRow && currentVideoRow.category ? Number(currentVideoRow.category) : null;
|
||||||
|
|
||||||
|
let currentYtId = null;
|
||||||
|
if (currentVideoRow && currentVideoRow.targetUrl) {
|
||||||
|
const m =
|
||||||
|
currentVideoRow.targetUrl.match(/[?&]v=([^&]+)/) ||
|
||||||
|
currentVideoRow.targetUrl.match(/youtu\.be\/([^?]+)/) ||
|
||||||
|
currentVideoRow.targetUrl.match(/shorts\/([^?]+)/);
|
||||||
|
if (m) currentYtId = m[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract artist/prefix before '-' if present (e.g. "Seda Sayan & Tekir - Gör Bak")
|
||||||
|
let artistPart = '';
|
||||||
|
const dashParts = effectiveTitle.split(/\s+[\-\u2010-\u2015]\s+/);
|
||||||
|
if (dashParts.length >= 2 && dashParts[0].trim().length >= 3) {
|
||||||
|
artistPart = dashParts[0]
|
||||||
|
.replace(/[\(\[].*?[\)\]]/g, '')
|
||||||
|
.replace(/YakTube/gi, '')
|
||||||
|
.trim();
|
||||||
|
} else if (
|
||||||
|
rawChannel &&
|
||||||
|
!/^(yaktube|root|admin|youtube|varsayılan|müzik kanalı|muzik_kanali)$/i.test(rawChannel.trim())
|
||||||
|
) {
|
||||||
|
artistPart = rawChannel.trim();
|
||||||
|
}
|
||||||
|
const artistNorm = normalizeTitleForMatch(artistPart);
|
||||||
|
const currentKeywords = extractRecommendationKeywords(effectiveTitle);
|
||||||
|
|
||||||
|
// Build clean primary search query for YouTube
|
||||||
|
const cleanTopic = effectiveTitle
|
||||||
|
.replace(/YakTube/gi, '')
|
||||||
|
.replace(/[\(\[].*?[\)\]]/g, '')
|
||||||
|
.replace(/official\s*video|video\s*klip|klip|hd|4k|lyric\s*video|audio|şarkı\s*sözleri|sarki\s*sozleri/gi, '')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
const topicWords = cleanTopic.split(/\s+/).filter(w => w.length >= 2);
|
||||||
|
const primaryQuery = topicWords.slice(0, 5).join(' ') || cleanTopic || effectiveTitle;
|
||||||
|
|
||||||
|
// Parse user watch & search history terms
|
||||||
|
let historyTerms = [];
|
||||||
|
if (rawHistory) {
|
||||||
|
try {
|
||||||
|
const parsed = rawHistory.startsWith('[') ? JSON.parse(rawHistory) : rawHistory.split('|');
|
||||||
|
if (Array.isArray(parsed)) {
|
||||||
|
const defaultIgnore = new Set(['tarkan', 'barış manço', 'yapay zeka', 'canlı haber']);
|
||||||
|
const cleaned = parsed
|
||||||
|
.map(t => String(t || '').trim())
|
||||||
|
.filter(t => t.length >= 3 && (!safeSearchEnabled || !isContentBlocked(t, blockedKeywordsList)));
|
||||||
|
const nonDefaults = cleaned.filter(t => !defaultIgnore.has(t.toLocaleLowerCase('tr')));
|
||||||
|
historyTerms = (nonDefaults.length > 0 ? nonDefaults : cleaned).slice(0, 8);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const historyKeywords = Array.from(
|
||||||
|
new Set(historyTerms.flatMap(t => extractRecommendationKeywords(t)).filter(w => w.length >= 3))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Pick a distinct secondary query from user history that isn't identical to primaryQuery
|
||||||
|
let historyQuery = '';
|
||||||
|
const normPrimary = normalizeTitleForMatch(primaryQuery);
|
||||||
|
for (const hTerm of historyTerms) {
|
||||||
|
const normH = normalizeTitleForMatch(hTerm);
|
||||||
|
if (
|
||||||
|
normH &&
|
||||||
|
normH.length >= 3 &&
|
||||||
|
normH !== normPrimary &&
|
||||||
|
!normPrimary.includes(normH) &&
|
||||||
|
!normH.includes(normPrimary)
|
||||||
|
) {
|
||||||
|
historyQuery = hTerm
|
||||||
|
.replace(/[\(\[].*?[\)\]]/g, '')
|
||||||
|
.split(/\s+/)
|
||||||
|
.slice(0, 4)
|
||||||
|
.join(' ')
|
||||||
|
.trim();
|
||||||
|
if (historyQuery.length >= 3) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Score Local YakTube Videos from PostgreSQL
|
||||||
|
const scoredLocalItems = [];
|
||||||
|
let hasDirectLocalMatch = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const localRows = await dbQuery(
|
||||||
|
`SELECT DISTINCT ON (v.id)
|
||||||
|
v.id, v.uuid, v.name, v.category, v.duration, v.views, v."createdAt",
|
||||||
|
t.filename AS "thumbFilename",
|
||||||
|
vi."targetUrl" AS "importUrl"
|
||||||
|
FROM "video" v
|
||||||
|
LEFT JOIN "thumbnail" t ON t."videoId" = v.id
|
||||||
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
|
WHERE v.remote = false AND v.state = 1
|
||||||
|
ORDER BY v.id DESC, t.type ASC
|
||||||
|
LIMIT 250`
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const lv of localRows) {
|
||||||
|
if (!lv || !lv.name) continue;
|
||||||
|
if (resolvedUuid && lv.uuid === resolvedUuid) continue;
|
||||||
|
if (currentVideoRow && Number(lv.id) === Number(currentVideoRow.id)) continue;
|
||||||
|
if (safeSearchEnabled && isContentBlocked(lv.name, blockedKeywordsList)) continue;
|
||||||
|
|
||||||
|
const normLv = normalizeTitleForMatch(lv.name);
|
||||||
|
if (!normLv || normLv === normCurrentTitle) continue;
|
||||||
|
|
||||||
|
let lvYtId = null;
|
||||||
|
if (lv.importUrl) {
|
||||||
|
const m =
|
||||||
|
lv.importUrl.match(/[?&]v=([^&]+)/) ||
|
||||||
|
lv.importUrl.match(/youtu\.be\/([^?]+)/) ||
|
||||||
|
lv.importUrl.match(/shorts\/([^?]+)/);
|
||||||
|
if (m) lvYtId = m[1];
|
||||||
|
}
|
||||||
|
if (currentYtId && lvYtId && currentYtId === lvYtId) continue;
|
||||||
|
|
||||||
|
let rawScore = 0;
|
||||||
|
let reasonBadge = '';
|
||||||
|
|
||||||
|
// Artist / channel match
|
||||||
|
if (artistNorm && artistNorm.length >= 3 && normLv.includes(artistNorm)) {
|
||||||
|
rawScore += 65;
|
||||||
|
reasonBadge = '🔥 Aynı Sanatçı / Kanal';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keyword overlap with current video
|
||||||
|
const lvKeywords = extractRecommendationKeywords(lv.name);
|
||||||
|
let kwOverlap = 0;
|
||||||
|
for (const kw of currentKeywords) {
|
||||||
|
if (lvKeywords.includes(kw) || (kw.length >= 4 && normLv.includes(kw))) {
|
||||||
|
kwOverlap++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (kwOverlap > 0) {
|
||||||
|
rawScore += kwOverlap * 28;
|
||||||
|
if (!reasonBadge) reasonBadge = '🔥 Benzer İçerik';
|
||||||
|
}
|
||||||
|
|
||||||
|
// User watch/search history match
|
||||||
|
let histOverlap = 0;
|
||||||
|
for (const hkw of historyKeywords) {
|
||||||
|
if (lvKeywords.includes(hkw) || (hkw.length >= 4 && normLv.includes(hkw))) {
|
||||||
|
histOverlap++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (histOverlap > 0) {
|
||||||
|
rawScore += Math.min(44, histOverlap * 22);
|
||||||
|
if (!reasonBadge) reasonBadge = '🎯 Geçmişinize Göre';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same category match (only if category is known)
|
||||||
|
if (currentCategory && lv.category && Number(lv.category) === currentCategory) {
|
||||||
|
rawScore += 20;
|
||||||
|
if (!reasonBadge) reasonBadge = '📂 Aynı Kategoriden';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strictly exclude completely unrelated videos (score < 20)
|
||||||
|
if (rawScore < 20) continue;
|
||||||
|
|
||||||
|
if (rawScore >= 40) {
|
||||||
|
hasDirectLocalMatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const finalScore = rawScore >= 40 ? rawScore + 35 : 54 + Math.min(10, Math.floor((lv.views || 0) / 10));
|
||||||
|
const thumbUrl = lv.thumbFilename
|
||||||
|
? `/lazy-static/thumbnails/${lv.thumbFilename}`
|
||||||
|
: lvYtId
|
||||||
|
? `https://i.ytimg.com/vi/${lvYtId}/hqdefault.jpg`
|
||||||
|
: '/client/assets/images/default-thumbnail.jpg';
|
||||||
|
|
||||||
|
scoredLocalItems.push({
|
||||||
|
id: lvYtId || `local-${lv.uuid}`,
|
||||||
|
title: lv.name,
|
||||||
|
channel: 'YakTube Kütüphanesi',
|
||||||
|
duration: lv.duration || 0,
|
||||||
|
durationFormatted: formatDurationLabel(lv.duration || 0),
|
||||||
|
isLive: false,
|
||||||
|
isDownloaded: true,
|
||||||
|
isFederated: false,
|
||||||
|
reasonBadge: reasonBadge ? `✅ ${reasonBadge.replace(/^[🔥🎯📂]\s*/, '')}` : "✅ YakTube'da İzle",
|
||||||
|
relevanceScore: finalScore,
|
||||||
|
url: lv.importUrl || `/videos/watch/${lv.uuid}`,
|
||||||
|
thumbnail: thumbUrl,
|
||||||
|
localVideo: {
|
||||||
|
id: lv.id,
|
||||||
|
uuid: lv.uuid,
|
||||||
|
name: lv.name,
|
||||||
|
url: `/videos/watch/${lv.uuid}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
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
|
||||||
|
let primaryYtResults = [];
|
||||||
|
let historyYtResults = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const tasks = [searchYouTubeRaw(primaryQuery, 18).catch(() => ({ results: [] }))];
|
||||||
|
if (historyQuery && (!safeSearchEnabled || !isContentBlocked(historyQuery, blockedKeywordsList))) {
|
||||||
|
tasks.push(searchYouTubeRaw(historyQuery, 8).catch(() => ({ results: [] })));
|
||||||
|
}
|
||||||
|
const [primaryRes, historyRes] = await Promise.all(tasks);
|
||||||
|
primaryYtResults = await enrichResultsWithLocalStatus((primaryRes && primaryRes.results) || []);
|
||||||
|
if (historyRes && historyRes.results && historyRes.results.length > 0) {
|
||||||
|
historyYtResults = await enrichResultsWithLocalStatus(historyRes.results);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
const scoredYtItems = [];
|
||||||
|
|
||||||
|
// Score primary topic YouTube results
|
||||||
|
primaryYtResults.forEach((item, idx) => {
|
||||||
|
if (!item || !item.id || !item.title) return;
|
||||||
|
if (currentYtId && item.id === currentYtId) return;
|
||||||
|
const normItem = normalizeTitleForMatch(item.title);
|
||||||
|
if (!normItem || normItem === normCurrentTitle) return;
|
||||||
|
|
||||||
|
let score = Math.max(55, 76 - idx * 1.5);
|
||||||
|
let badge = '🔥 Benzer İçerik';
|
||||||
|
|
||||||
|
if (
|
||||||
|
artistNorm &&
|
||||||
|
artistNorm.length >= 3 &&
|
||||||
|
(normItem.includes(artistNorm) || normalizeTitleForMatch(item.channel).includes(artistNorm))
|
||||||
|
) {
|
||||||
|
score += 14;
|
||||||
|
badge = '🔥 Aynı Sanatçı / Kanal';
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemKws = extractRecommendationKeywords(item.title);
|
||||||
|
let histHits = 0;
|
||||||
|
for (const hkw of historyKeywords) {
|
||||||
|
if (itemKws.includes(hkw)) histHits++;
|
||||||
|
}
|
||||||
|
if (histHits > 0) {
|
||||||
|
score += 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.isDownloaded && item.localVideo) {
|
||||||
|
score += 25;
|
||||||
|
hasDirectLocalMatch = true;
|
||||||
|
badge = "✅ YakTube'da İzle";
|
||||||
|
}
|
||||||
|
|
||||||
|
scoredYtItems.push({
|
||||||
|
...item,
|
||||||
|
reasonBadge: badge,
|
||||||
|
relevanceScore: score,
|
||||||
|
sourceType: 'topic'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Score personalized history YouTube results
|
||||||
|
historyYtResults.forEach((item, idx) => {
|
||||||
|
if (!item || !item.id || !item.title) return;
|
||||||
|
if (currentYtId && item.id === currentYtId) return;
|
||||||
|
const normItem = normalizeTitleForMatch(item.title);
|
||||||
|
if (!normItem || normItem === normCurrentTitle) return;
|
||||||
|
|
||||||
|
let score = Math.max(50, 68 - idx * 2);
|
||||||
|
let badge = '🎯 Geçmişinize Göre';
|
||||||
|
|
||||||
|
if (item.isDownloaded && item.localVideo) {
|
||||||
|
score += 22;
|
||||||
|
badge = '✅ Geçmişinize Göre';
|
||||||
|
}
|
||||||
|
|
||||||
|
scoredYtItems.push({
|
||||||
|
...item,
|
||||||
|
reasonBadge: badge,
|
||||||
|
relevanceScore: score,
|
||||||
|
sourceType: 'history'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3. Merge, Deduplicate & Rank
|
||||||
|
const combined = [...scoredLocalItems, ...scoredYtItems];
|
||||||
|
combined.sort((a, b) => (b.relevanceScore || 0) - (a.relevanceScore || 0));
|
||||||
|
|
||||||
|
const finalResults = [];
|
||||||
|
const seenIds = new Set();
|
||||||
|
const seenUuids = new Set();
|
||||||
|
const seenNormTitles = new Set();
|
||||||
|
|
||||||
|
for (const item of combined) {
|
||||||
|
const normT = normalizeTitleForMatch(item.title);
|
||||||
|
if (!normT || normT === normCurrentTitle) continue;
|
||||||
|
if (item.id && seenIds.has(item.id)) continue;
|
||||||
|
if (item.localVideo && item.localVideo.uuid && seenUuids.has(item.localVideo.uuid)) continue;
|
||||||
|
if (seenNormTitles.has(normT)) continue;
|
||||||
|
|
||||||
|
if (item.id) seenIds.add(item.id);
|
||||||
|
if (item.localVideo && item.localVideo.uuid) seenUuids.add(item.localVideo.uuid);
|
||||||
|
seenNormTitles.add(normT);
|
||||||
|
|
||||||
|
finalResults.push(item);
|
||||||
|
if (finalResults.length >= 24) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identify #1 undownloaded topic match for optional background smart pre-fetch
|
||||||
|
const topPrefetchCandidate =
|
||||||
|
finalResults.find(
|
||||||
|
it =>
|
||||||
|
!it.isDownloaded &&
|
||||||
|
!it.isLive &&
|
||||||
|
it.url &&
|
||||||
|
(it.url.includes('youtube.com') || it.url.includes('youtu.be')) &&
|
||||||
|
(!it.duration || it.duration <= 900) // Only pre-fetch videos <= 15 mins to respect server storage/bandwidth
|
||||||
|
) || null;
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
ok: true,
|
||||||
|
query: primaryQuery,
|
||||||
|
historyQuery: historyQuery || null,
|
||||||
|
hasLocalMatch: hasDirectLocalMatch,
|
||||||
|
smartPrefetchMode,
|
||||||
|
federatedRecommendationsMode,
|
||||||
|
topPrefetchCandidate: topPrefetchCandidate
|
||||||
|
? {
|
||||||
|
id: topPrefetchCandidate.id,
|
||||||
|
title: topPrefetchCandidate.title,
|
||||||
|
url: topPrefetchCandidate.url,
|
||||||
|
channel: topPrefetchCandidate.channel
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
guestImportLimit,
|
||||||
|
results: finalResults
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// 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();
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "peertube-plugin-yaktube-ondemand",
|
"name": "peertube-plugin-yaktube-ondemand",
|
||||||
"version": "1.7.5",
|
"version": "1.7.8",
|
||||||
"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