Skip to content

Commit

Permalink
Override user agent with floatplane downloader info
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Mar 25, 2023
1 parent 36484f8 commit aba14ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/float.ts
@@ -1,6 +1,6 @@
import { quickStart, validatePlexSettings } from "./quickStart.js";
import { fetchSubscriptions } from "./subscriptionFetching.js";
import { settings, fetchFFMPEG, fApi, args } from "./lib/helpers.js";
import { settings, fetchFFMPEG, fApi, args, DownloaderVersion } from "./lib/helpers.js";
import { MyPlexAccount } from "@ctrl/plex";
import { loginFloatplane } from "./logins.js";
import Downloader from "./Downloader.js";
Expand Down Expand Up @@ -62,19 +62,18 @@ const fetchNewVideos = async (subscriptions: Array<Subscription>, videoProcessor
};

(async () => {
const version = "5.6.0";
if (args.sanityCheck && version !== pkg.version) {
throw new Error(`Version mismatch! package.json says ${pkg.version} but float.ts says ${version}`);
if (args.sanityCheck && DownloaderVersion !== pkg.version) {
throw new Error(`Version mismatch! package.json says ${pkg.version} but float.ts says ${DownloaderVersion}`);
}

const latest = await fApi
.got("https://raw.githubusercontent.com/Inrixia/Floatplane-Downloader/master/package.json")
.json<{ version: string }>()
.catch(() => ({ version }));
.catch(() => ({ version: DownloaderVersion }));

if (gt(latest.version, version))
if (gt(latest.version, DownloaderVersion))
console.log(
chalk`There is a ${diff(latest.version, version)} update available! ${version} > ${
chalk`There is a ${diff(latest.version, DownloaderVersion)} update available! ${DownloaderVersion} > ${
latest.version
}.\nHead to {cyanBright https://github.com/Inrixia/Floatplane-Downloader/releases} to update!\n`
);
Expand Down
7 changes: 6 additions & 1 deletion src/lib/helpers.ts
Expand Up @@ -14,14 +14,19 @@ import "dotenv/config";
import json5 from "json5";
const { parse } = json5;

export const DownloaderVersion = "5.6.0";

import type { PartialArgs, Settings } from "./types.js";

import { FileCookieStore } from "tough-cookie-file-store";
import { CookieJar } from "tough-cookie";
export const cookieJar = new CookieJar(new FileCookieStore("./db/cookies.json"));

import { Floatplane } from "floatplane";
export const fApi = new Floatplane(cookieJar);
export const fApi = new Floatplane(
cookieJar,
`Floatplane-Downloader/${DownloaderVersion} (Inrix, +https://github.com/Inrixia/Floatplane-Downloader), CFNetwork`
);

export const settings = db<Settings>("./db/settings.json", { template: defaultSettings, pretty: true, forceCreate: true, updateOnExternalChanges: true });
recursiveUpdate(settings, defaultSettings);
Expand Down

0 comments on commit aba14ba

Please sign in to comment.