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
397 stars 70 forks source link

File paths received with incorrect slashes #148

Closed TehRobot closed 4 years ago

TehRobot commented 4 years ago

Describe the bug When I use autoscan with sonarr I have file path issues, when it tells plex to look for file. Puts a forward slash in between season and episode. eg Drive:\TV Shows\Show\Season 1/episode.mkv

When Windows is wanting a backslash.

I suspect this is due to Sonarr passing the full path /media/TV Shows/show/season 1/episode.mkv while the remote path mappings stop after tv shows so converting "/media/TV Shows/" to "\10.1.2.115\Media\TV Shows\"

When it sends a scan request for a season folder there is no issue adding the files only when the analyize request is sent.

To Reproduce Details for my setup Media is on unRaid array Sonarr is setup as a docker in unRaid Plex and Autoscan are running on a seperate windows machine

I assume this can be easily replicated by running Plex on Windows with media and Sonarr on any linux based system.

Expected behavior

Logs

 2020-04-30 23:07:23,243 -    DEBUG -  AUTOSCAN [14980]: Client '10.1.1.115' request dump:
{
    "episodeFile": {
        "id": 159758,
        "path": "/media/Downloads/Completed/Medici S02 web hevc-d3g/Medici.S02E01.Old.Scores.WEBRip.1080p.DD5.1.H265-d3g.mkv",
        "quality": "WEBRip-1080p",
        "qualityVersion": 1,
        "relativePath": "Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv",
        "releaseGroup": "d3g",
        "sceneName": "Medici.S02E01.Old.Scores.WEBRip.1080p.DD5.1.H265-d3g"
    },
    "episodes": [
        {
            "airDate": "2018-10-23",
            "airDateUtc": "2018-10-23T19:30:00Z",
            "episodeNumber": 1,
            "id": 58982,
            "quality": "WEBRip-1080p",
            "qualityVersion": 1,
            "releaseGroup": "d3g",
            "sceneName": "Medici.S02E01.Old.Scores.WEBRip.1080p.DD5.1.H265-d3g",
            "seasonNumber": 2,
            "title": "Old Scores"
        }
    ],
    "eventType": "Download",
    "isUpgrade": true,
    "series": {
        "id": 539,
        "imdbId": "tt5057130",
        "path": "/media/TV Shows/Medici (2016)",
        "title": "Medici",
        "tvMazeId": 18999,
        "tvdbId": 313024,
        "type": "standard"
    }
}
 2020-04-30 23:07:23,243 -     INFO -  AUTOSCAN [14980]: Client '10.1.1.115' scan request for series: '/media/TV Shows/Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv', event: 'Upgrade'
 2020-04-30 23:07:23,243 -    DEBUG -     UTILS [14980]: Mapping server path '/media/TV Shows/' to '\\10.1.2.115\Media\TV Shows\'.
 2020-04-30 23:07:23,247 -    DEBUG -     UTILS [14980]: Checking if root folder path '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' matches Plex Library root path in the Plex DB.
 2020-04-30 23:07:23,253 -    DEBUG -     UTILS [14980]: Plex Library Section ID '4' matching root folder '\\10.1.2.115\Media\TV Shows' was found in the Plex DB.
 2020-04-30 23:07:23,255 -     INFO -  AUTOSCAN [14980]: Using Section ID '4' for '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv'
 2020-04-30 23:07:23,256 -     INFO -      PLEX [13192]: Scan request from Sonarr for '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv'.
 2020-04-30 23:07:23,256 -     INFO -      PLEX [13192]: Sleeping for 30 seconds...
 2020-04-30 23:07:53,263 -     INFO -      PLEX [13192]: File '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' exists on check 1 of 10.
 2020-04-30 23:07:53,265 -    DEBUG -     UTILS [13192]: Using default priority '0' for path '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2'
 2020-04-30 23:07:53,266 -    DEBUG -      PLEX [13192]: Waiting for turn in the scan request backlog with priority '0'...
 2020-04-30 23:10:38,561 -    DEBUG -      PLEX [13192]: Sending analysis request...
 2020-04-30 23:10:38,566 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' in 1 of 5 attempts...
 2020-04-30 23:10:48,569 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' in 2 of 5 attempts...
 2020-04-30 23:10:58,571 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' in 3 of 5 attempts...
 2020-04-30 23:11:08,572 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' in 4 of 5 attempts...
 2020-04-30 23:11:18,572 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' in 5 of 5 attempts...
 2020-04-30 23:11:28,573 -    ERROR -      PLEX [13192]: Could not locate record in 'media_parts' where 'file' = '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' after 5 tries
 2020-04-30 23:11:28,575 -  WARNING -      PLEX [13192]: Aborting analysis of '\\10.1.2.115\Media\TV Shows\Medici (2016)\Season 2/Medici.S02E01.Old.Scores.WEBRip-1080p-d3g.mkv' because could not find any 'metadata_item_id' for it.

System Information

Additional context One fix for this would be a path correction script where it looks at "relativePath" and if linux to windows conversion enabled swap / for .

the "linux to windows conversion" could be enabled in config nestled where server path mappings are.

TehRobot commented 4 years ago

This is fixed with l3uddz's update. :)