l3uddz / plex_autoscan

Script to assist sonarr/radarr with plex imports. Will only scan the folder that has been imported, instead of the whole library section.
GNU General Public License v3.0
395 stars 70 forks source link

Sonarr Rename Error #21

Closed danielloader closed 6 years ago

danielloader commented 6 years ago

Sonarr: Sonarr Ver. 2.0.0.5163 Ubuntu 16.04 Server

Ran into an error when renaming files shown below:

Apr 09 20:09:44 htpc mono[13536]: [Warn] HttpClient: HTTP Error - Res: [POST] *URLREDACTED*: 400.BadRequest
Apr 09 20:09:44 htpc mono[13536]: [Warn] NotificationService: Unable to send OnRename notification to: Plex Autoscan
Apr 09 20:09:44 htpc mono[13536]: [v2.0.0.5163] NzbDrone.Common.Http.HttpException: HTTP request failed: [400:BadRequest] [POST] at [http://plex.spicypixel.co.uk:3467/4e210bd0216d4906afda744a29a52a24]
Apr 09 20:09:44 htpc mono[13536]:   at NzbDrone.Common.Http.HttpClient.Execute (NzbDrone.Common.Http.HttpRequest request) [0x00128] in <6d548036160a49ed8e2657c617163f50>:0
Apr 09 20:09:44 htpc mono[13536]:   at NzbDrone.Core.Notifications.Webhook.WebhookProxy.SendWebhook (NzbDrone.Core.Notifications.Webhook.WebhookPayload body, NzbDrone.Core.Notifications.Webhook.WebhookSettings settings) [0x0006f] in <9b8bbe29888f49229914613e26af4aa5>:0
Apr 09 20:09:44 htpc mono[13536]:   at NzbDrone.Core.Notifications.Webhook.Webhook.OnRename (NzbDrone.Core.Tv.Series series) [0x0002a] in <9b8bbe29888f49229914613e26af4aa5>:0
Apr 09 20:09:44 htpc mono[13536]:   at NzbDrone.Core.Notifications.NotificationService.Handle (NzbDrone.Core.MediaFiles.Events.SeriesRenamedEvent message) [0x00036] in <9b8bbe29888f49229914613e26af4aa5>:0
Apr 09 20:09:44 htpc mono[13536]: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
Apr 09 20:09:44 htpc mono[13536]: <title>400 Bad Request</title>
Apr 09 20:09:44 htpc mono[13536]: <h1>Bad Request</h1>
Apr 09 20:09:44 htpc mono[13536]: <p>The browser (or proxy) sent a request that this server could not understand.</p>

Seems to only affect rename, new downloads don't suffer this.

l3uddz commented 6 years ago

The issue with this is, plex_autoscan ignores those requests/considers them unknown, reason being is there is no filename sent in the request, e.g.

{
    "eventType": "Rename",
    "series": {
        "id": 1532,
        "path": "/tv/The Durrells",
        "title": "The Durrells",
        "tvdbId": 308129
    }
}

If you can get Radarr & Sonarr to implement a relativePath field of the new file like it does for download/upgrade, then I can add support for Rename.

l3uddz commented 6 years ago

Just spoke to markus101 and he said that the Rename event is only emitted once all selected files have been renamed, aka, not an event for single file renames.

So not quite sure the best way of adding support for this.

danielloader commented 6 years ago

I suspected this might be the case, I am renaming a lot of files at once. It's spitting a lot of errors at plex_autoscan as you'd imagine, it's triggering it per file but not sending any useful data.

l3uddz commented 6 years ago

added basic support in the dev branch if you want to test it out. the caveat is that it will scan the entire series / movie folder instead of just the season folder, this is because there is no file path given, just series path. also due to that reason, no analyze request can be sent either.

l3uddz commented 6 years ago

ofcourse this probably isnt of much use with rclone cache, because the folder will be there, yet the file will be cached under old filename. until sonarr/radarr actually is able to send us the filenames, this is the best im able to do i think.

l3uddz commented 6 years ago

basic rename support is now available.

if you want lidarr suport, open a new issue with a sample from a lidarr rename webhook