Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

refactor: lib and server folder

Christian Fei5aec21bef485
diff --git a/index.js b/index.js
index b5ebeba..971f248 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,5 @@
import os from 'os'
-import Repository from './server/repository.js'
+import Repository from './lib/repository.js'
import { createServer } from './server/http.js'
async function main ({ port = 3000 } = {}) {
diff --git a/server/ffmpeg.js b/lib/ffmpeg.js
similarity index 100%
rename from server/ffmpeg.js
rename to lib/ffmpeg.js
diff --git a/server/llm/index.js b/lib/llm/index.js
similarity index 100%
rename from server/llm/index.js
rename to lib/llm/index.js
diff --git a/server/llm/providers/anthropic.js b/lib/llm/providers/anthropic.js
similarity index 100%
rename from server/llm/providers/anthropic.js
rename to lib/llm/providers/anthropic.js
diff --git a/server/llm/providers/generic.js b/lib/llm/providers/generic.js
similarity index 100%
rename from server/llm/providers/generic.js
rename to lib/llm/providers/generic.js
diff --git a/server/repository.js b/lib/repository.js
similarity index 100%
rename from server/repository.js
rename to lib/repository.js
diff --git a/server/subtitles-summary.js b/lib/subtitles-summary.js
similarity index 94%
rename from server/subtitles-summary.js
rename to lib/subtitles-summary.js
index 140097b..1e7d612 100644
--- a/server/subtitles-summary.js
+++ b/lib/subtitles-summary.js
@@ -1,7 +1,7 @@
/* eslint-disable no-async-promise-executor */
import fs from 'fs'
-import { getVideoSubtitles } from './youtube.js'
-import * as llm from './llm/index.js'
+import { getVideoSubtitles } from '../lib/youtube.js'
+import * as llm from '../lib/llm/index.js'
export async function summarizeVideo (id, repo, llmSettings = {}, callback = () => {}) {
return new Promise(async (resolve, reject) => {
diff --git a/server/update-videos.js b/lib/update-videos.js
similarity index 100%
rename from server/update-videos.js
rename to lib/update-videos.js
diff --git a/server/youtube.js b/lib/youtube.js
similarity index 100%
rename from server/youtube.js
rename to lib/youtube.js
diff --git a/server/yt-dlp.js b/lib/yt-dlp.js
similarity index 100%
rename from server/yt-dlp.js
rename to lib/yt-dlp.js
diff --git a/server/http.js b/server/http.js
index d7d0274..d960989 100644
--- a/server/http.js
+++ b/server/http.js
@@ -1,10 +1,10 @@
import http from 'http'
import { URL } from 'url'
import { handleSSE, broadcastSSE } from './sse.js'
-import { updateAndPersistVideos } from './update-videos.js'
+import { updateAndPersistVideos } from '../lib/update-videos.js'
import apiHandler from './router/api.js'
import appHandler from './router/app.js'
-import Repository from './repository.js'
+import Repository from '../lib/repository.js'
export function createServer (repo = new Repository()) {
const stateChangeHandler = {
diff --git a/server/router/api.js b/server/router/api.js
index 558c5ac..92b86e4 100644
--- a/server/router/api.js
+++ b/server/router/api.js
@@ -1,10 +1,10 @@
import fs from 'fs'
import { URL } from 'url'
import querystring from 'querystring'
-import { summarizeVideo } from '../subtitles-summary.js'
+import { summarizeVideo } from '../../lib/subtitles-summary.js'
import { broadcastSSE } from '../sse.js'
-import { downloadVideo, extractIdFromUrl, isUnsupportedUrl, isYouTubeUrl } from '../youtube.js'
-import { updateAndPersistVideosForChannel } from '../update-videos.js'
+import { downloadVideo, extractIdFromUrl, isUnsupportedUrl, isYouTubeUrl } from '../../lib/youtube.js'
+import { updateAndPersistVideosForChannel } from '../../lib/update-videos.js'
const llmDefaults = {
model: 'meta-llama-3.1-8b-instruct',
diff --git a/test/llm/index.test.js b/test/llm/index.test.js
index 26fcdc1..50d9a2d 100644
--- a/test/llm/index.test.js
+++ b/test/llm/index.test.js
@@ -2,7 +2,7 @@ import { test, beforeEach } from 'node:test'
import assert from 'node:assert'
import { MockAgent, setGlobalDispatcher } from 'undici'
-import { summarize } from '../../server/llm/index.js'
+import { summarize } from '../../lib/llm/index.js'
const system = 'You are a helpful assistant.'
const prompt = 'Just tell me something'
diff --git a/test/repository.search.test.js b/test/repository.search.test.js
index a6c0d16..2711993 100644
--- a/test/repository.search.test.js
+++ b/test/repository.search.test.js
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test'
import fs from 'fs'
import assert from 'assert'
-import Repository from '../server/repository.js'
+import Repository from '../lib/repository.js'
let repo
test.beforeEach(() => {
diff --git a/test/repository.test.js b/test/repository.test.js
index f473f8d..fffae9f 100644
--- a/test/repository.test.js
+++ b/test/repository.test.js
@@ -1,7 +1,7 @@
import { test, describe } from 'node:test'
import fs from 'fs'
import assert from 'assert'
-import Repository from '../server/repository.js'
+import Repository from '../lib/repository.js'
let repo
test.beforeEach(() => {
diff --git a/test/search.test.js b/test/search.test.js
index 6317f2d..d05346f 100644
--- a/test/search.test.js
+++ b/test/search.test.js
@@ -2,7 +2,7 @@ import { test } from 'node:test'
import fs from 'fs'
import assert from 'assert'
import { searchVideosHandler } from '../server/router/api.js'
-import Repository from '../server/repository.js'
+import Repository from '../lib/repository.js'
const req = {}
const assertRes = (assertionCb) => ({
diff --git a/test/server.test.js b/test/server.test.js
index a05160e..99144b1 100644
--- a/test/server.test.js
+++ b/test/server.test.js
@@ -2,7 +2,7 @@ import { test, describe, mock } from 'node:test'
import fs from 'fs'
import assert from 'assert'
import { createServer } from '../server/http.js'
-import Repository from '../server/repository.js'
+import Repository from '../lib/repository.js'
mock.timers.enable({ apis: ['setInterval'] })
let repo
diff --git a/test/subtitles.summary.test.js b/test/subtitles.summary.test.js
index d09d123..d010912 100644
--- a/test/subtitles.summary.test.js
+++ b/test/subtitles.summary.test.js
@@ -1,6 +1,6 @@
import { test } from 'node:test'
import assert from 'assert'
-import { cleanTranscript } from '../server/subtitles-summary.js'
+import { cleanTranscript } from '../lib/subtitles-summary.js'
test('cleans transcript', () => {
const transcript = `
diff --git a/test/youtube.test.js b/test/youtube.test.js
index 8f39e03..faf99b9 100644
--- a/test/youtube.test.js
+++ b/test/youtube.test.js
@@ -1,6 +1,6 @@
import { test } from 'node:test'
import assert from 'assert'
-import { getVideosFor, getVideo, extractIdFromUrl, isYouTubeUrl, isUnsupportedUrl, isVideoId } from '../server/youtube.js'
+import { getVideosFor, getVideo, extractIdFromUrl, isYouTubeUrl, isUnsupportedUrl, isVideoId } from '../lib/youtube.js'
if (!process.env.CI) {
test('gets videos for channel', async () => {