YouTube.js
YouTube.js copied to clipboard
Integration; potentially continuous bi-directional integration / collaboration
Describe your suggestion
@LuanRT Considering the (partial and potential) intersection in our works (https://github.com/code-charity/youtube), do any steps come to mind how I could start to make the best out of that? thank you!
@code-charity/developers
Checklist
- [x] I have provided sufficient information.
To be more precise, we have not yet used the API, but other funny methods
DATA = {}; defaultKeywords = "video,sharing,camera,phone,video phone,free,upload";
DATA = JSON.parse(document.querySelector('#microformat script')?.textContent) ?? false; }
DATA.title = DATA.name || DATA.title = document.getElementsByTagName('meta')?.title?.content || false;
DATA.genre = document.querySelector('meta[itemprop=genre]')?.content || false;
DATA.duration = document.querySelector('meta[itemprop=duration]')?.content || false;
if ( DATA.title === ImprovedTube.videoTitle() || DATA.title.replace(/\s{2,}/g, ' ') === ImprovedTube.videoTitle() ) {
keywords = document.querySelector('meta[name="keywords"]')?.content || '';
ImprovedTube.speedException();
} else { (async function () { try {
const response = await fetch(`https://www.youtube.com/watch?v=${DATA.videoID}`);
console.log("loading the html source:" + `https://www.youtube.com/watch?v=${DATA.videoID}`);
const htmlContent = await response.text();
const metaRegex = /<meta[^>]+(name|itemprop)=["'](keywords|genre|duration)["'][^>]+content=["']([^"']+)["'][^>]*>/gi;
let match; while ((match = metaRegex.exec(htmlContent)) !== null) { // console.log(match);
const [, property, value] = match;
if (property === 'keywords') { keywords = value;} else {DATA[property] = value;}
}
amountOfSongs = (htmlContent.slice(-80000).match(/},"subtitle":{"simpleText":"(\d*)\s/) || [])[1] || false;
if (keywords) {
ImprovedTube.speedException();
}