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 | |
|---|---|---|---|
|
|
64a961bc74 | ||
|
|
1fb61b784e | ||
|
|
65fdc8a71f | ||
|
|
944b779fcd | ||
|
|
798c850cef |
@@ -111,6 +111,16 @@ const DEFAULT_BLOCKED_KEYWORDS = [
|
||||
'sheer',
|
||||
'babydoll',
|
||||
'gravure',
|
||||
'bra',
|
||||
'plus-size bra',
|
||||
'try on',
|
||||
'try-on',
|
||||
'underwear',
|
||||
'panties',
|
||||
'thong',
|
||||
'cleavage',
|
||||
'twerk',
|
||||
'cameltoe',
|
||||
'nude',
|
||||
'nudes',
|
||||
'nudist',
|
||||
@@ -136,6 +146,7 @@ const DEFAULT_BLOCKED_KEYWORDS = [
|
||||
'+18',
|
||||
'nsfw',
|
||||
'xxx',
|
||||
'xvideos',
|
||||
'onlyfans',
|
||||
'sissy',
|
||||
'seduce',
|
||||
@@ -178,17 +189,96 @@ function isContentBlocked(text, list = DEFAULT_BLOCKED_KEYWORDS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function register({ getRouter, registerSetting, settingsManager, peertubeHelpers, logger }) {
|
||||
async function register({ registerHook, getRouter, registerSetting, settingsManager, peertubeHelpers, logger }) {
|
||||
const router = getRouter();
|
||||
|
||||
let guestImportLimit = 5;
|
||||
let maxDiskUsagePercent = 85;
|
||||
let yaknetSsoEnabled = true;
|
||||
let smartPrefetchMode = 'auto-when-no-local';
|
||||
let customChannelId = '';
|
||||
let customYtDlpPath = '';
|
||||
let safeSearchEnabled = true;
|
||||
let blockedKeywordsList = [...DEFAULT_BLOCKED_KEYWORDS];
|
||||
|
||||
// YakTube Bildirim Filtresi & SafeSearch Video Listesi Filtresi
|
||||
if (typeof registerHook === 'function') {
|
||||
registerHook({
|
||||
target: 'filter:notifier.notification.enabled.result',
|
||||
handler: async (result, { notification }) => {
|
||||
if (notification && (notification.type === 7 || notification.type === 'my-video-import-success')) {
|
||||
return {
|
||||
webNotificationEnabled: false,
|
||||
emailNotificationEnabled: false
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
const filterVideoListResult = async result => {
|
||||
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.');
|
||||
}
|
||||
|
||||
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: 'safe-search-enabled',
|
||||
label: 'Güvenli Okul & Aile Araması (SafeSearch)',
|
||||
@@ -361,7 +451,7 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
};
|
||||
|
||||
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') {
|
||||
result.push({
|
||||
label: item,
|
||||
@@ -529,6 +619,24 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
parsedHomeCategories = parseHomeCategories(rawHomeCategories);
|
||||
} 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 safeVal = await settingsManager.getSetting('safe-search-enabled');
|
||||
if (safeVal !== undefined && safeVal !== null) {
|
||||
@@ -543,7 +651,11 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
.split(/[\n,]+/)
|
||||
.map(w => w.trim().toLowerCase())
|
||||
.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) {}
|
||||
}
|
||||
@@ -965,6 +1077,8 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
await loadPluginSettings();
|
||||
return res.json({
|
||||
ok: true,
|
||||
yaknetSsoEnabled,
|
||||
smartPrefetchMode,
|
||||
guestImportLimit,
|
||||
maxDiskUsagePercent,
|
||||
safeSearchEnabled,
|
||||
@@ -1005,42 +1119,37 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
return res.json(result);
|
||||
});
|
||||
|
||||
// 2. YouTube Search Route (aliases: /youtube-search and /search)
|
||||
async function handleYouTubeSearch(req, res) {
|
||||
await loadPluginSettings();
|
||||
const query = (req.query.q || '').trim();
|
||||
if (!query || query.length < 2) {
|
||||
return res.json({ results: [], guestImportLimit });
|
||||
// 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 });
|
||||
}
|
||||
|
||||
if (safeSearchEnabled && isContentBlocked(query, blockedKeywordsList)) {
|
||||
return res.json({
|
||||
results: [],
|
||||
blocked: true,
|
||||
guestImportLimit,
|
||||
message:
|
||||
'Bu arama terimi veya içerik, Çocuk ve Aile Güvenliği (Child & Family Safety) politikaları gereğince filtrelenmiştir.'
|
||||
});
|
||||
}
|
||||
|
||||
const cached = getCached(query);
|
||||
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;
|
||||
const enriched = await enrichResultsWithLocalStatus(filteredCached);
|
||||
return res.json({ results: enriched, cached: true, guestImportLimit });
|
||||
return resolve({ results: filteredCached.slice(0, maxCount), cached: true });
|
||||
}
|
||||
|
||||
const ytdlpPath = resolveYtDlpPath(logger, customYtDlpPath);
|
||||
const args = ['ytsearch24:' + query, '--dump-single-json', '--flat-playlist', '--skip-download', '--no-warnings'];
|
||||
const args = [
|
||||
`ytsearch${maxCount}:${cleanQ}`,
|
||||
'--dump-single-json',
|
||||
'--flat-playlist',
|
||||
'--skip-download',
|
||||
'--no-warnings'
|
||||
];
|
||||
|
||||
execFile(ytdlpPath, args, { maxBuffer: 10 * 1024 * 1024, timeout: 15000 }, async (error, stdout) => {
|
||||
execFile(ytdlpPath, args, { maxBuffer: 10 * 1024 * 1024, timeout: 15000 }, (error, stdout) => {
|
||||
if (error) {
|
||||
if (logger) logger.error('YouTube search error: ' + error.message);
|
||||
return res.status(500).json({ error: 'Search failed', details: error.message });
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
try {
|
||||
const rawStr = stdout.trim();
|
||||
const startIdx = rawStr.indexOf('{');
|
||||
@@ -1082,19 +1191,483 @@ async function register({ getRouter, registerSetting, settingsManager, peertubeH
|
||||
rawResults = rawResults.filter(e => !isContentBlocked(e.title, blockedKeywordsList));
|
||||
}
|
||||
|
||||
setCache(query, rawResults);
|
||||
const enrichedResults = await enrichResultsWithLocalStatus(rawResults);
|
||||
return res.json({ results: enrichedResults, cached: false, guestImportLimit });
|
||||
setCache(cacheKey, rawResults);
|
||||
if (maxCount >= 18) setCache(cleanQ, rawResults);
|
||||
return resolve({ results: rawResults, cached: false });
|
||||
} catch (parseErr) {
|
||||
if (logger) logger.error('JSON parse error in search: ' + parseErr.message);
|
||||
return res.status(500).json({ error: 'Failed to parse search results' });
|
||||
return reject(parseErr);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 2. YouTube Search Route (aliases: /youtube-search and /search)
|
||||
async function handleYouTubeSearch(req, res) {
|
||||
await loadPluginSettings();
|
||||
const query = (req.query.q || '').trim();
|
||||
if (!query || query.length < 2) {
|
||||
return res.json({ results: [], guestImportLimit });
|
||||
}
|
||||
|
||||
if (safeSearchEnabled && isContentBlocked(query, blockedKeywordsList)) {
|
||||
return res.json({
|
||||
results: [],
|
||||
blocked: true,
|
||||
guestImportLimit,
|
||||
message:
|
||||
'Bu arama terimi veya içerik, Çocuk ve Aile Güvenliği (Child & Family Safety) politikaları gereğince filtrelenmiştir.'
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const { results: rawResults, cached } = await searchYouTubeRaw(query, 24);
|
||||
const enrichedResults = await enrichResultsWithLocalStatus(rawResults);
|
||||
return res.json({ results: enrichedResults, cached, guestImportLimit });
|
||||
} catch (err) {
|
||||
if (logger) logger.error('YouTube search error: ' + err.message);
|
||||
return res.status(500).json({ error: 'Search failed', details: err.message });
|
||||
}
|
||||
}
|
||||
|
||||
router.get('/youtube-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,
|
||||
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);
|
||||
}
|
||||
|
||||
// 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,
|
||||
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)
|
||||
async function handleOnDemandImport(req, res) {
|
||||
await loadPluginSettings();
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "peertube-plugin-yaktube-ondemand",
|
||||
"version": "1.7.2",
|
||||
"version": "1.7.7",
|
||||
"description": "Accessible On-Demand YouTube Import, Live Streams, Smart Recommendations, Sleep Timer, Touch Gestures, Voice Assistant & A11y Engine for PeerTube",
|
||||
"main": "main.js",
|
||||
"library": "./main.js",
|
||||
|
||||
@@ -1763,3 +1763,178 @@ my-date-toggle .date-toggle:focus-visible {
|
||||
background-color: rgba(255, 143, 55, 0.15) !important;
|
||||
outline: 2px solid #ff8f37 !important;
|
||||
}
|
||||
|
||||
/* === YakTube WCAG 2.1 AAA Video Player Accessibility: Keep Controls Accessible === */
|
||||
|
||||
/* 1. Video duraklatıldığında veya klavye/ekran okuyucu odaklandığında denetim çubuğunu görünür tut */
|
||||
.video-js.vjs-paused .vjs-control-bar,
|
||||
.video-js:focus-within .vjs-control-bar,
|
||||
.video-js .vjs-control-bar:focus-within,
|
||||
.video-js.vjs-user-inactive.vjs-paused .vjs-control-bar {
|
||||
opacity: 1 !important;
|
||||
visibility: visible !important;
|
||||
display: flex !important;
|
||||
pointer-events: auto !important;
|
||||
}
|
||||
|
||||
/* 2. Büyük merkez oynatma düğmesi PeerTube varsayılanında bırakıldı */
|
||||
|
||||
/* 3. Tüm Video.js düğmelerinin klavye odağını belirgin kıl */
|
||||
.video-js .vjs-control-bar .vjs-button:focus,
|
||||
.video-js .vjs-control-bar .vjs-button:focus-visible,
|
||||
.video-js .vjs-big-play-button:focus,
|
||||
.video-js .vjs-big-play-button:focus-visible {
|
||||
outline: 3px solid #ff8f37 !important;
|
||||
outline-offset: 2px !important;
|
||||
box-shadow: 0 0 10px rgba(255, 143, 55, 0.8) !important;
|
||||
}
|
||||
|
||||
/* === YakTube NLnet WCAG 2.2 AAA & Privacy Suite Styles === */
|
||||
|
||||
/* 1. Yalnızca Ses ve Ekran Karartma Modu */
|
||||
.yaktube-audio-blank-overlay {
|
||||
position: fixed !important;
|
||||
top: 0 !important;
|
||||
left: 0 !important;
|
||||
width: 100vw !important;
|
||||
height: 100vh !important;
|
||||
background: #000 !important;
|
||||
z-index: 9999999 !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
text-align: center !important;
|
||||
color: #fff !important;
|
||||
padding: 24px !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
.yaktube-audio-blank-content {
|
||||
background: rgba(20, 20, 28, 0.95) !important;
|
||||
border: 1px solid rgba(255, 143, 55, 0.5) !important;
|
||||
border-radius: 20px !important;
|
||||
padding: 32px 24px !important;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9) !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
align-items: center !important;
|
||||
animation: yaktube-fade-in 0.25s ease-out !important;
|
||||
}
|
||||
|
||||
.yaktube-audio-action-btn {
|
||||
background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%) !important;
|
||||
color: #fff !important;
|
||||
border: none !important;
|
||||
border-radius: 10px !important;
|
||||
padding: 12px 20px !important;
|
||||
font-size: 14px !important;
|
||||
font-weight: 700 !important;
|
||||
cursor: pointer !important;
|
||||
transition:
|
||||
transform 0.15s,
|
||||
opacity 0.15s !important;
|
||||
}
|
||||
|
||||
.yaktube-audio-action-btn:hover,
|
||||
.yaktube-audio-action-btn:focus-visible {
|
||||
transform: scale(1.05) !important;
|
||||
outline: 3px solid #ff8f37 !important;
|
||||
outline-offset: 3px !important;
|
||||
}
|
||||
|
||||
/* 2. Erişilebilir Canlı Transkript Paneli */
|
||||
.yaktube-transcript-panel {
|
||||
margin: 16px 0 !important;
|
||||
background: #181824 !important;
|
||||
border: 1px solid rgba(255, 143, 55, 0.35) !important;
|
||||
border-radius: 16px !important;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
|
||||
color: #fff !important;
|
||||
overflow: hidden !important;
|
||||
animation: yaktube-fade-in 0.2s ease-out !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-header {
|
||||
display: flex !important;
|
||||
justify-content: space-between !important;
|
||||
align-items: center !important;
|
||||
padding: 14px 18px !important;
|
||||
background: rgba(255, 255, 255, 0.04) !important;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
|
||||
flex-wrap: wrap !important;
|
||||
gap: 10px !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-search {
|
||||
background: #22222e !important;
|
||||
border: 1px solid #444 !important;
|
||||
border-radius: 8px !important;
|
||||
padding: 6px 12px !important;
|
||||
color: #fff !important;
|
||||
font-size: 13px !important;
|
||||
width: 180px !important;
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-search:focus {
|
||||
border-color: #ff8f37 !important;
|
||||
box-shadow: 0 0 8px rgba(255, 143, 55, 0.4) !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-list {
|
||||
list-style: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 8px 12px !important;
|
||||
max-height: 280px !important;
|
||||
overflow-y: auto !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
gap: 4px !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-item {
|
||||
display: flex !important;
|
||||
align-items: baseline !important;
|
||||
gap: 12px !important;
|
||||
padding: 8px 12px !important;
|
||||
border-radius: 8px !important;
|
||||
cursor: pointer !important;
|
||||
transition: background 0.15s ease !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-item:hover,
|
||||
.yaktube-transcript-item:focus-visible {
|
||||
background: rgba(255, 143, 55, 0.15) !important;
|
||||
outline: 2px solid #ff8f37 !important;
|
||||
outline-offset: -2px !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-item.active {
|
||||
background: rgba(255, 143, 55, 0.25) !important;
|
||||
font-weight: 700 !important;
|
||||
border-left: 4px solid #ff8f37 !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-time {
|
||||
font-family: monospace !important;
|
||||
font-size: 12px !important;
|
||||
color: #ff8f37 !important;
|
||||
background: rgba(255, 143, 55, 0.1) !important;
|
||||
padding: 2px 6px !important;
|
||||
border-radius: 4px !important;
|
||||
flex-shrink: 0 !important;
|
||||
}
|
||||
|
||||
.yaktube-transcript-text {
|
||||
font-size: 14px !important;
|
||||
line-height: 1.45 !important;
|
||||
color: #e5e5e5 !important;
|
||||
}
|
||||
|
||||
/* 3. Araç Çubuğu Butonlarının Aktif Hali */
|
||||
.yaktube-player-action-btn.active {
|
||||
background: linear-gradient(135deg, #ff8f37 0%, #ff5e3a 100%) !important;
|
||||
color: #fff !important;
|
||||
border-color: #ff8f37 !important;
|
||||
box-shadow: 0 0 12px rgba(255, 143, 55, 0.6) !important;
|
||||
}
|
||||
Reference in New Issue
Block a user