Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jellyfin): Enforcing media type and session handling fixes #210

Merged
merged 11 commits into from
Oct 15, 2024
Merged
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"vscode": {
"extensions": [
"hbenl.vscode-mocha-test-adapter",
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"unifiedjs.vscode-mdx"
]
}
},
Expand Down
9 changes: 8 additions & 1 deletion config/jellyfin.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
"url": "http://localhost:8096",
"user": "FoxxMD",
"apiKey": "c9fae8756fbf481ebd9c5bb56bd6540c",

// everything below is optional
"usersAllow": ["FoxxMD","SomeOtherUser"],
"usersBlock": ["AnotherUser"],
"devicesAllow": ["firefox"],
"devicesBlock": ["google-home"]
"devicesBlock": ["google-home"],
"librariesAllow": ["GoodMusic"],
"librariesBlock": ["BadMusic"],
"additionalAllowedLibraryTypes": ["musicvideos"],
"allowUnknown": false,
},
"options": {
"logPayload": true,
"logFilterFailure": "debug"
}
}
Expand Down
22 changes: 17 additions & 5 deletions docsite/docs/configuration/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -387,24 +387,36 @@ Must be using Jellyfin 10.7 or greater

It is **recommended** to use API Key + username but if you are not an admin for your Jellyfin instance you can also authenticate with your Jellyfin username and **password.**

#### Configuration
:::tip[Important Defaults]

:::tip
By default...

By default, multi-scrobbler will only scrobble for the user authenticated with the API. Allowed Users are only necessary if you want to scrobble for additional users.
* multi-scrobbler will **only** scrobbling for the user authenticated with the API.
* Allowed Users (`usersAllow` or `JELLYFIN_USERS_ALLOW`) are only necessary if you want to scrobble for additional users.
* multi-scrobbler will only scrobble media found in Jellyfin libraries that were labelled as **Music.**
* `librariesAllow` or `JELLYFIN_LIBRARIES_ALLOW` will override this
* OR use `additionalAllowedLibraryTypes` to allow more types (like `mixed` or `book` for audiobooks)
* multi-scrobbler will only scrobble media Jellyfin detects as **Audio.**
* To force multi-scrobbler to scrobble when media is detected as **Unknown** use `"allowUnknown": true` in file/aio configuration.

:::

#### Configuration

<Tabs groupId="configType" queryString>
<TabItem value="env" label="ENV">
| Environmental Variable | Required? | Default | Description |
|----------------------------|-----------|---------|--------------------------------------------------------------------------------------------|
| -------------------------- | --------- | ------- | ------------------------------------------------------------------------------------------ |
| `JELLYFIN_URL` | **Yes** | | The URL of the Jellyfin server IE `http://localhost:8096` |
| `JELLYFIN_USER` | **Yes** | | The user to authenticate with the API |
| `JELLYFIN_APIKEY` | No | | The API Key to use for authentication **(Must provide either apikey or password)** |
| `JELLYFIN_PASSWORD` | No | | The password of the user to authenticate for. **(Must provide either apikey or password)** |
| `JELLYFIN_USERS_ALLOW` | No | | Comma-separated list of usernames (from Jellyfin) to scrobble for |
| `JELLYFIN_USERS_BLOCK` | No | | Comma-separated list of usernames (from Jellyfin) to disallow scrobble for |
| `JELLYFIN_DEVICES_ALLOW` | No | | Comma-separated list of devices to scrobble from |
| `JELLYFIN_DEVICES_BLOCK` | No | | Comma-separated list of devices to disallow scrobbles from |
| `JELLYFIN_LIBRARIES_ALLOW` | No | | Comma-separated list of libraries to allow scrobbles from |
| `JELLYFIN_LIBRARIES_BLOCK` | No | | Comma-separated list of libraries to disallow scrobbles from |
</TabItem>
<TabItem value="file" label="File">
<details>
Expand All @@ -415,7 +427,7 @@ By default, multi-scrobbler will only scrobble for the user authenticated with t

</details>

or <SchemaLink lower objectName="JellySourceConfig"/>
or <SchemaLink lower objectName="JellyApiSourceConfig"/>

</TabItem>
<TabItem value="aio" label="AIO">
Expand Down
1 change: 1 addition & 0 deletions docsite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docsite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"clsx": "^2.0.0",
"docusaurus-json-schema-plugin": "^1.12.1",
"docusaurus-theme-github-codeblock": "^2.0.2",
"json5": "^2.2.3",
"micromark-extension-directive": "^3.0.1",
"prism-react-renderer": "^2.3.0",
"raw-loader": "^4.0.2",
Expand Down
3 changes: 2 additions & 1 deletion docsite/src/components/AIOExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ErrorBoundary from "@docusaurus/ErrorBoundary"
import Error from "@theme/Error"
import { Simulate } from "react-dom/test-utils";
import error = Simulate.error;
import json5 from 'json5';

export interface AIOProps {
data: string
Expand All @@ -22,7 +23,7 @@ const AIOExample = (props: AIOProps) => {
let configObj;
// eslint-disable-next-line prefer-const
try {
configObj = JSON.parse(data);
configObj = json5.parse(data);
} catch (e) {
console.error(e);
return <Admonition type="danger" title="Unexpected Error">
Expand Down
43 changes: 35 additions & 8 deletions src/backend/common/infrastructure/config/source/jellyfin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { CommonSourceConfig, CommonSourceData, CommonSourceOptions } from "./index.js";
import {
// @ts-expect-error weird typings?
CollectionType
} from "@jellyfin/sdk/lib/generated-client/index.js";

export interface JellyData extends CommonSourceData {
/**
Expand Down Expand Up @@ -54,23 +58,46 @@ export interface JellyApiData extends CommonSourceData {

/**
* Only scrobble if device or application name contains strings from this list (case-insensitive)
*
* Note: This only applies to real-time scrobbling as JF does not track device info in user activity history
* */
devicesAllow?: string | string[]
/**
* Do not scrobble if device or application name contains strings from this list (case-insensitive)
*
* Note: This only applies to real-time scrobbling as JF does not track device info in user activity history
* */
devicesBlock?: string | string[]

/**
* Only scrobble if library name contains string from this list (case-insensitive)
* */
librariesAllow?: string | string[]
/**
* Do not scrobble if library name contains strings from this list (case-insensitive)
* */
librariesBlock?: string | string[]

/**
* Allow MS to scrobble audio media in libraries classified other than 'music'
*
* `librariesAllow` will achieve the same result as this but this is more convenient if you do not want to explicitly list every library name or are only using `librariesBlock`
*/
additionalAllowedLibraryTypes?: CollectionType[]

/**
* Force media with a type of "Unknown" to be counted as Audio
*
* @default false
*/
allowUnknown?: boolean
}

export interface JellyApiOptions extends CommonSourceOptions {
/* /!**
* Set a persistent device id suffix
* *!/
deviceId?: string*/
/*
* Outputs JSON for session data the first time a new media ID is seen
*
* For use when troubleshooting issues
*
* @default false
*/
logPayload?: boolean
}

export interface JellySourceConfig extends CommonSourceConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/common/schema/aio-source.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/backend/common/schema/aio.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/backend/common/schema/source.json

Large diffs are not rendered by default.

Loading