From 8642d466b666192eca09998ba054312b39b8b498 Mon Sep 17 00:00:00 2001 From: Nick Maynard Date: Mon, 4 Dec 2023 22:32:42 +0000 Subject: [PATCH 01/42] Multi-stage build to reduce image size --- Dockerfile | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d835ec..af74796 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,38 @@ -FROM node:latest +FROM node:latest AS build -LABEL Description="Project for automatically organizing and downloading Floatplane videos for plex." - -# Environment variables -ENV headless=true -ENV runQuickstartPrompts=false - -# Create Directory for the Container -WORKDIR /fp - -# Define volumes to be mountable -VOLUME /fp/db -VOLUME /fp/videos +# working directory for the build +WORKDIR ${HOME} # Copy package configs into working Directory -COPY ./package.json ./package-lock.json ./tsconfig.json /fp/ +COPY ./package.json ./package-lock.json ./tsconfig.json ${HOME}/ # Install required packages -RUN npm install +RUN npm ci --omit-dev # Copy src files into Working Directory -COPY ./src /fp/src +COPY ./src ${HOME}/src # Compile the project RUN npx tsc +# Copy built artifacts and dependencies into a minimal release image +FROM node:slim AS release + +LABEL Description="Project for automatically organizing and downloading Floatplane videos for plex." + +# Create Directory for the Container +WORKDIR /fp + +COPY --from=build ${HOME}/node_modules node_modules +COPY --from=build ${HOME}/dist dist + +# Environment variables +ENV headless=true +ENV runQuickstartPrompts=false + +# Define volumes to be mountable +VOLUME /fp/db +VOLUME /fp/videos + # Runs on container start CMD node ./dist/float.js \ No newline at end of file From fcd92f0ddd3334c9d39676390e2def155c033fce Mon Sep 17 00:00:00 2001 From: Nick Maynard Date: Mon, 4 Dec 2023 22:45:40 +0000 Subject: [PATCH 02/42] Add missing package.json necessary for node execution --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index af74796..63e7fa5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ WORKDIR /fp COPY --from=build ${HOME}/node_modules node_modules COPY --from=build ${HOME}/dist dist +COPY --from=build ${HOME}/package.json package.json # Environment variables ENV headless=true From 656131e4ab2df44a71f18a9979203cb07ae0d968 Mon Sep 17 00:00:00 2001 From: Inrixia Date: Wed, 27 Dec 2023 00:57:06 +1300 Subject: [PATCH 03/42] Fix #186 --- package-lock.json | 4 ++-- src/lib/Video.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 95a5a30..d522e9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "floatplane-plex-downloader", - "version": "5.9.0", + "version": "5.10.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "floatplane-plex-downloader", - "version": "5.9.0", + "version": "5.10.2", "dependencies": { "@ctrl/plex": "^1.5.3", "@inrixia/db": "2.0.2", diff --git a/src/lib/Video.ts b/src/lib/Video.ts index 3c312f7..64f9a15 100644 --- a/src/lib/Video.ts +++ b/src/lib/Video.ts @@ -89,7 +89,7 @@ export class Video { .join("/"); // Ensure filePath is not exceeding maximum length - if (this.filePath.length > 255) this.filePath = this.filePath.substring(0, 255); + if (this.filePath.length > 250) this.filePath = this.filePath.substring(0, 250); this.folderPath = this.filePath.substring(0, this.filePath.lastIndexOf("/")); From dd92e3fddf7856bb1c058d79ae307468160dbc80 Mon Sep 17 00:00:00 2001 From: Inrixia Date: Wed, 3 Jan 2024 14:25:08 +1300 Subject: [PATCH 04/42] Remove channel identifiers adding functional isChannel matching This should properly implement #187 and finally give a solution for #181 and #179 --- src/lib/Subscription.ts | 106 ++++++++++++++---------------------- src/lib/defaults.ts | 28 ++-------- src/lib/types.ts | 7 +-- src/subscriptionFetching.ts | 5 +- 4 files changed, 49 insertions(+), 97 deletions(-) diff --git a/src/lib/Subscription.ts b/src/lib/Subscription.ts index 2856daf..9a748e1 100644 --- a/src/lib/Subscription.ts +++ b/src/lib/Subscription.ts @@ -4,7 +4,7 @@ import chalk from "chalk"; import { rm } from "fs/promises"; import type { ChannelOptions, SubscriptionSettings } from "./types.js"; -import type { ContentPost } from "floatplane/content"; +import type { ContentPost, VideoContent } from "floatplane/content"; import type { BlogPost } from "floatplane/creator"; import { Video } from "./Video.js"; @@ -26,6 +26,7 @@ const removeRepeatedSentences = (postTitle: string, attachmentTitle: string) => }; type BlogPosts = typeof fApi.creator.blogPostsIterable; +type isChannel = (post: BlogPost, video?: VideoContent) => boolean; export default class Subscription { public channels: SubscriptionSettings["channels"]; @@ -80,85 +81,58 @@ export default class Subscription { }; private static getIgnoreBeforeTimestamp = (channel: ChannelOptions) => Date.now() - (channel.daysToKeepVideos ?? 0) * 24 * 60 * 60 * 1000; + private static isChannelCache: Record = {}; + private static isChannelHelper = `const isChannel = (post, channelId) => (typeof post.channel !== 'string' ? post.channel.id : post.channel) === channelId`; private async *matchChannel(blogPost: BlogPost): AsyncGenerator