diff --git a/static/images/integrations/bot_avatars/lidarr.png b/static/images/integrations/bot_avatars/lidarr.png new file mode 100644 index 0000000000..63921bb27b Binary files /dev/null and b/static/images/integrations/bot_avatars/lidarr.png differ diff --git a/static/images/integrations/lidarr/001.png b/static/images/integrations/lidarr/001.png new file mode 100644 index 0000000000..3bd0710ecb Binary files /dev/null and b/static/images/integrations/lidarr/001.png differ diff --git a/static/images/integrations/logos/lidarr.svg b/static/images/integrations/logos/lidarr.svg new file mode 100644 index 0000000000..f17dfa254c Binary files /dev/null and b/static/images/integrations/logos/lidarr.svg differ diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py index 20a65cb2ae..beaefa9111 100644 --- a/zerver/lib/integrations.py +++ b/zerver/lib/integrations.py @@ -36,6 +36,7 @@ CATEGORIES: Dict[str, Promise] = { "continuous-integration": gettext_lazy("Continuous integration"), "customer-support": gettext_lazy("Customer support"), "deployment": gettext_lazy("Deployment"), + "entertainment": gettext_lazy("Entertainment"), "communication": gettext_lazy("Communication"), "financial": gettext_lazy("Financial"), "hr": gettext_lazy("HR"), @@ -408,6 +409,7 @@ WEBHOOK_INTEGRATIONS: List[WebhookIntegration] = [ WebhookIntegration("jotform", ["misc"], display_name="Jotform"), WebhookIntegration("json", ["misc"], display_name="JSON formatter"), WebhookIntegration("librato", ["monitoring"]), + WebhookIntegration("lidarr", ["entertainment"]), WebhookIntegration("mention", ["marketing"], display_name="Mention"), WebhookIntegration("netlify", ["continuous-integration", "deployment"], display_name="Netlify"), WebhookIntegration("newrelic", ["monitoring"], display_name="New Relic"), @@ -743,6 +745,7 @@ DOC_SCREENSHOT_CONFIG: Dict[str, List[BaseScreenshotConfig]] = { "jotform": [ScreenshotConfig("response.json")], "json": [ScreenshotConfig("json_github_push__1_commit.json")], "librato": [ScreenshotConfig("three_conditions_alert.json", payload_as_query_param=True)], + "lidarr": [ScreenshotConfig("lidarr_tracks_grabbed.json")], "mention": [ScreenshotConfig("webfeeds.json")], "nagios": [BaseScreenshotConfig("service_notify.json")], "netlify": [ScreenshotConfig("deploy_building.json")], diff --git a/zerver/webhooks/lidarr/__init__.py b/zerver/webhooks/lidarr/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/zerver/webhooks/lidarr/doc.md b/zerver/webhooks/lidarr/doc.md new file mode 100644 index 0000000000..c3501a8f65 --- /dev/null +++ b/zerver/webhooks/lidarr/doc.md @@ -0,0 +1,22 @@ +Receive Lidarr notifications in Zulip! + +1. {!create-stream.md!} + +1. {!create-bot-construct-url-indented.md!} + +1. Go to your Lidarr dashboard. Click **Settings** and + click **Connect**. Click the **+** icon. + +1. Select **Webhook** and set the name of the webhook to any name + of your choice (e.g **Zulip**). Select the scenarios you would like + to receive notifications for. You may also enter tags if you would like + to be notified about artists with specific tags. + +1. Set **URL** to the **URL** constructed above. Set **Method** to **POST** + and leave the **Username** and **Password** fields blank. + +1. Click **Save** and you should receive a test message. + +{!congrats.md!} + +![](/static/images/integrations/lidarr/001.png) diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_album_grabbed.json b/zerver/webhooks/lidarr/fixtures/lidarr_album_grabbed.json new file mode 100644 index 0000000000..9b0d13e2d8 --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_album_grabbed.json @@ -0,0 +1,25 @@ +{ + "albums": [ + { + "id": 2, + "title": "Labour of Love", + "releaseDate": "1983-01-01T00:00:00Z", + "quality": "MP3-320", + "qualityVersion": 1 + } + ], + "release": { + "quality": "MP3-320", + "qualityVersion": 1, + "releaseTitle": "UB40 - Labour Of Love - [1983] - [320]", + "indexer": "IP Torrents - Jackett", + "size": 96783568 + }, + "eventType": "Grab", + "artist": { + "id": 1, + "name": "UB40", + "path": "/home36/adbtech/media/Music/UB40", + "mbId": "7113aab7-628f-4050-ae49-dbecac110ca8" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_test.json b/zerver/webhooks/lidarr/fixtures/lidarr_test.json new file mode 100644 index 0000000000..470c237391 --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_test.json @@ -0,0 +1,16 @@ +{ + "albums": [ + { + "id": 123, + "title": "Test title", + "qualityVersion": 0 + } + ], + "eventType": "Test", + "artist": { + "id": 1, + "name": "Test Name", + "path": "C:\\testpath", + "mbId": "aaaaa-aaa-aaaa-aaaaaa" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported.json new file mode 100644 index 0000000000..0d24ea9b6b --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported.json @@ -0,0 +1,154 @@ +{ + "tracks": [ + { + "id": 41, + "title": "Cherry Oh Baby", + "trackNumber": "A1", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 42, + "title": "Keep On Moving", + "trackNumber": "A2", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 43, + "title": "Please Don't Make Me Cry", + "trackNumber": "A3", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 44, + "title": "Sweet Sensation", + "trackNumber": "A4", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 45, + "title": "Johnny Too Bad", + "trackNumber": "A5", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 46, + "title": "Red Red Wine", + "trackNumber": "B1", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 47, + "title": "Guilty", + "trackNumber": "B2", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 48, + "title": "She Caught the Train", + "trackNumber": "B3", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 49, + "title": "Version Girl", + "trackNumber": "B4", + "quality": "MP3-320", + "qualityVersion": 1 + }, + { + "id": 50, + "title": "Many Rivers to Cross", + "trackNumber": "B5", + "quality": "MP3-320", + "qualityVersion": 1 + } + ], + "trackFiles": [ + { + "id": 1, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 01 - Cherry Oh Baby.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 2, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 02 - Keep On Moving.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 3, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 03 - Please Don't Make Me Cry.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 4, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 04 - Sweet Sensation.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 5, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 05 - Johnny Too Bad.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 6, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 06 - Red Red Wine.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 7, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 07 - Guilty.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 8, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 08 - She Caught the Train.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 9, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 09 - Version Girl.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + }, + { + "id": 10, + "path": "/home36/adbtech/media/Music/UB40/Labour of Love (1983)/UB40 - Labour of Love - 10 - Many Rivers to Cross.mp3", + "quality": "MP3-320", + "qualityVersion": 1, + "sceneName": "UB40 - Labour Of Love - [1983] - [320]" + } + ], + "isUpgrade": false, + "eventType": "Download", + "artist": { + "id": 1, + "name": "UB40", + "path": "/home36/adbtech/media/Music/UB40", + "mbId": "7113aab7-628f-4050-ae49-dbecac110ca8" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_over_limit.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_over_limit.json new file mode 100644 index 0000000000..86e94dd8e4 --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_over_limit.json @@ -0,0 +1,494 @@ +{ + "tracks": [ + { + "id": 5257, + "title": "Scream", + "trackNumber": "1", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5242, + "title": "Billie Jean", + "trackNumber": "1", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5243, + "title": "The Way You Make Me Feel", + "trackNumber": "2", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5258, + "title": "They Don’t Care About Us", + "trackNumber": "2", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5259, + "title": "Stranger in Moscow", + "trackNumber": "3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5244, + "title": "Black or White", + "trackNumber": "3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5260, + "title": "This Time Around", + "trackNumber": "4", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5245, + "title": "Rock With You", + "trackNumber": "4", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5261, + "title": "Earth Song", + "trackNumber": "5", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5246, + "title": "She’s Out of My Life", + "trackNumber": "5", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5262, + "title": "D.S.", + "trackNumber": "6", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5247, + "title": "Bad", + "trackNumber": "6", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5263, + "title": "Money", + "trackNumber": "7", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5248, + "title": "I Just Can’t Stop Loving You", + "trackNumber": "7", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5249, + "title": "Man in the Mirror", + "trackNumber": "8", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5264, + "title": "Come Together", + "trackNumber": "8", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5250, + "title": "Thriller", + "trackNumber": "9", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5265, + "title": "You Are Not Alone", + "trackNumber": "9", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5251, + "title": "Beat It", + "trackNumber": "10", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5266, + "title": "Childhood (theme from “Free Willy 2”)", + "trackNumber": "10", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5267, + "title": "Tabloid Junkie", + "trackNumber": "11", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5252, + "title": "The Girl Is Mine", + "trackNumber": "11", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5268, + "title": "2 Bad", + "trackNumber": "12", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5253, + "title": "Remember the Time", + "trackNumber": "12", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5254, + "title": "Don’t Stop ’til You Get Enough", + "trackNumber": "13", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5269, + "title": "HIStory", + "trackNumber": "13", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5255, + "title": "Wanna Be Startin’ Somethin’", + "trackNumber": "14", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5270, + "title": "Little Susie", + "trackNumber": "14", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5256, + "title": "Heal the World", + "trackNumber": "15", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5271, + "title": "Smile", + "trackNumber": "15", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + } + ], + "trackFiles": [ + { + "id": 103, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 01 - Scream.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 104, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 01 - Billie Jean.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 105, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 02 - The Way You Make Me Feel.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 106, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 02 - They Don’t Care About Us.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 107, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 03 - Stranger in Moscow.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 108, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 03 - Black or White.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 109, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 04 - This Time Around.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 110, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 04 - Rock With You.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 111, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 05 - Earth Song.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 112, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 05 - She’s Out of My Life.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 113, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 06 - D.S.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 114, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 06 - Bad.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 115, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 07 - Money.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 116, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 07 - I Just Can’t Stop Loving You.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 117, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 08 - Man in the Mirror.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 118, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 08 - Come Together.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 119, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 09 - Thriller.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 120, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 09 - You Are Not Alone.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 121, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 10 - Beat It.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 122, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 10 - Childhood (theme from “Free Willy 2”).mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 123, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 11 - Tabloid Junkie.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 124, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 11 - The Girl Is Mine.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 125, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 12 - 2 Bad.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 126, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 12 - Remember the Time.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 127, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 13 - Don’t Stop ’til You Get Enough.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 128, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 13 - HIStory.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 129, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 14 - Wanna Be Startin’ Somethin’.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 130, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 14 - Little Susie.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 131, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 15 - Heal the World.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 132, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 15 - Smile.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + } + ], + "isUpgrade": false, + "eventType": "Download", + "artist": { + "id": 4, + "name": "Michael Jackson", + "path": "/home36/adbtech/media/Music/Michael Jackson", + "mbId": "f27ec8db-af05-4f36-916e-3d57f91ecf5e" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade.json new file mode 100644 index 0000000000..8cb8ea58e8 --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade.json @@ -0,0 +1,302 @@ +{ + "tracks": [ + { + "id": 3187, + "title": "The National Manthem", + "trackNumber": "1", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3188, + "title": "Woman Like Me", + "trackNumber": "2", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3189, + "title": "Think About Us", + "trackNumber": "3", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3190, + "title": "Strip", + "trackNumber": "4", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3191, + "title": "Monster in Me", + "trackNumber": "5", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3192, + "title": "Joan of Arc", + "trackNumber": "6", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3193, + "title": "Love a Girl Right", + "trackNumber": "7", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3194, + "title": "American Boy", + "trackNumber": "8", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3195, + "title": "Told You So", + "trackNumber": "9", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3196, + "title": "Wasabi", + "trackNumber": "10", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3197, + "title": "More Than Words", + "trackNumber": "11", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3198, + "title": "Motivate", + "trackNumber": "12", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3199, + "title": "Notice", + "trackNumber": "13", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3200, + "title": "The Cure", + "trackNumber": "14", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3201, + "title": "Forget You Not", + "trackNumber": "15", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3202, + "title": "Woman’s World", + "trackNumber": "16", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3203, + "title": "The Cure (stripped)", + "trackNumber": "17", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + }, + { + "id": 3204, + "title": "Only You", + "trackNumber": "18", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT" + } + ], + "trackFiles": [ + { + "id": 40, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 01 - The National Manthem.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 41, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 02 - Woman Like Me.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 42, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 03 - Think About Us.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 43, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 04 - Strip.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 44, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 05 - Monster in Me.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 45, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 06 - Joan of Arc.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 46, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 07 - Love a Girl Right.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 47, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 08 - American Boy.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 48, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 09 - Told You So.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 49, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 10 - Wasabi.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 50, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 11 - More Than Words.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 51, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 12 - Motivate.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 52, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 13 - Notice.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 53, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 14 - The Cure.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 54, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 15 - Forget You Not.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 55, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 16 - Woman’s World.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 56, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 17 - The Cure (stripped).flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + }, + { + "id": 57, + "path": "/home36/adbtech/media/Music/Little Mix/LM5 (2018)/Little Mix - LM5 - 18 - Only You.flac", + "quality": "FLAC", + "qualityVersion": 1, + "releaseGroup": "PERFECT", + "sceneName": "Little_Mix-LM5-Deluxe_Edition-CD-FLAC-2018-PERFECT" + } + ], + "isUpgrade": true, + "eventType": "Download", + "artist": { + "id": 3, + "name": "Little Mix", + "path": "/home36/adbtech/media/Music/Little Mix", + "mbId": "38f59974-2f4d-4bfa-b2e3-d2696de1b675" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade_over_limit.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade_over_limit.json new file mode 100644 index 0000000000..4affb6da7c --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_imported_upgrade_over_limit.json @@ -0,0 +1,494 @@ +{ + "tracks": [ + { + "id": 5257, + "title": "Scream", + "trackNumber": "1", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5242, + "title": "Billie Jean", + "trackNumber": "1", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5243, + "title": "The Way You Make Me Feel", + "trackNumber": "2", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5258, + "title": "They Don’t Care About Us", + "trackNumber": "2", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5259, + "title": "Stranger in Moscow", + "trackNumber": "3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5244, + "title": "Black or White", + "trackNumber": "3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5260, + "title": "This Time Around", + "trackNumber": "4", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5245, + "title": "Rock With You", + "trackNumber": "4", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5261, + "title": "Earth Song", + "trackNumber": "5", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5246, + "title": "She’s Out of My Life", + "trackNumber": "5", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5262, + "title": "D.S.", + "trackNumber": "6", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5247, + "title": "Bad", + "trackNumber": "6", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5263, + "title": "Money", + "trackNumber": "7", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5248, + "title": "I Just Can’t Stop Loving You", + "trackNumber": "7", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5249, + "title": "Man in the Mirror", + "trackNumber": "8", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5264, + "title": "Come Together", + "trackNumber": "8", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5250, + "title": "Thriller", + "trackNumber": "9", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5265, + "title": "You Are Not Alone", + "trackNumber": "9", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5251, + "title": "Beat It", + "trackNumber": "10", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5266, + "title": "Childhood (theme from “Free Willy 2”)", + "trackNumber": "10", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5267, + "title": "Tabloid Junkie", + "trackNumber": "11", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5252, + "title": "The Girl Is Mine", + "trackNumber": "11", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5268, + "title": "2 Bad", + "trackNumber": "12", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5253, + "title": "Remember the Time", + "trackNumber": "12", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5254, + "title": "Don’t Stop ’til You Get Enough", + "trackNumber": "13", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5269, + "title": "HIStory", + "trackNumber": "13", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5255, + "title": "Wanna Be Startin’ Somethin’", + "trackNumber": "14", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5270, + "title": "Little Susie", + "trackNumber": "14", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5256, + "title": "Heal the World", + "trackNumber": "15", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + }, + { + "id": 5271, + "title": "Smile", + "trackNumber": "15", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely" + } + ], + "trackFiles": [ + { + "id": 103, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 01 - Scream.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 104, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 01 - Billie Jean.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 105, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 02 - The Way You Make Me Feel.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 106, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 02 - They Don’t Care About Us.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 107, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 03 - Stranger in Moscow.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 108, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 03 - Black or White.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 109, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 04 - This Time Around.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 110, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 04 - Rock With You.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 111, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 05 - Earth Song.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 112, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 05 - She’s Out of My Life.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 113, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 06 - D.S.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 114, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 06 - Bad.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 115, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 07 - Money.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 116, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 07 - I Just Can’t Stop Loving You.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 117, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 08 - Man in the Mirror.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 118, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 08 - Come Together.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 119, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 09 - Thriller.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 120, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 09 - You Are Not Alone.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 121, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 10 - Beat It.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 122, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 10 - Childhood (theme from “Free Willy 2”).mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 123, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 11 - Tabloid Junkie.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 124, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 11 - The Girl Is Mine.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 125, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 12 - 2 Bad.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 126, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 12 - Remember the Time.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 127, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 13 - Don’t Stop ’til You Get Enough.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 128, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 13 - HIStory.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 129, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 14 - Wanna Be Startin’ Somethin’.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 130, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 14 - Little Susie.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 131, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 01/Michael Jackson - HIStory- Past, Present and Future, Book I - 15 - Heal the World.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + }, + { + "id": 132, + "path": "/home36/adbtech/media/Music/Michael Jackson/HIStory- Past, Present and Future, Book I (1995)/CD 02/Michael Jackson - HIStory- Past, Present and Future, Book I - 15 - Smile.mp3", + "quality": "MP3-VBR-V0", + "qualityVersion": 1, + "releaseGroup": "Homely", + "sceneName": "Michael_Jackson_-_History_(Past_Present_And_Future_Book_I)-2CD-1995-Homely_INT" + } + ], + "isUpgrade": true, + "eventType": "Download", + "artist": { + "id": 4, + "name": "Michael Jackson", + "path": "/home36/adbtech/media/Music/Michael Jackson", + "mbId": "f27ec8db-af05-4f36-916e-3d57f91ecf5e" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_renamed.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_renamed.json new file mode 100644 index 0000000000..04b7c742fd --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_renamed.json @@ -0,0 +1,9 @@ +{ + "eventType": "Rename", + "artist": { + "id": 3, + "name": "Little Mix", + "path": "/home36/adbtech/media/Music/Little Mix", + "mbId": "38f59974-2f4d-4bfa-b2e3-d2696de1b675" + } +} diff --git a/zerver/webhooks/lidarr/fixtures/lidarr_tracks_retagged.json b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_retagged.json new file mode 100644 index 0000000000..8d0dc10c5d --- /dev/null +++ b/zerver/webhooks/lidarr/fixtures/lidarr_tracks_retagged.json @@ -0,0 +1,9 @@ +{ + "eventType": "Retag", + "artist": { + "id": 3, + "name": "Little Mix", + "path": "/home36/adbtech/media/Music/Little Mix", + "mbId": "38f59974-2f4d-4bfa-b2e3-d2696de1b675" + } +} diff --git a/zerver/webhooks/lidarr/tests.py b/zerver/webhooks/lidarr/tests.py new file mode 100644 index 0000000000..3044ad9a85 --- /dev/null +++ b/zerver/webhooks/lidarr/tests.py @@ -0,0 +1,151 @@ +from zerver.lib.test_classes import WebhookTestCase + + +class LidarrHookTests(WebhookTestCase): + STREAM_NAME = "lidarr" + URL_TEMPLATE = "/api/v1/external/lidarr?api_key={api_key}&stream={stream}" + FIXTURE_DIR_NAME = "lidarr" + + def test_lidarr_test(self) -> None: + """ + Tests if lidarr test payload is handled correctly + """ + expected_topic = "Lidarr - Test" + expected_message = "Lidarr webhook has been successfully configured." + self.check_webhook("lidarr_test", expected_topic, expected_message) + + def test_lidarr_tracks_renamed(self) -> None: + """ + Tests if lidarr tracks renamed payload is handled correctly + """ + expected_topic = "Little Mix" + expected_message = "The artist Little Mix has had its tracks renamed." + self.check_webhook("lidarr_tracks_renamed", expected_topic, expected_message) + + def test_lidarr_tracks_retagged(self) -> None: + """ + Tests if lidarr tracks retagged payload is handled correctly + """ + expected_topic = "Little Mix" + expected_message = "The artist Little Mix has had its tracks retagged." + self.check_webhook("lidarr_tracks_retagged", expected_topic, expected_message) + + def test_lidarr_tracks_imported(self) -> None: + """ + Tests if lidarr tracks imported payload is handled correctly + """ + expected_topic = "UB40" + expected_message = """ +The following tracks by UB40 have been imported: +* Cherry Oh Baby +* Keep On Moving +* Please Don't Make Me Cry +* Sweet Sensation +* Johnny Too Bad +* Red Red Wine +* Guilty +* She Caught the Train +* Version Girl +* Many Rivers to Cross +""".strip() + self.check_webhook("lidarr_tracks_imported", expected_topic, expected_message) + + def test_lidarr_tracks_imported_upgrade(self) -> None: + """ + Tests if lidarr tracks imported upgrade payload is handled correctly + """ + expected_topic = "Little Mix" + expected_message = """ +The following tracks by Little Mix have been imported due to upgrade: +* The National Manthem +* Woman Like Me +* Think About Us +* Strip +* Monster in Me +* Joan of Arc +* Love a Girl Right +* American Boy +* Told You So +* Wasabi +* More Than Words +* Motivate +* Notice +* The Cure +* Forget You Not +* Woman’s World +* The Cure (stripped) +* Only You +""".strip() + self.check_webhook("lidarr_tracks_imported_upgrade", expected_topic, expected_message) + + def test_lidarr_album_grabbed(self) -> None: + """ + Tests if lidarr album grabbed payload is handled correctly + """ + expected_topic = "UB40" + expected_message = "The album Labour of Love by UB40 has been grabbed." + self.check_webhook("lidarr_album_grabbed", expected_topic, expected_message) + + def test_lidarr_tracks_imported_over_limit(self) -> None: + """ + Tests if lidarr tracks imported over limit payload is handled correctly + """ + expected_topic = "Michael Jackson" + expected_message = """ +The following tracks by Michael Jackson have been imported: +* Scream +* Billie Jean +* The Way You Make Me Feel +* They Don’t Care About Us +* Stranger in Moscow +* Black or White +* This Time Around +* Rock With You +* Earth Song +* She’s Out of My Life +* D.S. +* Bad +* Money +* I Just Can’t Stop Loving You +* Man in the Mirror +* Come Together +* Thriller +* You Are Not Alone +* Beat It +* Childhood (theme from “Free Willy 2”) +[and 10 more tracks(s)] +""".strip() + self.check_webhook("lidarr_tracks_imported_over_limit", expected_topic, expected_message) + + def test_lidarr_tracks_imported_upgrade_over_limit(self) -> None: + """ + Tests if lidarr tracks imported upgrade over limit payload is handled correctly + """ + expected_topic = "Michael Jackson" + expected_message = """ +The following tracks by Michael Jackson have been imported due to upgrade: +* Scream +* Billie Jean +* The Way You Make Me Feel +* They Don’t Care About Us +* Stranger in Moscow +* Black or White +* This Time Around +* Rock With You +* Earth Song +* She’s Out of My Life +* D.S. +* Bad +* Money +* I Just Can’t Stop Loving You +* Man in the Mirror +* Come Together +* Thriller +* You Are Not Alone +* Beat It +* Childhood (theme from “Free Willy 2”) +[and 10 more tracks(s)] +""".strip() + self.check_webhook( + "lidarr_tracks_imported_upgrade_over_limit", expected_topic, expected_message + ) diff --git a/zerver/webhooks/lidarr/view.py b/zerver/webhooks/lidarr/view.py new file mode 100644 index 0000000000..16b0dc0b1b --- /dev/null +++ b/zerver/webhooks/lidarr/view.py @@ -0,0 +1,130 @@ +from typing import Any, Dict, List + +from django.http import HttpRequest, HttpResponse + +from zerver.decorator import REQ, has_request_variables, webhook_view +from zerver.lib.exceptions import UnsupportedWebhookEventType +from zerver.lib.response import json_success +from zerver.lib.webhooks.common import check_send_webhook_message, get_setup_webhook_message +from zerver.models import UserProfile + +LIDARR_TOPIC_TEMPLATE = "{artist_name}".strip() +LIDARR_TOPIC_TEMPLATE_TEST = "Lidarr - Test".strip() + +LIDARR_MESSAGE_TEMPLATE_TRACKS_RENAMED = ( + "The artist {artist_name} has had its tracks renamed.".strip() +) +LIDARR_MESSAGE_TEMPLATE_TRACKS_RETAGGED = ( + "The artist {artist_name} has had its tracks retagged.".strip() +) +LIDARR_MESSAGE_TEMPLATE_ALBUM_GRABBED = ( + "The album {album_name} by {artist_name} has been grabbed.".strip() +) + +LIDARR_MESSAGE_TEMPLATE_TRACKS_IMPORTED = """ +The following tracks by {artist_name} have been imported: +{tracks_final_data} +""".strip() + +LIDARR_MESSAGE_TEMPLATE_TRACKS_IMPORTED_UPGRADE = """ +The following tracks by {artist_name} have been imported due to upgrade: +{tracks_final_data} +""".strip() + +LIDARR_TRACKS_ROW_TEMPLATE = "* {track_title}\n" +LIDARR_TRACKS_OTHERS_ROW_TEMPLATE = "[and {tracks_number} more tracks(s)]" +LIDARR_TRACKS_LIMIT = 20 + + +def get_tracks_content(tracks_data: List[Dict[str, Any]]) -> str: + tracks_content = "" + for track in tracks_data[:LIDARR_TRACKS_LIMIT]: + tracks_content += LIDARR_TRACKS_ROW_TEMPLATE.format(track_title=track.get("title")) + + if len(tracks_data) > LIDARR_TRACKS_LIMIT: + tracks_content += LIDARR_TRACKS_OTHERS_ROW_TEMPLATE.format( + tracks_number=len(tracks_data) - LIDARR_TRACKS_LIMIT, + ) + + return tracks_content.rstrip() + + +@webhook_view("Lidarr") +@has_request_variables +def api_lidarr_webhook( + request: HttpRequest, + user_profile: UserProfile, + payload: Dict[str, Any] = REQ(argument_type="body"), +) -> HttpResponse: + body = get_body_for_http_request(payload) + subject = get_subject_for_http_request(payload) + + check_send_webhook_message(request, user_profile, subject, body) + return json_success() + + +def get_subject_for_http_request(payload: Dict[str, Any]) -> str: + if payload["eventType"] == "Test": + topic = LIDARR_TOPIC_TEMPLATE_TEST + else: + topic = LIDARR_TOPIC_TEMPLATE.format(artist_name=payload["artist"]["name"]) + + return topic + + +def get_body_for_album_grabbed_event(payload: Dict[str, Any]) -> str: + return LIDARR_MESSAGE_TEMPLATE_ALBUM_GRABBED.format( + artist_name=payload["artist"]["name"], album_name=payload["albums"][0]["title"] + ) + + +def get_body_for_tracks_renamed_event(payload: Dict[str, Any]) -> str: + return LIDARR_MESSAGE_TEMPLATE_TRACKS_RENAMED.format(artist_name=payload["artist"]["name"]) + + +def get_body_for_tracks_retagged_event(payload: Dict[str, Any]) -> str: + return LIDARR_MESSAGE_TEMPLATE_TRACKS_RETAGGED.format(artist_name=payload["artist"]["name"]) + + +def get_body_for_tracks_imported_upgrade_event(payload: Dict[str, Any]) -> str: + tracks_data = [] + for track in payload["tracks"]: + tracks_data.append({"title": track["title"]}) + + data = { + "artist_name": payload["artist"]["name"], + "tracks_final_data": get_tracks_content(tracks_data), + } + + return LIDARR_MESSAGE_TEMPLATE_TRACKS_IMPORTED_UPGRADE.format(**data) + + +def get_body_for_tracks_imported_event(payload: Dict[str, Any]) -> str: + tracks_data = [] + for track in payload["tracks"]: + tracks_data.append({"title": track["title"]}) + + data = { + "artist_name": payload["artist"]["name"], + "tracks_final_data": get_tracks_content(tracks_data), + } + + return LIDARR_MESSAGE_TEMPLATE_TRACKS_IMPORTED.format(**data) + + +def get_body_for_http_request(payload: Dict[str, Any]) -> str: + if payload["eventType"] == "Test": + return get_setup_webhook_message("Lidarr") + elif payload["eventType"] == "Grab": + return get_body_for_album_grabbed_event(payload) + elif payload["eventType"] == "Rename": + return get_body_for_tracks_renamed_event(payload) + elif payload["eventType"] == "Retag": + return get_body_for_tracks_retagged_event(payload) + elif payload["eventType"] == "Download" and "isUpgrade" in payload: + if payload["isUpgrade"]: + return get_body_for_tracks_imported_upgrade_event(payload) + else: + return get_body_for_tracks_imported_event(payload) + else: + raise UnsupportedWebhookEventType(payload["eventType"])