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 | |
|---|---|---|---|
|
|
b5e8ea28ce | ||
|
|
18f8a601e8 | ||
|
|
e90d928bf1 |
@@ -7071,11 +7071,13 @@ try {
|
|||||||
|
|
||||||
var uuid = match[1];
|
var uuid = match[1];
|
||||||
var existingPanel = document.getElementById('yaktube-watch-comments-panel');
|
var existingPanel = document.getElementById('yaktube-watch-comments-panel');
|
||||||
if (uuid === lastWatchUuid && existingPanel) {
|
if (uuid === lastWatchUuid) {
|
||||||
|
if (existingPanel) {
|
||||||
var nativeComments = document.querySelector('my-video-comments, .video-comments, .comments-block, #comments');
|
var nativeComments = document.querySelector('my-video-comments, .video-comments, .comments-block, #comments');
|
||||||
if (nativeComments && existingPanel.previousElementSibling !== nativeComments) {
|
if (nativeComments && existingPanel.previousElementSibling !== nativeComments) {
|
||||||
nativeComments.insertAdjacentElement('afterend', existingPanel);
|
nativeComments.insertAdjacentElement('afterend', existingPanel);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastWatchUuid = uuid;
|
lastWatchUuid = uuid;
|
||||||
|
|||||||
@@ -360,6 +360,38 @@ const DEFAULT_BLOCKED_KEYWORDS = [
|
|||||||
'hentai',
|
'hentai',
|
||||||
'boob',
|
'boob',
|
||||||
'boobs',
|
'boobs',
|
||||||
|
'prnstars',
|
||||||
|
'pornstar',
|
||||||
|
'pornstars',
|
||||||
|
'brazzers',
|
||||||
|
'brattysis',
|
||||||
|
'nubiles',
|
||||||
|
'naughty america',
|
||||||
|
'sexploitation',
|
||||||
|
'twerking',
|
||||||
|
'gyat',
|
||||||
|
'nalgona',
|
||||||
|
'pawg',
|
||||||
|
'ssbbw',
|
||||||
|
'bimbofication',
|
||||||
|
'femdom',
|
||||||
|
'fetish',
|
||||||
|
'ear licking',
|
||||||
|
'mic licking',
|
||||||
|
'lens licking',
|
||||||
|
'foot tickle',
|
||||||
|
'tickle feet',
|
||||||
|
'foot goddess',
|
||||||
|
'stepsister',
|
||||||
|
'stepmom',
|
||||||
|
'sara jay',
|
||||||
|
'julia ann',
|
||||||
|
'lisa ann',
|
||||||
|
'alexis texas',
|
||||||
|
'lexi belle',
|
||||||
|
'alyx star',
|
||||||
|
'lady sonia',
|
||||||
|
'krazee klipz',
|
||||||
'uyuşturucu',
|
'uyuşturucu',
|
||||||
'uyusturucu',
|
'uyusturucu',
|
||||||
'esrar',
|
'esrar',
|
||||||
@@ -803,8 +835,15 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
}
|
}
|
||||||
parsedHomeCategories = parseHomeCategories(rawHomeCategories);
|
parsedHomeCategories = parseHomeCategories(rawHomeCategories);
|
||||||
|
|
||||||
async function loadPluginSettings() {
|
let lastSettingsLoadTime = 0;
|
||||||
|
const SETTINGS_CACHE_TTL_MS = 60 * 1000;
|
||||||
|
|
||||||
|
async function loadPluginSettings(force = false) {
|
||||||
if (!settingsManager || typeof settingsManager.getSetting !== 'function') return;
|
if (!settingsManager || typeof settingsManager.getSetting !== 'function') return;
|
||||||
|
if (!force && lastSettingsLoadTime > 0 && Date.now() - lastSettingsLoadTime < SETTINGS_CACHE_TTL_MS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastSettingsLoadTime = Date.now();
|
||||||
try {
|
try {
|
||||||
const val = await settingsManager.getSetting('guest-import-limit');
|
const val = await settingsManager.getSetting('guest-import-limit');
|
||||||
if (val !== undefined && val !== null && String(val).trim() !== '') {
|
if (val !== undefined && val !== null && String(val).trim() !== '') {
|
||||||
@@ -896,9 +935,9 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
await loadPluginSettings();
|
await loadPluginSettings(true);
|
||||||
if (settingsManager && typeof settingsManager.onSettingsChange === 'function') {
|
if (settingsManager && typeof settingsManager.onSettingsChange === 'function') {
|
||||||
settingsManager.onSettingsChange(loadPluginSettings);
|
settingsManager.onSettingsChange(() => loadPluginSettings(true));
|
||||||
}
|
}
|
||||||
resolveYtDlpPath(logger, customYtDlpPath, peertubeHelpers);
|
resolveYtDlpPath(logger, customYtDlpPath, peertubeHelpers);
|
||||||
|
|
||||||
@@ -981,79 +1020,164 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
throw new Error('Could not resolve or generate admin OAuth token');
|
throw new Error('Could not resolve or generate admin OAuth token');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function classifyVideoCategoryAndChannel(title, currentCategory, tags, description) {
|
||||||
|
const rawT = String(title || '');
|
||||||
|
const t = rawT.toLocaleLowerCase('tr');
|
||||||
|
const tagStr = Array.isArray(tags) ? tags.filter(Boolean).join(' ').toLocaleLowerCase('tr') : '';
|
||||||
|
const descStr = String(description || '')
|
||||||
|
.slice(0, 400)
|
||||||
|
.toLocaleLowerCase('tr');
|
||||||
|
const combined = `${t} ${tagStr}`;
|
||||||
|
const fullText = `${combined} ${descStr}`;
|
||||||
|
|
||||||
|
const cat = currentCategory ? Number(currentCategory) : null;
|
||||||
|
|
||||||
|
// 1. Music (Category 1 -> YakTube Müzik)
|
||||||
|
const musicPattern =
|
||||||
|
/\b(müzik|muzik|music|musik|muziek|musiqi|müzikleri|muzikleri|şarkı|sarki|şarkılar|sarkilar|klip|video\s*klip|official\s*video|official\s*music|official\s*audio|audio|karaoke|kareoke|akustik|acoustic|enstrümantal|enstrumantal|instrumental|sözleri|sozleri|lyrics|lyric|remix|mix|mashup|cover|ai\s*cover|freestyle|konser|canlı\s*performans|performans|netd|sony\s*music|dmc|poll\s*production|mahzen|tfb\s*records|dokuz\s*sekiz|avrupa\s*müzik|pasaj\s*müzik|türkçe\s*pop|turkce\s*pop|arabesk|rap|hip\s*hop|boombesk|chillebesk|halay|türkü|turku|türküleri|ilahi|kaside|fon\s*müziği|melodi|beat|feat\.?|ft\.?|mv|kpop|k-pop|aespa|sechskies|starakor|star\s*akor|akor|akorları|altyapı|alt\s*yapı)\b/i;
|
||||||
|
|
||||||
|
const knownMusicArtists =
|
||||||
|
/\b(tarkan|sezen\s*aksu|gülşen|gulsen|ebru\s*yaşar|ebru\s*yasar|derya\s*uluğ|derya\s*ulug|asil\s*gök|ferhat\s*göçer|ferhat\s*gocer|sertab\s*erener|candan\s*erçetin|bahadır\s*tatlıöz|reynmen|semicenk|burak\s*bulut|kurtuluş\s*kuş|tekir|mehmet\s*elmas|yıldırım\s*elmas|ahmet\s*kaya|ibrahim\s*tatlıses|müslüm\s*gürses|orhan\s*gencebay|barış\s*manço|cem\s*karaca|mabel\s*matiz|hadise|aleyna\s*tilki|simge|ziynet\s*sali|hande\s*yener|demet\s*akalı|mustafa\s*sandal|kenan\s*doğulu|yalın|teoman|duman|mor\s*ve\s*ötesi|manga|sagopa|ceza|ezhel|uzi|cakal|çakal|lvbel|blok3|poizi|wegh|dedublüman|melek\s*mosso|zeynep\s*bastık|melike\s*şahin|karsu|maya\s*perest|siyam|zeyd|gökhan\s*türkmen|emre\s*aydın|oğuzhan\s*koç|murat\s*boz|edis|buray|ilyas\s*yalçıntaş|tuğçe\s*kandemir|bilal\s*sonses|sancak|taladro|canfeza|no\.?\s*1|şehinşah|hidra|allame|contra|norm\s*ender|ben\s*fero|motive|ati242|girl\s*in\s*red|tate\s*mcrae|rose|giselle|sunghoon|serkan\s*nişancı|yiğit\s*mahzuni|afşin\s*akyol)\b/i;
|
||||||
|
|
||||||
|
if (cat === 1 || /[🎶🎵🎤🎧🎼]/.test(rawT) || musicPattern.test(combined) || knownMusicArtists.test(combined)) {
|
||||||
|
return { category: 1, bucket: 'music', keywords: ['muzik', 'müzik', 'music'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Podcast & Sohbet (-> YakTube Podcast & Sohbet)
|
||||||
|
const podcastPattern =
|
||||||
|
/\b(podcast|röportaj|roportaj|sohbet|söyleşi|soylesi|açık\s*mikrofon|konuk|bölüm\s*sohbet|talk\s*show|interview|in\s*your\s*dreams)\b/i;
|
||||||
|
if (podcastPattern.test(combined)) {
|
||||||
|
return { category: cat || 8, bucket: 'podcast', keywords: ['podcast', 'sohbet'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Teknoloji, Bilim & Eğitim (Categories 12, 13, 15 -> YakTube Teknoloji & Eğitim)
|
||||||
|
const techEduPattern =
|
||||||
|
/\b(teknoloji|technology|bilim|science|yazılım|software|kodlama|coding|programlama|linux|windows|android|ios|iphone|samsung|yapay\s*zeka|artificial\s*intelligence|chatgpt|gemini|bitcoin|kripto|crypto|blockchain|donanım|inceleme|review|rehber|tutorial|how\s*to|nasıl\s*yapılır|eğitim|egitim|education|educational|ders|lecture|kurs|matematik|fizik|kimya|ingilizce|english\s*listening|learn\s*english|qcomputing|quantum|developer|open\s*source|kde|ubuntu|debian|seo|search\s*console|marketing)\b/i;
|
||||||
|
if (cat === 12 || cat === 13 || cat === 15 || techEduPattern.test(combined)) {
|
||||||
|
return { category: cat || 13, bucket: 'tech', keywords: ['teknoloji', 'tekno', 'egitim', 'eğitim', 'tech'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Oyun, Spor & Araçlar (Categories 3, 5, 7 -> YakTube Oyun & Spor)
|
||||||
|
const gameSportPattern =
|
||||||
|
/\b(oyun|gaming|game|gameplay|walkthrough|playthrough|steam|playstation|xbox|nintendo|minecraft|valorant|csgo|cs2|pubg|gta|roblox|fortnite|league\s*of\s*legends|osu|twitch|spor|sport|sports|futbol|football|soccer|basketbol|voleybol|şampiyonlar\s*ligi|champions\s*league|galatasaray|fenerbahçe|fenerbahce|beşiktaş|besiktas|trabzonspor|man\s*utd|manchester|real\s*madrid|barcelona|maç\s*özeti|highlights|fitness|workout|gym|yoga|stretching|wwe|undertaker|red\s*bull|extreme\s*sports|araba|araç|aracı|otomobil|sürüş|multijet|gokart|go\s*kart|karting|motor|f1|formula\s*1)\b/i;
|
||||||
|
if (cat === 3 || cat === 5 || cat === 7 || gameSportPattern.test(combined)) {
|
||||||
|
return { category: cat || 5, bucket: 'game_sport', keywords: ['oyun', 'spor', 'game', 'sport'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Eğlence, Komedi, Film & Dizi (Categories 2, 9, 10 -> YakTube Eğlence & Dizi)
|
||||||
|
const entertainmentPattern =
|
||||||
|
/\b(komedi|comedy|mizah|komik|funny|skeç|skec|parodi|parodie|şaka|prank|eğlence|eglence|entertainment|film|movie|sinema|cinema|fragman|trailer|dizi|series|drama|episode|ep\.\s*\d+|bölüm|bolum|dramatizeme|kısa\s*film|short\s*film|animasyon|animation|anime|çizgi\s*film|tiyatro|stand\s*up|dans|dance|koreografi|choreography|tiktok\s*compilation|challenge|show)\b/i;
|
||||||
|
if (cat === 2 || cat === 9 || cat === 10 || entertainmentPattern.test(combined)) {
|
||||||
|
return { category: cat || 10, bucket: 'entertainment', keywords: ['eglence', 'eğlence', 'dizi', 'komedi'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. Haber, Gündem, Gezi, Doğa & Yaşam (Categories 4, 6, 8, 11, 14, 16, 17, 18 -> YakTube Haber & Yaşam)
|
||||||
|
const newsLifePattern =
|
||||||
|
/\b(haber|haberler|gazete|gazetesi|news|gündem|siyaset|politika|ekonomi|belgesel|documentary|gezi|seyahat|travel|vlog|doğa|doga|nature|kamp|hayvan|animal|kedi|cat|köpek|dog|yemek|mutfak|tarif|food|cooking|moda|fashion|style|outfit|wear|trend|alışveriş|haul|yaşam|lifestyle|sağlık|health|çocuk|kids|sanat|art)\b/i;
|
||||||
|
if ([4, 6, 11, 14, 16, 17, 18].includes(cat) || newsLifePattern.test(combined) || newsLifePattern.test(fullText)) {
|
||||||
|
return { category: cat || 8, bucket: 'news_life', keywords: ['yasam', 'yaşam', 'haber', 'gezi'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Artist - Song fallback for "Artist - Song Title" format
|
||||||
|
if (/^[^\-|]{2,35}\s*[\-\u2010-\u2015]\s*[^\-|]{2,60}$/.test(rawT.trim())) {
|
||||||
|
return { category: 1, bucket: 'music', keywords: ['muzik', 'müzik', 'music'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { category: cat || 8, bucket: 'general', keywords: ['genel', 'general', 'main'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadOfficialChannels() {
|
||||||
|
const allAdminChannels = await dbQuery(
|
||||||
|
`SELECT vc.id, vc.name, act."preferredUsername" AS handle, a.name AS "accountName", u.id AS "userId"
|
||||||
|
FROM "videoChannel" vc
|
||||||
|
INNER JOIN "actor" act ON act."videoChannelId" = vc.id
|
||||||
|
INNER JOIN "account" a ON vc."accountId" = a.id
|
||||||
|
INNER JOIN "user" u ON a."userId" = u.id
|
||||||
|
WHERE u.role = 0 AND act."serverId" IS NULL
|
||||||
|
ORDER BY vc.id ASC`
|
||||||
|
);
|
||||||
|
const yaktubeChannels = allAdminChannels.filter(
|
||||||
|
c =>
|
||||||
|
(c.accountName && c.accountName.toLowerCase() === 'yaktube') ||
|
||||||
|
(c.handle && c.handle.toLowerCase().startsWith('yaktube_')) ||
|
||||||
|
Number(c.userId) === 1
|
||||||
|
);
|
||||||
|
return yaktubeChannels.length > 0 ? yaktubeChannels : allAdminChannels;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickChannelIdFromList(channels, decision) {
|
||||||
|
if (!channels || channels.length === 0) return '1';
|
||||||
|
for (const kw of decision.keywords || []) {
|
||||||
|
const found = channels.find(
|
||||||
|
c =>
|
||||||
|
(c.handle && c.handle.toLocaleLowerCase('tr').includes(kw)) ||
|
||||||
|
(c.name && c.name.toLocaleLowerCase('tr').includes(kw))
|
||||||
|
);
|
||||||
|
if (found) return String(found.id);
|
||||||
|
}
|
||||||
|
const genel =
|
||||||
|
channels.find(
|
||||||
|
c =>
|
||||||
|
(c.handle && c.handle.toLowerCase().includes('genel')) ||
|
||||||
|
(c.name && c.name.toLocaleLowerCase('tr').includes('genel'))
|
||||||
|
) || channels[0];
|
||||||
|
return String(genel.id);
|
||||||
|
}
|
||||||
|
|
||||||
// Universal Channel Resolver (Works on any PeerTube instance + smart category mapping)
|
// Universal Channel Resolver (Works on any PeerTube instance + smart category mapping)
|
||||||
async function resolveTargetChannelId(title, explicitChannelId) {
|
async function resolveTargetChannelId(title, explicitChannelId) {
|
||||||
if (explicitChannelId) return String(explicitChannelId);
|
if (explicitChannelId) return String(explicitChannelId);
|
||||||
if (customChannelId) return String(customChannelId);
|
if (customChannelId) return String(customChannelId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const channels = await dbQuery(
|
const channels = await loadOfficialChannels();
|
||||||
`SELECT vc.id, vc.name, a."displayName"
|
|
||||||
FROM "videoChannel" vc
|
|
||||||
INNER JOIN "account" a ON vc."accountId" = a.id
|
|
||||||
INNER JOIN "user" u ON a."userId" = u.id
|
|
||||||
WHERE u.role = 0
|
|
||||||
ORDER BY vc.id ASC`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (channels.length > 0) {
|
if (channels.length > 0) {
|
||||||
const t = String(title || '').toLowerCase();
|
const decision = classifyVideoCategoryAndChannel(title, null, [], '');
|
||||||
const findCh = keyword =>
|
return pickChannelIdFromList(channels, decision);
|
||||||
channels.find(
|
|
||||||
c =>
|
|
||||||
(c.name && c.name.toLowerCase().includes(keyword)) ||
|
|
||||||
(c.displayName && c.displayName.toLowerCase().includes(keyword))
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
t.includes('podcast') ||
|
|
||||||
t.includes('röportaj') ||
|
|
||||||
t.includes('roportaj') ||
|
|
||||||
t.includes('sohbet') ||
|
|
||||||
t.includes('bölüm') ||
|
|
||||||
t.includes('episode')
|
|
||||||
) {
|
|
||||||
const podCh = findCh('podcast') || findCh('sohbet');
|
|
||||||
if (podCh) return String(podCh.id);
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
if (
|
if (logger) logger.warn('[YakTube OnDemand] resolveTargetChannelId warning: ' + e.message);
|
||||||
t.includes('bitcoin') ||
|
|
||||||
t.includes('kripto') ||
|
|
||||||
t.includes('yazılım') ||
|
|
||||||
t.includes('kodlama') ||
|
|
||||||
t.includes('ders') ||
|
|
||||||
t.includes('rehber') ||
|
|
||||||
t.includes('tutorial') ||
|
|
||||||
t.includes('teknoloji') ||
|
|
||||||
t.includes('inceleme')
|
|
||||||
) {
|
|
||||||
const techCh = findCh('tekno') || findCh('tech') || findCh('egitim');
|
|
||||||
if (techCh) return String(techCh.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
|
||||||
t.includes('müzik') ||
|
|
||||||
t.includes('muzik') ||
|
|
||||||
t.includes('music') ||
|
|
||||||
t.includes('şarkı') ||
|
|
||||||
t.includes('klip') ||
|
|
||||||
t.includes('official') ||
|
|
||||||
t.includes('feat') ||
|
|
||||||
t.includes('remix') ||
|
|
||||||
t.includes(' - ')
|
|
||||||
) {
|
|
||||||
const musicCh = findCh('muzik') || findCh('müzik') || findCh('music');
|
|
||||||
if (musicCh) return String(musicCh.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return String(channels[0].id);
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
return '1';
|
return '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Post-import synchronizer: once yt-dlp populates a video's YouTube category & tags, ensure it is in the right channel
|
||||||
|
async function syncVideoChannelAndCategory(videoId) {
|
||||||
|
if (!videoId || customChannelId) return;
|
||||||
|
try {
|
||||||
|
const rows = await dbQuery(
|
||||||
|
`SELECT v.id, v.name, v.category, v."channelId", v.description,
|
||||||
|
(SELECT array_agg(t.name) FROM "videoTag" vt INNER JOIN "tag" t ON t.id = vt."tagId" WHERE vt."videoId" = v.id) AS tags
|
||||||
|
FROM "video" v
|
||||||
|
WHERE v.id = $1 AND v.remote = false
|
||||||
|
LIMIT 1`,
|
||||||
|
[Number(videoId)]
|
||||||
|
);
|
||||||
|
if (rows.length === 0) return;
|
||||||
|
const v = rows[0];
|
||||||
|
const channels = await loadOfficialChannels();
|
||||||
|
if (channels.length === 0) return;
|
||||||
|
|
||||||
|
const decision = classifyVideoCategoryAndChannel(v.name, v.category, v.tags, v.description);
|
||||||
|
const targetChannelId = Number(pickChannelIdFromList(channels, decision));
|
||||||
|
const targetCategory = decision.category || v.category || 8;
|
||||||
|
|
||||||
|
if (
|
||||||
|
(targetChannelId && targetChannelId !== Number(v.channelId) && Number(v.channelId) === 1) ||
|
||||||
|
(!v.category && targetCategory)
|
||||||
|
) {
|
||||||
|
await dbQuery(
|
||||||
|
`UPDATE "video"
|
||||||
|
SET "channelId" = $1,
|
||||||
|
category = COALESCE(category, $2)
|
||||||
|
WHERE id = $3`,
|
||||||
|
[targetChannelId || v.channelId, targetCategory, v.id]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Helper to check if request is from an authenticated PeerTube user
|
// Helper to check if request is from an authenticated PeerTube user
|
||||||
async function isRequestAuthenticated(req, res, bodyAuthFlag) {
|
async function isRequestAuthenticated(req, res, bodyAuthFlag) {
|
||||||
if (bodyAuthFlag === true) return true;
|
if (bodyAuthFlag === true) return true;
|
||||||
@@ -1642,6 +1766,38 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let localLibrarySnapshotCache = { time: 0, rows: [] };
|
||||||
|
const LOCAL_LIBRARY_CACHE_TTL_MS = 30 * 1000;
|
||||||
|
|
||||||
|
async function getCachedLocalLibraryRows() {
|
||||||
|
if (
|
||||||
|
localLibrarySnapshotCache.rows.length > 0 &&
|
||||||
|
Date.now() - localLibrarySnapshotCache.time < LOCAL_LIBRARY_CACHE_TTL_MS
|
||||||
|
) {
|
||||||
|
return localLibrarySnapshotCache.rows;
|
||||||
|
}
|
||||||
|
const rows = await dbQuery(
|
||||||
|
`SELECT v.id, v.uuid, v.name, v.category, v.duration, v.views, v."createdAt",
|
||||||
|
(SELECT t.filename FROM "thumbnail" t WHERE t."videoId" = v.id ORDER BY t.width ASC NULLS LAST LIMIT 1) AS "thumbFilename",
|
||||||
|
vi."targetUrl" AS "importUrl",
|
||||||
|
(
|
||||||
|
SELECT tg.name
|
||||||
|
FROM "videoTag" vt2
|
||||||
|
INNER JOIN "tag" tg ON tg.id = vt2."tagId"
|
||||||
|
WHERE vt2."videoId" = v.id
|
||||||
|
ORDER BY vt2."createdAt" ASC
|
||||||
|
LIMIT 1
|
||||||
|
) AS "primaryTag"
|
||||||
|
FROM "video" v
|
||||||
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
|
WHERE v.remote = false AND v.state = 1
|
||||||
|
ORDER BY v.id DESC
|
||||||
|
LIMIT 250`
|
||||||
|
);
|
||||||
|
localLibrarySnapshotCache = { time: Date.now(), rows };
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
router.get('/smart-recommendations', async (req, res) => {
|
router.get('/smart-recommendations', async (req, res) => {
|
||||||
await loadPluginSettings();
|
await loadPluginSettings();
|
||||||
if (isCrawlerBotRequest(req)) {
|
if (isCrawlerBotRequest(req)) {
|
||||||
@@ -1681,14 +1837,26 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
|
|
||||||
if (resolvedUuid) {
|
if (resolvedUuid) {
|
||||||
try {
|
try {
|
||||||
const currentRows = await dbQuery(
|
let currentRows = [];
|
||||||
|
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(resolvedUuid)) {
|
||||||
|
currentRows = await dbQuery(
|
||||||
`SELECT v.id, v.uuid, v.name, v.category, v."channelId", vi."targetUrl"
|
`SELECT v.id, v.uuid, v.name, v.category, v."channelId", vi."targetUrl"
|
||||||
FROM "video" v
|
FROM "video" v
|
||||||
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
WHERE v.uuid::text = $1 OR v.id::text = $2
|
WHERE v.uuid = $1::uuid
|
||||||
LIMIT 1`,
|
LIMIT 1`,
|
||||||
[resolvedUuid, rawUuid]
|
[resolvedUuid]
|
||||||
);
|
);
|
||||||
|
} else if (/^\d+$/.test(rawUuid)) {
|
||||||
|
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.id = $1::int
|
||||||
|
LIMIT 1`,
|
||||||
|
[parseInt(rawUuid, 10)]
|
||||||
|
);
|
||||||
|
}
|
||||||
if (currentRows.length > 0) {
|
if (currentRows.length > 0) {
|
||||||
currentVideoRow = currentRows[0];
|
currentVideoRow = currentRows[0];
|
||||||
const tagRows = await dbQuery(
|
const tagRows = await dbQuery(
|
||||||
@@ -1696,7 +1864,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
FROM "videoTag" vt
|
FROM "videoTag" vt
|
||||||
INNER JOIN "tag" t ON t.id = vt."tagId"
|
INNER JOIN "tag" t ON t.id = vt."tagId"
|
||||||
WHERE vt."videoId" = $1
|
WHERE vt."videoId" = $1
|
||||||
ORDER BY vt.id ASC
|
ORDER BY vt."createdAt" ASC
|
||||||
LIMIT 8`,
|
LIMIT 8`,
|
||||||
[currentVideoRow.id]
|
[currentVideoRow.id]
|
||||||
);
|
);
|
||||||
@@ -1942,26 +2110,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
let hasDirectLocalMatch = false;
|
let hasDirectLocalMatch = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const localRows = await dbQuery(
|
const localRows = await getCachedLocalLibraryRows();
|
||||||
`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",
|
|
||||||
(
|
|
||||||
SELECT tg.name
|
|
||||||
FROM "videoTag" vt2
|
|
||||||
INNER JOIN "tag" tg ON tg.id = vt2."tagId"
|
|
||||||
WHERE vt2."videoId" = v.id
|
|
||||||
ORDER BY vt2.id ASC
|
|
||||||
LIMIT 1
|
|
||||||
) AS "primaryTag"
|
|
||||||
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) {
|
for (const lv of localRows) {
|
||||||
if (!lv || !lv.name) continue;
|
if (!lv || !lv.name) continue;
|
||||||
@@ -2100,7 +2249,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
// 1.5. Score Relevant Fediverse (Remote PeerTube) Videos when federatedRecommendationsMode !== 'disabled'
|
// 1.5. Score Relevant Fediverse (Remote PeerTube) Videos when federatedRecommendationsMode !== 'disabled'
|
||||||
if (federatedRecommendationsMode !== 'disabled') {
|
if (federatedRecommendationsMode !== 'disabled') {
|
||||||
try {
|
try {
|
||||||
const searchPatterns = Array.from(
|
const trgmPatterns = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
[
|
[
|
||||||
...(artistNorm && artistNorm.length >= 3 ? [artistNorm] : []),
|
...(artistNorm && artistNorm.length >= 3 ? [artistNorm] : []),
|
||||||
@@ -2108,27 +2257,35 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
...currentKeywords,
|
...currentKeywords,
|
||||||
...historyKeywords
|
...historyKeywords
|
||||||
]
|
]
|
||||||
|
.map(k =>
|
||||||
|
String(k || '')
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/[ç]/g, 'c')
|
||||||
|
.replace(/[ğ]/g, 'g')
|
||||||
|
.replace(/[ıİ]/g, 'i')
|
||||||
|
.replace(/[ö]/g, 'o')
|
||||||
|
.replace(/[ş]/g, 's')
|
||||||
|
.replace(/[ü]/g, 'u')
|
||||||
|
.trim()
|
||||||
|
)
|
||||||
.filter(k => k && k.length >= 3)
|
.filter(k => k && k.length >= 3)
|
||||||
.slice(0, 8)
|
.slice(0, 6)
|
||||||
.map(k => `%${k}%`)
|
.map(k => `%${k}%`)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (searchPatterns.length > 0) {
|
if (trgmPatterns.length > 0) {
|
||||||
const fedRows = await dbQuery(
|
const fedRows = await dbQuery(
|
||||||
`SELECT DISTINCT ON (v.id)
|
`SELECT v.id, v.uuid, v.name, v.category, v.language, v.duration, v.views, v."isLive", v.nsfw,
|
||||||
v.id, v.uuid, v.name, v.category, v.language, v.duration, v.views, v."isLive", v.nsfw,
|
(SELECT t.filename FROM "thumbnail" t WHERE t."videoId" = v.id ORDER BY t.width ASC NULLS LAST LIMIT 1) AS "thumbFilename"
|
||||||
t.filename AS "thumbFilename"
|
|
||||||
FROM "video" v
|
FROM "video" v
|
||||||
LEFT JOIN "thumbnail" t ON t."videoId" = v.id
|
|
||||||
WHERE v.remote = true
|
WHERE v.remote = true
|
||||||
AND v.state = 1
|
AND v.state = 1
|
||||||
AND v.privacy = 1
|
AND v.privacy = 1
|
||||||
AND v.nsfw = false
|
AND v.nsfw = false
|
||||||
AND (v.name ILIKE ANY($1) OR v.language = 'tr')
|
AND lower(immutable_unaccent(v.name::text)) LIKE ANY($1)
|
||||||
ORDER BY v.id DESC, t.type ASC
|
LIMIT 40`,
|
||||||
LIMIT 80`,
|
[trgmPatterns]
|
||||||
[searchPatterns]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const fv of fedRows) {
|
for (const fv of fedRows) {
|
||||||
@@ -2632,6 +2789,7 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
try {
|
try {
|
||||||
const data = JSON.parse(body);
|
const data = JSON.parse(body);
|
||||||
if (data && data.video) {
|
if (data && data.video) {
|
||||||
|
syncVideoChannelAndCategory(data.video.id).catch(() => {});
|
||||||
return resolve({
|
return resolve({
|
||||||
status: 200,
|
status: 200,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -2699,6 +2857,9 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
|
|
||||||
// 4. Video Import Status Polling Route
|
// 4. Video Import Status Polling Route
|
||||||
router.get('/status/:id', async (req, res) => {
|
router.get('/status/:id', async (req, res) => {
|
||||||
|
if (isCrawlerBotRequest(req)) {
|
||||||
|
return res.status(403).json({ error: 'Bot requests are not allowed on import status endpoint' });
|
||||||
|
}
|
||||||
const videoId = req.params.id;
|
const videoId = req.params.id;
|
||||||
const { hostname, port, hostHeader } = getLocalServerTarget();
|
const { hostname, port, hostHeader } = getLocalServerTarget();
|
||||||
const reqVideo = http.request(
|
const reqVideo = http.request(
|
||||||
@@ -2723,6 +2884,10 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
(video.files && video.files.length > 0) ||
|
(video.files && video.files.length > 0) ||
|
||||||
(video.streamingPlaylists && video.streamingPlaylists.length > 0);
|
(video.streamingPlaylists && video.streamingPlaylists.length > 0);
|
||||||
|
|
||||||
|
if ((isPublished || isTranscoding) && video.id) {
|
||||||
|
await syncVideoChannelAndCategory(video.id);
|
||||||
|
}
|
||||||
|
|
||||||
let errorMessage = null;
|
let errorMessage = null;
|
||||||
if (isFailed && video.id) {
|
if (isFailed && video.id) {
|
||||||
try {
|
try {
|
||||||
@@ -2816,21 +2981,47 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const videoOriginCache = new Map();
|
||||||
|
const VIDEO_ORIGIN_CACHE_TTL_MS = 10 * 60 * 1000;
|
||||||
|
|
||||||
router.get('/video-origin/:uuid', async (req, res) => {
|
router.get('/video-origin/:uuid', async (req, res) => {
|
||||||
|
if (isCrawlerBotRequest(req)) {
|
||||||
|
return res.json({ ok: false, hasYouTubeOrigin: false, botIgnored: true });
|
||||||
|
}
|
||||||
const rawParam = (req.params.uuid || '').trim();
|
const rawParam = (req.params.uuid || '').trim();
|
||||||
if (!rawParam) return res.status(400).json({ error: 'UUID required' });
|
if (!rawParam) return res.status(400).json({ error: 'UUID required' });
|
||||||
const resolvedUuid = shortToUuid(rawParam);
|
const resolvedUuid = shortToUuid(rawParam);
|
||||||
|
|
||||||
|
const cacheHit = videoOriginCache.get(resolvedUuid);
|
||||||
|
if (cacheHit && Date.now() - cacheHit.time < VIDEO_ORIGIN_CACHE_TTL_MS) {
|
||||||
|
if (cacheHit.notFound) return res.status(404).json({ error: 'Video not found' });
|
||||||
|
return res.json(cacheHit.payload);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const rows = await dbQuery(
|
let rows = [];
|
||||||
|
if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(resolvedUuid)) {
|
||||||
|
rows = await dbQuery(
|
||||||
`SELECT v.id, v.uuid, v.name, v.description, vi."targetUrl"
|
`SELECT v.id, v.uuid, v.name, v.description, vi."targetUrl"
|
||||||
FROM "video" v
|
FROM "video" v
|
||||||
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
WHERE v.uuid::text = $1 OR v.id::text = $2
|
WHERE v.uuid = $1::uuid
|
||||||
LIMIT 1`,
|
LIMIT 1`,
|
||||||
[resolvedUuid, rawParam]
|
[resolvedUuid]
|
||||||
);
|
);
|
||||||
|
} else if (/^\d+$/.test(rawParam)) {
|
||||||
|
rows = await dbQuery(
|
||||||
|
`SELECT v.id, v.uuid, v.name, v.description, vi."targetUrl"
|
||||||
|
FROM "video" v
|
||||||
|
LEFT JOIN "videoImport" vi ON vi."videoId" = v.id
|
||||||
|
WHERE v.id = $1::int
|
||||||
|
LIMIT 1`,
|
||||||
|
[parseInt(rawParam, 10)]
|
||||||
|
);
|
||||||
|
}
|
||||||
if (rows.length === 0) {
|
if (rows.length === 0) {
|
||||||
|
if (videoOriginCache.size > 2000) videoOriginCache.clear();
|
||||||
|
videoOriginCache.set(resolvedUuid, { time: Date.now(), notFound: true });
|
||||||
return res.status(404).json({ error: 'Video not found' });
|
return res.status(404).json({ error: 'Video not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2853,13 +3044,17 @@ async function register({ registerHook, getRouter, registerSetting, settingsMana
|
|||||||
if (match) youtubeId = match[1];
|
if (match) youtubeId = match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json({
|
const payload = {
|
||||||
ok: true,
|
ok: true,
|
||||||
hasYouTubeOrigin: !!youtubeId,
|
hasYouTubeOrigin: !!youtubeId,
|
||||||
youtubeId: youtubeId || null,
|
youtubeId: youtubeId || null,
|
||||||
targetUrl: row.targetUrl || null,
|
targetUrl: row.targetUrl || null,
|
||||||
title: row.name
|
title: row.name
|
||||||
});
|
};
|
||||||
|
if (videoOriginCache.size > 2000) videoOriginCache.clear();
|
||||||
|
videoOriginCache.set(resolvedUuid, { time: Date.now(), notFound: false, payload });
|
||||||
|
|
||||||
|
return res.json(payload);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(500).json({ error: err.message });
|
return res.status(500).json({ error: err.message });
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "peertube-plugin-yaktube-ondemand",
|
"name": "peertube-plugin-yaktube-ondemand",
|
||||||
"version": "1.7.13",
|
"version": "1.7.16",
|
||||||
"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