Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

english as main language

Christian Feif1ed2f824686
diff --git a/lib/youtube.js b/lib/youtube.js
index 869f540..b88982e 100644
--- a/lib/youtube.js
+++ b/lib/youtube.js
@@ -28,13 +28,15 @@ export async function getVideoSubtitles (id, callback = () => {}) {
export async function getVideosFor(channelName) {
try {
- const response = await fetch(`https://www.youtube.com/${channelWithAt(channelName)}/videos`)
+ const response = await fetch(`https://www.youtube.com/${channelWithAt(channelName)}/videos`, {
+ headers: { 'Accept-Language': 'en' }
+ })
const text = await response.text()
const match = text.match(/var ytInitialData = (.+?);<\/script>/)
if (!match || !match[1]) return null
const json = JSON.parse(match[1].trim())
- const videoTab = json.contents.twoColumnBrowseResultsRenderer.tabs.find(t => t.tabRenderer.title === 'Video')
+ 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)
} catch (error) {