Skip to content

Commit

Permalink
merged branch 'webtorrent': add /movies/:id stream and subtitles api
Browse files Browse the repository at this point in the history
commit 8216d90
Author: mirsella <[email protected]>
Date:   Tue Oct 22 11:40:27 2024 +0200

    finally fix remaining errors

commit d166e10
Author: mirsella <[email protected]>
Date:   Tue Oct 22 11:10:58 2024 +0200

    rename app to hypertube

commit 806d88f
Author: mirsella <[email protected]>
Date:   Tue Oct 22 10:43:39 2024 +0200

    Revert "fix nuxt/nuxt#29637"

    This reverts commit b2e9633.

commit b2e9633
Author: mirsella <[email protected]>
Date:   Tue Oct 22 10:24:58 2024 +0200

    fix nuxt/nuxt#29637

commit a7d5ef3
Author: mirsella <[email protected]>
Date:   Tue Oct 22 00:09:21 2024 +0200

    need to debug nodejs error when closing app

    uv loop at [0x747673dff988] has open handles:
    [0x74713c4a09c0] timer (active)
            Close callback: (nil)
            Data: 0x74713c4a08d0
            (First field): 0x74713c378630
    [0x74713c4a08d0] udp (active)
            Close callback: (nil)
            Data: 0x74713c378630
    uv loop at [0x747673dff988] has 2 open handles in total

      #  /usr/bin/node[255359]: void node::CheckedUvLoopClose(uv_loop_t*) at
    ../src/debug_utils.cc:352
      #  Assertion failed: "Unreachable code reached" ": " "uv_loop_close()
    while having open handles"

    ----- Native stack trace -----

     1: 0x5b8027583e11 node::Assert(node::AssertionInfo const&)
    [/usr/bin/node]
     2: 0x5b80274bd909 node::CheckedUvLoopClose(uv_loop_s*) [/usr/bin/node]
     3: 0x5b80276dae6a node::worker::WorkerThreadData::~WorkerThreadData()
    [/usr/bin/node]
     4: 0x5b80276d98f4 node::worker::Worker::Run() [/usr/bin/node]
     5: 0x5b80276d9a2b  [/usr/bin/node]
     6: 0x7476844a339d  [/usr/lib/libc.so.6]
     7: 0x74768452849c  [/usr/lib/libc.so.6]

commit 61578b9
Author: mirsella <[email protected]>
Date:   Mon Oct 21 23:26:39 2024 +0200

    add /movies/:id/subtitles/:lang that return the link to the .srt file

commit e08ec7d
Author: mirsella <[email protected]>
Date:   Mon Oct 21 23:25:06 2024 +0200

    update pages/movies.vue with fixed /movies/[id]/stream

commit 0a0a285
Author: mirsella <[email protected]>
Date:   Mon Oct 21 22:42:56 2024 +0200

    add opensubtitles and /api/movies/[id]/subtitles

commit 0479d63
Author: mirsella <[email protected]>
Date:   Mon Oct 21 22:42:42 2024 +0200

    add /api/movies

commit e0ff075
Author: mirsella <[email protected]>
Date:   Mon Oct 21 22:42:28 2024 +0200

    move stream and ffmpeg endpoint to the right place

commit a9edacf
Author: mirsella <[email protected]>
Date:   Mon Oct 21 19:38:09 2024 +0200

    add comment

    update comment

commit c42c0c3
Author: mirsella <[email protected]>
Date:   Mon Oct 21 19:36:01 2024 +0200

    finish ffmpeg streaming

commit 7e8e92b
Author: mirsella <[email protected]>
Date:   Mon Oct 21 18:47:44 2024 +0200

    little ffmpeg tweak, add movies to gitignore

commit 32ae6fb
Author: mirsella <[email protected]>
Date:   Mon Oct 21 18:32:48 2024 +0200

    use webm instead of mp4 output

    mp4 produced bugged output because ffmpeg wasn't seekable as its a
    stream/pipe instead of a pipe, and so it can't go back and chagne
    already written bytes.
    webm seems to handle it far better, but the convertion is extremly
    slow...

commit 5a6780f
Author: mirsella <[email protected]>
Date:   Mon Oct 21 11:32:50 2024 +0200

    everything seems to be working

commit ecbc9ca
Author: mirsella <[email protected]>
Date:   Sun Oct 20 12:03:51 2024 +0200

    WIP: webtorrent to ffmpeg

commit 35b2446
Author: mirsella <[email protected]>
Date:   Sun Oct 20 00:51:58 2024 +0200

    WIP: try to link webtorrent to ffmpeg

commit 3aac1a9
Author: mirsella <[email protected]>
Date:   Sat Oct 19 18:45:11 2024 +0200

    add fluent ffmpeg

commit 74ac8c4
Author: mirsella <[email protected]>
Date:   Sat Oct 19 18:19:30 2024 +0200

    dockerfile: use pnpm cache and recommanded install method

commit 980814f
Author: mirsella <[email protected]>
Date:   Thu Oct 17 14:52:42 2024 +0200

    bump deps to fix CVE-2023-42282

    to include this release of the ip
    github.com/transitive-bullshit/ip-set/issues/9

commit c0fa066
Author: mirsella <[email protected]>
Date:   Wed Oct 16 23:32:50 2024 +0200

    add TODO comments with future lib we will use

commit c2138cb
Author: mirsella <[email protected]>
Date:   Wed Oct 16 17:06:43 2024 +0200

    add webtorrent and initial torrent downloading implementation
  • Loading branch information
mirsella committed Oct 22, 2024
1 parent 811a5a3 commit f6324c5
Show file tree
Hide file tree
Showing 14 changed files with 609 additions and 170 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
downloaded/

# Nuxt dev/build outputs
.output
.data
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
`pnpm db:push` to apply the schema to the database.

## bonus:

- Some additional Omniauth strategies.
- More API routes to add, delete movies, etc.
- Stream the video via the ~MediaStream~ MediaSource API.
- Manage various video resolutions. ?
- OpenAPI schema with swagger/scalar
- deploy to real server
4 changes: 3 additions & 1 deletion app.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<script setup lang="ts"></script>

<template>
<div>
<div class="flex justify-center my-4">
Expand All @@ -6,6 +8,6 @@
<span class="i-carbon-rocket size-6">new</span>
</button>
</div>
<NuxtWelcome />
<NuxtPage />
</div>
</template>
14 changes: 13 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
function get_from_env(field: string): string {
return process.env[field] || process.exit(1);
}

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2024-04-03",
devtools: { enabled: true },
modules: ["@nuxtjs/tailwindcss"],
runtimeConfig: {
moviesDir: "./movies",
moviesDir: "./downloaded",
opensubtitles_key: get_from_env("OPENSUBTITLES_KEY"),
opensubtitles_username: get_from_env("OPENSUBTITLES_USERNAME"),
opensubtitles_password: get_from_env("OPENSUBTITLES_PASSWORD"),
pgpassword: get_from_env("PGPASSWORD"),
},
nitro: {
experimental: { tasks: true },
scheduledTasks: {
"0 * * * *": ["remove_old_movies"],
},
hooks: {
// fix "Module did not self-register" error. see https://github.com/lovell/sharp/issues/3295
"dev:reload": () => require("node-datachannel"),
},
},
});
11 changes: 8 additions & 3 deletions nuxt.dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
FROM node:20-alpine

RUN npm install -g [email protected]
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

RUN apk add --no-cache ffmpeg

WORKDIR /app
COPY . /app
COPY . .

RUN pnpm install && pnpm build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm build

EXPOSE 3000

Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "nuxt-app",
"name": "hypertube",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -12,7 +12,9 @@
},
"dependencies": {
"drizzle-orm": "^0.35.1",
"fluent-ffmpeg": "^2.1.3",
"nuxt": "^3.13.2",
"opensubtitles.com": "^1.1.0",
"pg": "^8.13.0",
"vue": "latest",
"vue-router": "latest",
Expand All @@ -21,10 +23,12 @@
"packageManager": "[email protected]+sha512.9df9cf27c91715646c7d675d1c9c8e41f6fce88246f1318c1aa6a1ed1aeb3c4f032fcdf4ba63cc69c4fe6d634279176b5358727d8f2cc1e65b65f43ce2f8bfb0",
"devDependencies": {
"@egoist/tailwindcss-icons": "^1.8.1",
"@iconify-json/carbon": "^1.2.1",
"@iconify-json/carbon": "^1.2.3",
"@nuxtjs/tailwindcss": "^6.12.1",
"@types/fluent-ffmpeg": "^2.1.26",
"@types/pg": "^8.11.10",
"daisyui": "^4.12.10",
"@types/webtorrent": "^0.109.8",
"daisyui": "^4.12.13",
"drizzle-kit": "^0.26.2"
}
}
11 changes: 11 additions & 0 deletions pages/movies.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div>
<ClientOnly>
<!-- "deadpool & wolverine" as base64 -->
<video
src="http://localhost:3000/api/movies/ZGVhZHBvb2wgJiB3b2x2ZXJpbmUK"
controls
></video>
</ClientOnly>
</div>
</template>
Loading

0 comments on commit f6324c5

Please sign in to comment.