A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
wip
Christian Feif98435e83f08
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..55a0cad--- /dev/null+++ b/.gitignore@@ -0,0 +1,138 @@+# Logs+logs+*.log+npm-debug.log*+yarn-debug.log*+yarn-error.log*+lerna-debug.log*+.pnpm-debug.log*++# Diagnostic reports (https://nodejs.org/api/report.html)+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json++# Runtime data+pids+*.pid+*.seed+*.pid.lock++# Directory for instrumented libs generated by jscoverage/JSCover+lib-cov++# Coverage directory used by tools like istanbul+coverage+*.lcov++# nyc test coverage+.nyc_output++# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)+.grunt++# Bower dependency directory (https://bower.io/)+bower_components++# node-waf configuration+.lock-wscript++# Compiled binary addons (https://nodejs.org/api/addons.html)+build/Release++# Dependency directories+node_modules/+jspm_packages/++# Snowpack dependency directory (https://snowpack.dev/)+web_modules/++# TypeScript cache+*.tsbuildinfo++# Optional npm cache directory+.npm++# Optional eslint cache+.eslintcache++# Optional stylelint cache+.stylelintcache++# Microbundle cache+.rpt2_cache/+.rts2_cache_cjs/+.rts2_cache_es/+.rts2_cache_umd/++# Optional REPL history+.node_repl_history++# Output of 'npm pack'+*.tgz++# Yarn Integrity file+.yarn-integrity++# dotenv environment variable files+.env+.env.development.local+.env.test.local+.env.production.local+.env.local++# parcel-bundler cache (https://parceljs.org/)+.cache+.parcel-cache++# Next.js build output+.next+out++# Nuxt.js build / generate output+.nuxt+dist++# Gatsby files+.cache/+# Comment in the public line in if your project uses Gatsby and not Next.js+# https://nextjs.org/blog/next-9-1#public-directory-support+# public++# vuepress build output+.vuepress/dist++# vuepress v2.x temp and cache directory+.temp+.cache++# vitepress build output+**/.vitepress/dist++# vitepress cache directory+**/.vitepress/cache++# Docusaurus cache and generated files+.docusaurus++# Serverless directories+.serverless/++# FuseBox cache+.fusebox/++# DynamoDB Local files+.dynamodb/++# TernJS port file+.tern-port++# Stores VSCode versions used for testing VSCode extensions+.vscode-test++# yarn v2+.yarn/cache+.yarn/unplugged+.yarn/build-state.yml+.yarn/install-state.gz+.pnp.*++data\ No newline at end of filediff --git a/index.html b/index.htmlnew file mode 100644index 0000000..b789e26--- /dev/null+++ b/index.html@@ -0,0 +1,127 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>my-yt</title>+ <style>+ body {+ font-family: Arial, sans-serif;+ margin: 20px;+ }+ form {+ margin-bottom: 20px;+ }+ ul {+ list-style-type: none;+ padding: 0;+ }+ li {+ margin-bottom: 10px;+ }+ </style>+ <style>+ .videos-container {+ display: flex;+ justify-content: space-between;+ flex-wrap: wrap;+ gap: 10px;+ padding: 10px;+ margin: 0;+ }+ .video {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ max-width: 280px;+ text-align: left;+ text-decoration: none;+ color: black;+ font-weight: bold;+ padding: 5px;+ background-color: #f0f0f0;+ margin: 5px;+ }+ .video img {+ width: 100%;+ height: auto;+ }+ .video span {+ font-size: 10px;+ color: #555;+ }+ .video a {+ text-decoration: none;+ color: black;+ }+ </style>+</head>+<body>+ <form id="add-channel-form">+ <input type="text" id="channel-name" placeholder="Channel Name" required>+ <button type="submit">Add Channel</button>+ </form>+ <div class="channels-container"></div>++ <script>+ document.getElementById('add-channel-form').addEventListener('submit', async (event) => {+ event.preventDefault();++ const channelName = document.getElementById('channel-name').value;++ if (!channelName) return alert('empty channel name');++ try {+ await fetch('/channels', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ name: channelName })+ });++ document.getElementById('add-channel-form').reset();+ updatevideosList();+ } catch (error) {+ console.error('Error adding channel:', error);+ }+ });++ async function updatevideosList() {+ try {+ const response = await fetch('/videos');+ const latestVideos = await response.json();++ const $channelsContainer = document.querySelector('.channels-container');+ $channelsContainer.innerHTML = '';++ for (const [name, videos] of Object.entries(latestVideos)) {+ const $channelSection = document.createElement('details')+ // $channelSection.open = true+ $channelSection.classList.add('channel-details')+ $channelSection.innerHTML = `<summary>${name}</summary>`+ const $videosContainer = document.createElement('div');+ $videosContainer.classList.add('videos-container')+ $channelSection.appendChild($videosContainer);+ for (const video of videos) {+ const $video = document.createElement('div');+ $video.classList.add('video')+ $video.innerHTML = `+ <a href="${video.url}" target="_blank">+ <img src="${video.thumbnail}"/>+ <span>${video.publishedTime}</span> | <span>${video.viewCount}</span> | <span>${video.duration || 'N/A'}</span><br/>+ ${video.title}+ </a>+ `+ $videosContainer.appendChild($video)+ }+ $channelsContainer.appendChild($channelSection);+ }+ } catch (error) {+ console.error('Error fetching latest videos:', error);+ }+ }++ updatevideosList();+ </script>++</body>+</html>diff --git a/package-lock.json b/package-lock.jsonnew file mode 100644index 0000000..23b7d55--- /dev/null+++ b/package-lock.json@@ -0,0 +1,898 @@+{+ "name": "my-yt",+ "version": "1.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "my-yt",+ "version": "1.0.0",+ "license": "ISC",+ "dependencies": {+ "execa": "^9.5.2",+ "http-server": "^14.1.1"+ }+ },+ "node_modules/@sec-ant/readable-stream": {+ "version": "0.4.1",+ "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz",+ "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==",+ "license": "MIT"+ },+ "node_modules/@sindresorhus/merge-streams": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz",+ "integrity": "sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/ansi-styles": {+ "version": "4.3.0",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",+ "license": "MIT",+ "dependencies": {+ "color-convert": "^2.0.1"+ },+ "engines": {+ "node": ">=8"+ },+ "funding": {+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"+ }+ },+ "node_modules/async": {+ "version": "2.6.4",+ "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",+ "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",+ "license": "MIT",+ "dependencies": {+ "lodash": "^4.17.14"+ }+ },+ "node_modules/basic-auth": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",+ "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",+ "license": "MIT",+ "dependencies": {+ "safe-buffer": "5.1.2"+ },+ "engines": {+ "node": ">= 0.8"+ }+ },+ "node_modules/call-bind-apply-helpers": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz",+ "integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "function-bind": "^1.1.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/call-bound": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz",+ "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.1",+ "get-intrinsic": "^1.2.6"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/chalk": {+ "version": "4.1.2",+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",+ "license": "MIT",+ "dependencies": {+ "ansi-styles": "^4.1.0",+ "supports-color": "^7.1.0"+ },+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/chalk/chalk?sponsor=1"+ }+ },+ "node_modules/color-convert": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",+ "license": "MIT",+ "dependencies": {+ "color-name": "~1.1.4"+ },+ "engines": {+ "node": ">=7.0.0"+ }+ },+ "node_modules/color-name": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",+ "license": "MIT"+ },+ "node_modules/corser": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/corser/-/corser-2.0.1.tgz",+ "integrity": "sha512-utCYNzRSQIZNPIcGZdQc92UVJYAhtGAteCFg0yRaFm8f0P+CPtyGyHXJcGXnffjCybUCEx3FQ2G7U3/o9eIkVQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4.0"+ }+ },+ "node_modules/cross-spawn": {+ "version": "7.0.6",+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",+ "license": "MIT",+ "dependencies": {+ "path-key": "^3.1.0",+ "shebang-command": "^2.0.0",+ "which": "^2.0.1"+ },+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/debug": {+ "version": "3.2.7",+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",+ "license": "MIT",+ "dependencies": {+ "ms": "^2.1.1"+ }+ },+ "node_modules/dunder-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.1",+ "es-errors": "^1.3.0",+ "gopd": "^1.2.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-define-property": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-errors": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/es-object-atoms": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz",+ "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/eventemitter3": {+ "version": "4.0.7",+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",+ "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",+ "license": "MIT"+ },+ "node_modules/execa": {+ "version": "9.5.2",+ "resolved": "https://registry.npmjs.org/execa/-/execa-9.5.2.tgz",+ "integrity": "sha512-EHlpxMCpHWSAh1dgS6bVeoLAXGnJNdR93aabr4QCGbzOM73o5XmRfM/e5FUqsw3aagP8S8XEWUWFAxnRBnAF0Q==",+ "license": "MIT",+ "dependencies": {+ "@sindresorhus/merge-streams": "^4.0.0",+ "cross-spawn": "^7.0.3",+ "figures": "^6.1.0",+ "get-stream": "^9.0.0",+ "human-signals": "^8.0.0",+ "is-plain-obj": "^4.1.0",+ "is-stream": "^4.0.1",+ "npm-run-path": "^6.0.0",+ "pretty-ms": "^9.0.0",+ "signal-exit": "^4.1.0",+ "strip-final-newline": "^4.0.0",+ "yoctocolors": "^2.0.0"+ },+ "engines": {+ "node": "^18.19.0 || >=20.5.0"+ },+ "funding": {+ "url": "https://github.com/sindresorhus/execa?sponsor=1"+ }+ },+ "node_modules/figures": {+ "version": "6.1.0",+ "resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz",+ "integrity": "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==",+ "license": "MIT",+ "dependencies": {+ "is-unicode-supported": "^2.0.0"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/follow-redirects": {+ "version": "1.15.9",+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",+ "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",+ "funding": [+ {+ "type": "individual",+ "url": "https://github.com/sponsors/RubenVerborgh"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=4.0"+ },+ "peerDependenciesMeta": {+ "debug": {+ "optional": true+ }+ }+ },+ "node_modules/function-bind": {+ "version": "1.1.2",+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/get-intrinsic": {+ "version": "1.2.7",+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz",+ "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==",+ "license": "MIT",+ "dependencies": {+ "call-bind-apply-helpers": "^1.0.1",+ "es-define-property": "^1.0.1",+ "es-errors": "^1.3.0",+ "es-object-atoms": "^1.0.0",+ "function-bind": "^1.1.2",+ "get-proto": "^1.0.0",+ "gopd": "^1.2.0",+ "has-symbols": "^1.1.0",+ "hasown": "^2.0.2",+ "math-intrinsics": "^1.1.0"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/get-proto": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",+ "license": "MIT",+ "dependencies": {+ "dunder-proto": "^1.0.1",+ "es-object-atoms": "^1.0.0"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/get-stream": {+ "version": "9.0.1",+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz",+ "integrity": "sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==",+ "license": "MIT",+ "dependencies": {+ "@sec-ant/readable-stream": "^0.4.1",+ "is-stream": "^4.0.1"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/gopd": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/has-flag": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/has-symbols": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/hasown": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",+ "license": "MIT",+ "dependencies": {+ "function-bind": "^1.1.2"+ },+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/he": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",+ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",+ "license": "MIT",+ "bin": {+ "he": "bin/he"+ }+ },+ "node_modules/html-encoding-sniffer": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",+ "integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",+ "license": "MIT",+ "dependencies": {+ "whatwg-encoding": "^2.0.0"+ },+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/http-proxy": {+ "version": "1.18.1",+ "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",+ "integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",+ "license": "MIT",+ "dependencies": {+ "eventemitter3": "^4.0.0",+ "follow-redirects": "^1.0.0",+ "requires-port": "^1.0.0"+ },+ "engines": {+ "node": ">=8.0.0"+ }+ },+ "node_modules/http-server": {+ "version": "14.1.1",+ "resolved": "https://registry.npmjs.org/http-server/-/http-server-14.1.1.tgz",+ "integrity": "sha512-+cbxadF40UXd9T01zUHgA+rlo2Bg1Srer4+B4NwIHdaGxAGGv59nYRnGGDJ9LBk7alpS0US+J+bLLdQOOkJq4A==",+ "license": "MIT",+ "dependencies": {+ "basic-auth": "^2.0.1",+ "chalk": "^4.1.2",+ "corser": "^2.0.1",+ "he": "^1.2.0",+ "html-encoding-sniffer": "^3.0.0",+ "http-proxy": "^1.18.1",+ "mime": "^1.6.0",+ "minimist": "^1.2.6",+ "opener": "^1.5.1",+ "portfinder": "^1.0.28",+ "secure-compare": "3.0.1",+ "union": "~0.5.0",+ "url-join": "^4.0.1"+ },+ "bin": {+ "http-server": "bin/http-server"+ },+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/human-signals": {+ "version": "8.0.0",+ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-8.0.0.tgz",+ "integrity": "sha512-/1/GPCpDUCCYwlERiYjxoczfP0zfvZMU/OWgQPMya9AbAE24vseigFdhAMObpc8Q4lc/kjutPfUddDYyAmejnA==",+ "license": "Apache-2.0",+ "engines": {+ "node": ">=18.18.0"+ }+ },+ "node_modules/iconv-lite": {+ "version": "0.6.3",+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",+ "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",+ "license": "MIT",+ "dependencies": {+ "safer-buffer": ">= 2.1.2 < 3.0.0"+ },+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/is-plain-obj": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",+ "integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",+ "license": "MIT",+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/is-stream": {+ "version": "4.0.1",+ "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz",+ "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/is-unicode-supported": {+ "version": "2.1.0",+ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz",+ "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/isexe": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",+ "license": "ISC"+ },+ "node_modules/lodash": {+ "version": "4.17.21",+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",+ "license": "MIT"+ },+ "node_modules/math-intrinsics": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/mime": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",+ "license": "MIT",+ "bin": {+ "mime": "cli.js"+ },+ "engines": {+ "node": ">=4"+ }+ },+ "node_modules/minimist": {+ "version": "1.2.8",+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",+ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/mkdirp": {+ "version": "0.5.6",+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",+ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",+ "license": "MIT",+ "dependencies": {+ "minimist": "^1.2.6"+ },+ "bin": {+ "mkdirp": "bin/cmd.js"+ }+ },+ "node_modules/ms": {+ "version": "2.1.3",+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",+ "license": "MIT"+ },+ "node_modules/npm-run-path": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-6.0.0.tgz",+ "integrity": "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA==",+ "license": "MIT",+ "dependencies": {+ "path-key": "^4.0.0",+ "unicorn-magic": "^0.3.0"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/npm-run-path/node_modules/path-key": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz",+ "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==",+ "license": "MIT",+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/object-inspect": {+ "version": "1.13.3",+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz",+ "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/opener": {+ "version": "1.5.2",+ "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz",+ "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==",+ "license": "(WTFPL OR MIT)",+ "bin": {+ "opener": "bin/opener-bin.js"+ }+ },+ "node_modules/parse-ms": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/parse-ms/-/parse-ms-4.0.0.tgz",+ "integrity": "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/path-key": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/portfinder": {+ "version": "1.0.32",+ "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz",+ "integrity": "sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==",+ "license": "MIT",+ "dependencies": {+ "async": "^2.6.4",+ "debug": "^3.2.7",+ "mkdirp": "^0.5.6"+ },+ "engines": {+ "node": ">= 0.12.0"+ }+ },+ "node_modules/pretty-ms": {+ "version": "9.2.0",+ "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-9.2.0.tgz",+ "integrity": "sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==",+ "license": "MIT",+ "dependencies": {+ "parse-ms": "^4.0.0"+ },+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/qs": {+ "version": "6.13.1",+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.1.tgz",+ "integrity": "sha512-EJPeIn0CYrGu+hli1xilKAPXODtJ12T0sP63Ijx2/khC2JtuaN3JyNIpvmnkmaEtha9ocbG4A4cMcr+TvqvwQg==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "side-channel": "^1.0.6"+ },+ "engines": {+ "node": ">=0.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/requires-port": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",+ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==",+ "license": "MIT"+ },+ "node_modules/safe-buffer": {+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",+ "license": "MIT"+ },+ "node_modules/safer-buffer": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",+ "license": "MIT"+ },+ "node_modules/secure-compare": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/secure-compare/-/secure-compare-3.0.1.tgz",+ "integrity": "sha512-AckIIV90rPDcBcglUwXPF3kg0P0qmPsPXAj6BBEENQE1p5yA1xfmDJzfi1Tappj37Pv2mVbKpL3Z1T+Nn7k1Qw==",+ "license": "MIT"+ },+ "node_modules/shebang-command": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",+ "license": "MIT",+ "dependencies": {+ "shebang-regex": "^3.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/shebang-regex": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/side-channel": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "object-inspect": "^1.13.3",+ "side-channel-list": "^1.0.0",+ "side-channel-map": "^1.0.1",+ "side-channel-weakmap": "^1.0.2"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-list": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",+ "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",+ "license": "MIT",+ "dependencies": {+ "es-errors": "^1.3.0",+ "object-inspect": "^1.13.3"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-map": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",+ "license": "MIT",+ "dependencies": {+ "call-bound": "^1.0.2",+ "es-errors": "^1.3.0",+ "get-intrinsic": "^1.2.5",+ "object-inspect": "^1.13.3"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/side-channel-weakmap": {+ "version": "1.0.2",+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",+ "license": "MIT",+ "dependencies": {+ "call-bound": "^1.0.2",+ "es-errors": "^1.3.0",+ "get-intrinsic": "^1.2.5",+ "object-inspect": "^1.13.3",+ "side-channel-map": "^1.0.1"+ },+ "engines": {+ "node": ">= 0.4"+ },+ "funding": {+ "url": "https://github.com/sponsors/ljharb"+ }+ },+ "node_modules/signal-exit": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",+ "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",+ "license": "ISC",+ "engines": {+ "node": ">=14"+ },+ "funding": {+ "url": "https://github.com/sponsors/isaacs"+ }+ },+ "node_modules/strip-final-newline": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-4.0.0.tgz",+ "integrity": "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/supports-color": {+ "version": "7.2.0",+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",+ "license": "MIT",+ "dependencies": {+ "has-flag": "^4.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/unicorn-magic": {+ "version": "0.3.0",+ "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.3.0.tgz",+ "integrity": "sha512-+QBBXBCvifc56fsbuxZQ6Sic3wqqc3WWaqxs58gvJrcOuN83HGTCwz3oS5phzU9LthRNE9VrJCFCLUgHeeFnfA==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/union": {+ "version": "0.5.0",+ "resolved": "https://registry.npmjs.org/union/-/union-0.5.0.tgz",+ "integrity": "sha512-N6uOhuW6zO95P3Mel2I2zMsbsanvvtgn6jVqJv4vbVcz/JN0OkL9suomjQGmWtxJQXOCqUJvquc1sMeNz/IwlA==",+ "dependencies": {+ "qs": "^6.4.0"+ },+ "engines": {+ "node": ">= 0.8.0"+ }+ },+ "node_modules/url-join": {+ "version": "4.0.1",+ "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.1.tgz",+ "integrity": "sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==",+ "license": "MIT"+ },+ "node_modules/whatwg-encoding": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",+ "integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",+ "license": "MIT",+ "dependencies": {+ "iconv-lite": "0.6.3"+ },+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/which": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",+ "license": "ISC",+ "dependencies": {+ "isexe": "^2.0.0"+ },+ "bin": {+ "node-which": "bin/node-which"+ },+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/yoctocolors": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/yoctocolors/-/yoctocolors-2.1.1.tgz",+ "integrity": "sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==",+ "license": "MIT",+ "engines": {+ "node": ">=18"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ }+ }+}diff --git a/package.json b/package.jsonnew file mode 100644index 0000000..b209647--- /dev/null+++ b/package.json@@ -0,0 +1,17 @@+{+ "name": "my-yt",+ "type": "module",+ "version": "1.0.0",+ "main": "index.js",+ "scripts": {+ "test": "echo \"Error: no test specified\" && exit 1"+ },+ "keywords": [],+ "author": "",+ "license": "ISC",+ "description": "",+ "dependencies": {+ "execa": "^9.5.2",+ "http-server": "^14.1.1"+ }+}diff --git a/server.js b/server.jsnew file mode 100644index 0000000..026fe3a--- /dev/null+++ b/server.js@@ -0,0 +1,152 @@+import http from 'http';+import { URL } from 'url';+import { execa } from 'execa';+import fs from 'fs';++let channels = await fs.promises.readFile('./data/channels.json')+ .then(data => JSON.parse(data)).catch(err => []);+const videos = await fs.promises.readFile('./data/videos.json')+ .then(data => JSON.parse(data)).catch(err => ({}))++function channelWithAt(channelName = '') {+ return channelName.startsWith('@') ? channelName : '@' + channelName+}++async function getChannelId(channelName) {+ const response = await fetch(`https://www.youtube.com/${channelWithAt(channelName) }`)+ const text = await response.text()+ const channelId = text?.split('channel_id=')[1]?.slice(0, 24)+ console.log('getChannelId', channelName, channelId)+ return channelId+}++async function updateAndPersistVideos () {+ return getVideos()+ .then(async videos => {+ await fs.promises.writeFile('./data/videos.json', JSON.stringify(videos, null, 2));+ console.log('Videos saved to ./data/videos.json');+ }).catch(error => {+ console.error('Error fetching videos:', error);+ })+}++async function getVideos() {+ for (const channel of channels) {+ console.log('updating videos for', channel.name)+ const channelVideos = await getVideosFor(channel.name);+ if (channelVideos) {+ videos[channel.name] = channelVideos;+ }+ }+ return videos;+}++async function getVideosFor(channelName) {+ try {+ const response = await fetch(`https://www.youtube.com/${channelWithAt(channelName)}/videos`);+ const text = await response.text();+ const match = text.match(/var ytInitialData = (.+?);<\/script>/);+ if (match && match[1]) {+ const json = JSON.parse(match[1].trim())+ fs.mkdirSync('./data', { recursive: true })+ fs.writeFileSync(`./data/${channelName}.json`, JSON.stringify(json, null, 2))+ const videoTab = json.contents.twoColumnBrowseResultsRenderer.tabs.find(t => t.tabRenderer.title === 'Video')+ const videos = videoTab.tabRenderer.content.richGridRenderer.contents+ return videos+ .filter(v => {+ return v?.richItemRenderer?.content?.videoRenderer?.title?.runs[0]?.text+ })+ .map(v => ({+ channelName,+ title: v.richItemRenderer.content.videoRenderer.title?.runs[0].text,+ url: `https://www.youtube.com/watch?v=${v.richItemRenderer.content.videoRenderer.videoId}`,+ thumbnail: v.richItemRenderer.content.videoRenderer.thumbnail?.thumbnails[0].url,+ description: v.richItemRenderer.content.videoRenderer.descriptionSnippet?.runs[0].text,+ videoId: v.richItemRenderer.content.videoRenderer.videoId,+ publishedTime: v.richItemRenderer.content.videoRenderer.publishedTimeText.simpleText,+ viewCount: v.richItemRenderer.content.videoRenderer.viewCountText.simpleText,+ duration: v.richItemRenderer.content.videoRenderer.lengthText ? v.richItemRenderer.content.videoRenderer.lengthText.simpleText : null,+ }))+ }+ return null+ } catch (error) {+ console.error('Error fetching latest video:', error);+ return null;+ }+}++async function downloadVideo(url, path) {+ try {+ await execa('yt-dlp', [url, '-o', path]);+ console.log('Download completed');+ } catch (error) {+ console.error('Error downloading video:', error);+ }+}++const server = http.createServer(async (req, res) => {+ const parsedUrl = new URL(req.url, `http://${req.headers.host}`);+ if (parsedUrl.pathname === '/videos') {+ res.writeHead(200, { 'Content-Type': 'application/json' });+ res.end(JSON.stringify(videos));+ return+ }+ if (parsedUrl.pathname === '/channels' && req.method === 'POST') {+ console.log('adding channel')+ let body = '';+ req.on('data', chunk => {+ body += chunk.toString();+ });+ req.on('end', async () => {+ let { name } = JSON.parse(body);+ name = name.trim()+ if (!channels.find(c => c.name === name)) {+ const id = await getChannelId(name)+ console.log('-- added channel', name, id)+ channels.push({ name, id });+ await fs.promises.writeFile('./data/channels.json', JSON.stringify(channels));+ await updateAndPersistVideos()+ res.writeHead(201, { 'Content-Type': 'text/plain' });+ res.end('Channel added');+ } else {+ console.log('channel already added', name)+ res.writeHead(409, { 'Content-Type': 'text/plain' });+ res.end('Channel already added');+ }+ })+ return+ }+ if (parsedUrl.pathname === '/download-video' && req.method === 'POST') {+ let body = '';+ req.on('data', chunk => {+ body += chunk.toString();+ });+ req.on('end', () => {+ const { url, path } = JSON.parse(body);+ downloadVideo(url, path).then(() => {+ res.writeHead(200, { 'Content-Type': 'text/plain' });+ res.end('Download started');+ }).catch(error => {+ console.error('Error starting download:', error);+ res.writeHead(500, { 'Content-Type': 'text/plain' });+ res.end('Internal Server Error');+ });+ });+ return+ }+ const indexHtml = await fs.promises.readFile('index.html', 'utf8');+ res.writeHead(200, { 'Content-Type': 'text/html' });+ res.end(indexHtml);+});++async function main ({port = 3000} = {}) {+ await updateAndPersistVideos()+ server.listen(port, () => {+ console.log(`Server running at http://localhost:${port}`);+ });+}++if (import.meta.url.endsWith('server.js')) {+ main();+}+