[READ-ONLY] Mirror of https://github.com/FoxxMD/multi-scrobbler. Scrobble plays from multiple sources to multiple clients docs.multi-scrobbler.app
deezer docker jellyfin koito lastfm listenbrainz maloja mopidy mpris music music-assistant plex scrobble self-hosted spotify subsonic tautulli youtube-music
0

Configure Feed

Select the types of activity you want to include in your feed.

feat(jellyfin): Initial testing suite

FoxxMD (Sep 26, 2023, 11:39 AM EDT) bdbbce4c ac2d453a

+105
+41
src/backend/tests/jellyfin.test.ts
··· 1 + import {describe, it} from 'mocha'; 2 + import {assert} from 'chai'; 3 + import samplePayload from './jellyfin/playbackProgressSample.json'; 4 + 5 + import JellyfinSource from "../sources/JellyfinSource"; 6 + import EventEmitter from "events"; 7 + import {getLogger} from "../common/logging"; 8 + import {JsonPlayObject, PlayObject} from "../../core/Atomic"; 9 + 10 + const dataAsFixture = (data: any): TestFixture => { 11 + return data as TestFixture; 12 + } 13 + 14 + interface TestFixture { 15 + data: any 16 + expected: JsonPlayObject 17 + } 18 + 19 + describe('Jellyfin Payload Parsing', function () { 20 + 21 + it('Should parse PlayProgress payload as PlayObject', async function () { 22 + const fixture = dataAsFixture(samplePayload[0]); 23 + const play = JellyfinSource.formatPlayObj(fixture.data); 24 + 25 + assert.equal(play.data.track, fixture.expected.data.track); 26 + assert.equal(play.meta.mediaType, 'Audio'); 27 + }); 28 + 29 + describe('Correctly detects events as valid/invalid', function () { 30 + 31 + const jfSource = new JellyfinSource('Test', {data: {}}, {localUrl: 'test', configDir: 'test', logger: getLogger({}, 'Test')}, new EventEmitter()); 32 + 33 + it('Should parse PlayProgress with Audio ItemType as valid event', async function () { 34 + const fixture = dataAsFixture(samplePayload[0]); 35 + const play = JellyfinSource.formatPlayObj(fixture.data); 36 + 37 + assert.isTrue(jfSource.isValidEvent(play)) 38 + }); 39 + 40 + }); 41 + });
+64
src/backend/tests/jellyfin/playbackProgressSample.json
··· 1 + [ 2 + { 3 + "data": { 4 + "ServerId": "6c41d884a9c1490f8fd0863e04d75a69", 5 + "ServerName": "maine", 6 + "ServerVersion": "10.8.10", 7 + "ServerUrl": "<redacted>", 8 + "NotificationType": "PlaybackProgress", 9 + "Timestamp": "2023-09-26T11:18:17.8399513-03:00", 10 + "UtcTimestamp": "2023-09-26T14:18:17.8399533Z", 11 + "Name": "Brother Madonna", 12 + "Overview": "", 13 + "Tagline": "", 14 + "ItemId": "514941104216969e74a8d87fc7893ad5", 15 + "ItemType": "Audio", 16 + "RunTimeTicks": 926533312, 17 + "RunTime": "00:01:32", 18 + "Year": 2008, 19 + "Album": "I Kind of Really Want to Make Love to You", 20 + "Artist": "Kitsune\u00B2", 21 + "Provider_musicbrainzalbumartist": "6e659357-5963-4daf-a634-a3596893f3d7", 22 + "Provider_musicbrainzartist": "6e659357-5963-4daf-a634-a3596893f3d7", 23 + "Provider_musicbrainzalbum": "7c10f8a5-669f-4ff6-bb88-de59846c0e0c", 24 + "Provider_musicbrainzreleasegroup": "85c9ae8b-13e4-4fbf-9f09-5e405039772c", 25 + "Provider_musicbrainztrack": "3c2c1f40-b22e-360e-a29a-1b1610190a8c", 26 + "Audio_0_Title": "FLAC - Stereo", 27 + "Audio_0_Type": "Audio", 28 + "Audio_0_Language": null, 29 + "Audio_0_Codec": "flac", 30 + "Audio_0_Channels": 2, 31 + "Audio_0_Bitrate": 917349, 32 + "Audio_0_SampleRate": 44100, 33 + "Audio_0_Default": false, 34 + "PlaybackPositionTicks": 640000000, 35 + "PlaybackPosition": "00:01:04", 36 + "MediaSourceId": "514941104216969e74a8d87fc7893ad5", 37 + "IsPaused": false, 38 + "IsAutomated": true, 39 + "DeviceId": "BC9311B570ABE4BD71EEEC0856A448AD", 40 + "DeviceName": "samsung SM-S901E", 41 + "ClientName": "Android", 42 + "NotificationUsername": "Tabitha", 43 + "UserId": "6d23c30c5e9d4ec6a66db6b05b63e516" 44 + }, 45 + "expected": { 46 + "data": { 47 + "track": "Brother Madonna", 48 + "artists": ["Kitsune²"], 49 + "album": "I Kind of Really Want to Make Love to You", 50 + "duration": 92 51 + }, 52 + "meta": { 53 + "source": "Jellyfin", 54 + "event": "PlaybackProgress", 55 + "mediaType": "Audio", 56 + "trackId": "514941104216969e74a8d87fc7893ad5", 57 + "user": "Tabitha", 58 + "sourceVersion": "10.8.10", 59 + "deviceId": "BC9311B570-samsung SM-S901E", 60 + "trackProgressPosition": 64 61 + } 62 + } 63 + } 64 + ]