Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

discard videos older than 1 month

Christian Feid5e17ca165a1
diff --git a/lib/youtube.js b/lib/youtube.js
index a38db3a..bda5278 100644
--- a/lib/youtube.js
+++ b/lib/youtube.js
@@ -48,7 +48,11 @@ export async function getVideosFor(channelName) {
const json = JSON.parse(match[1].trim())
const videoTab = json.contents.twoColumnBrowseResultsRenderer.tabs.find(t => t.tabRenderer?.title === 'Videos')
const videoContents = videoTab.tabRenderer.content.richGridRenderer.contents
- return videoContents.map(toInternalVideo).filter(Boolean)
+ return videoContents
+ .map(toInternalVideo)
+ .filter(Boolean)
+ .filter(v => v.publishedAt > new Date(Date.now() - 30 * 24 * 60 * 60 * 1000))
+ .filter((_,i) => i<10)
} catch (error) {
console.error('Error fetching latest video:', error)
return null