Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Incompatibility with the new Plex Movie agent #159

Open
agneevX opened this issue Oct 31, 2020 · 25 comments
Open

Incompatibility with the new Plex Movie agent #159

agneevX opened this issue Oct 31, 2020 · 25 comments

Comments

@agneevX
Copy link

agneevX commented Oct 31, 2020

EDIT 2: With Plex Media Server v1.21.1.3759, the metadata issue for movies with the new agent have been fixed, and I've disabled Fix Mismatched.


EDIT: If Fix Mismatched is enabled, plex_autoscan will attempt to match the movie with the legacy agent, but the new agent (Plex Movie) will ignore it, so this is the best option as of now.

Fixing match of 'Baby Driver' (plex://movie/5d776ba0ad5437001f7a5376) to 'Baby Driver' (com.plexapp.agents.imdb://tt3890160?lang=en).
Successfully matched 'metadata_item_id' '22669' to 'Baby Driver' (com.plexapp.agents.imdb://tt3890160?lang=en).

When adding movies to a library with the new Plex Movie agent, the movie isn't added properly, with Fix Mismatched disabled.

Part of config.json:

"PLEX_FIX_MISMATCHED": false,
"PLEX_ANALYZE_TYPE": "basic",
"PLEX_CHECK_BEFORE_SCAN": false

As you can see, there's missing info and no cast info is downloaded.

Screen Shot 2020-10-31 at 8 19 40 PM

(The metadata-fetching visible is because I hit Refresh Metadata)

@bad1dea
Copy link

bad1dea commented Nov 7, 2020

Can you post your log from plex_autoscan?

I have fix mismatched options enabled, and have no issues with the scanner. Only thing is, it changes the poster data, but everything else will populate.

If Plex is set up properly with the new movie agent, Plex Autoscan will tell Plex to scan using it, and once it's completed, it will change the guid to one of the legacy ones.. doesn't effect what you are describing.

I had a similar issue to what you did, and it ended up being a permission issue. Can you validate your PLEX User (either for docker or sudo).. that fixed issue for me after months of wondering what was going on.

I ended up scripting something to fix 16000 entries in movies the past 2 weeks.

 2020-11-07 02:28:25,354 -     INFO -      PLEX [139713792956160]: Finished basic analysis of 'metadata_item': 207294

 2020-11-07 02:28:35,375 -     INFO -      PLEX [139713792956160]: No duplicate 'media_items' found with 'metadata_item_id': '207294'

 2020-11-07 02:28:35,375 -     INFO -      PLEX [139713792956160]: Fixing match of 'Better Luck Tomorrow' (plex://movie/5d9f351268e4c8001fb5e46b) to 'Better Luck Tomorrow' (com.plexapp.agents.imdb://tt0280477?lang=en).

 2020-11-07 02:28:35,989 -     INFO -      PLEX [139713792956160]: Successfully matched 'metadata_item_id' '207294' to 'Better Luck Tomorrow' (com.plexapp.agents.imdb://tt0280477?lang=en).

 2020-11-07 02:28:35,995 -     INFO -      PLEX [139713792956160]: Successfully refreshed 'metadata_item_id' '207294' of 'Better Luck Tomorrow'.

001

@agneevX
Copy link
Author

agneevX commented Nov 7, 2020

@bad1dea

My logs are very similar to yours.

If Plex is set up properly with the new movie agent, Plex Autoscan will tell Plex to scan using it, and once it's completed, it will change the guid to one of the legacy ones

I've re-enabled Fix Matched and checked two files. One was added by plex_autoscan, the other was added manually.
Both have plex:// in their GUID.

So, despite this line, it is not being matched to the legacy agent.

2020-11-07 02:28:35,375 - INFO - PLEX [139713792956160]: Fixing match of 'Better Luck Tomorrow' (plex://movie/5d9f351268e4c8001fb5e46b) to 'Better Luck Tomorrow' (com.plexapp.agents.imdb://tt0280477?lang=en).

Can you validate your PLEX User (either for docker or sudo).. that fixed issue for me after months of wondering what was going on.

Plex runs under its own user, so I have sudo enabled in the config file.

Technically speaking, turning off Fix Mismatched should let Plex automatically scan with the new agent, but I suspect that the scanning or the scan command is not the same as the legacy agent.

@bad1dea
Copy link

bad1dea commented Nov 9, 2020

Hard to go further without seeing your Plex Log with Debug enabled (not verbose) while scanning an item.

If you can run the following and fill in xyz

curl -s -X PUT -i 'http://XXXXXXXXXX:32400/library/metadata/YYYYYYYYYYY/refresh?X-Plex-Token=ZZZZZZZZZZZ'

X = hostname/fqdn to plex server
Y = metadata id (example 207294 for my log from previous post)
Z = Plex Token (can use the same on Plex Autoscan) is using.

^ if the above command works and fixes the metadata, then there is something rogue going on with Plex_Autoscan, most likely permission issue.

I agree the movie agent should be added, I even took a look at adding it myself, unfortunately unless Plex gives us some rhyme or reason to the plex://movie/HASH it's hard to validate it from Plex Autoscan.

They did add XML tags/db entries with the TMDB_ID and IMDB_ID for other 3rd party tools (which Iuse to correct legitimate errors with metadata)

<Guid id="imdb://tt5981656"/>
<Guid id="tmdb://494750"/>

Which I guess, we could generate/validate against instead of forcing a com.plexapp.agents.XXXX://ID

@bad1dea
Copy link

bad1dea commented Nov 10, 2020

If you want to keep fix mismatch on for TV show for now.. you can edit

Line 333 of plex.py to the following

from
    if parent_guid and (parent_guid.lower() != new_guid):
to
    if parent_guid and (parent_guid.lower() != new_guid) and ("plex://movie/" not in parent_guid.lower()):

It'll just skip it for the movies (anything with plex://movie/)

I'm working on adding another function to grab the id's from the tags, and validate it that way, since we don't know how the new plex movie agent generates it's guid hash.

Considering there is a new TV Plex Agent coming out, we'll run into this issue for TV Series soon too.

If you want to help test, let me know.

@agneevX
Copy link
Author

agneevX commented Nov 11, 2020

I don't understand why Fix Mismatched has to be enabled in the first place.

If a scan request is sent to Plex for the particular file (which has a proper name structure), it should add the file to the library without any issue.

That scan request is not updated for the new agent.

@bad1dea
Copy link

bad1dea commented Nov 11, 2020

The reason for the option is for a few reasons.

  1. Plex movie scanning is based off of TITLE, YEAR
  2. Plex tv scanning is based off of the general notations, SXXEXX, 2020-XX-XX, or whatever.

Sometimes, the scanner mostly movies, ends up finding dupes, or sometimes the database has wrong years for movies (production, vs released, etc etc)

When Sonarr/Radarr are set up to connect to Plex Autoscan, it tells PLEX to scan, but also provides Plex_autoscan with additional information.

Mainly the IMDB/TMDB ID's for the Episode/Show/Movie, and all it tries to do is make sure the ID is found for that Item once it's been added, it's just to make sure Plex finds what Sonarr/Radarr found. If it doesn't match, it forces Plex to use the ID's supplied by Radarr/Sonarr.

Plex scanner is a hit or miss, it'll work 99% of the time, and then stop for some odd qwirk, its really messed up.

 2020-11-09 08:37:40,411 -    DEBUG -  AUTOSCAN [140078605133568]: Client '10.10.10.9' request dump:
{
    "downloadId": "d7140a5ad334476b802e3b7ba144d753",
    "eventType": "Download",
    "isUpgrade": false,
    "movie": {
        "folderPath": "/movies/For Better or For Worse (2014)",
        "id": 15728,
        "imdbId": "tt3579488",
        "releaseDate": "9999-12-31",
        "title": "For Better or For Worse",
        "tmdbId": 284166
    },
    "movieFile": {
        "id": 88922,
        "path": "/downloads/completed/movies/For.Better.or.For.Worse.2014.1080p.AMZN.WEB-DL.DDP5.1.H.264-DONNA/e457cdb6841d3bbe76bb750fd565bd05.mkv",
        "quality": "WEBDL-1080p",
        "qualityVersion": 1,
        "relativePath": "For Better or For Worse (2014) WEBDL-1080p.mkv",
        "releaseGroup": "DONNA",
        "sceneName": "For.Better.or.For.Worse.2014.1080p.AMZN.WEB-DL.DDP5.1.H.264-DONNA",
        "size": 6366636601
    },
    "remoteMovie": {
        "imdbId": "tt3579488",
        "title": "For Better or For Worse",
        "tmdbId": 284166,
        "year": 2014
    }
}

@asw13537
Copy link

I have the same issue where metadata is not pulling down until i manually refresh. I have the mismatch disabled however my movies are formatted into movie (year) {imdb-tt123456}.mkv format. Plex should pick up on the imdb reference.
Running plex in docker, I don't see any permission issues. Data can be manually refreshed fine.

@agneevX
Copy link
Author

agneevX commented Nov 12, 2020

That's because the scan request for the new agent isn't the same as for the old agent.

I made a rough script for Radarr auto scanning here: https://gist.github.com/agneevX/a865bc1821a1c6e5ca4a80fab5d2316a

@asw13537
Copy link

i tried the script, it just does a scan, doesn't pull the metadata.

Running this refreshed the item and pulled the missing data down. Have tried redeploying plexautoscan but still same issue.

curl -s -X PUT -i 'http://XXXXXXXXXX:32400/library/metadata/YYYYYYYYYYY/refresh?X-Plex-Token=ZZZZZZZZZZZ'

X = hostname/fqdn to plex server
Y = metadata id (example 207294 for my log from previous post)
Z = Plex Token (can use the same on Plex Autoscan) is using.

@bad1dea
Copy link

bad1dea commented Nov 12, 2020 via email

@asw13537
Copy link

cheers buddy.

@bad1dea
Copy link

bad1dea commented Nov 12, 2020

@bad1dea
Copy link

bad1dea commented Nov 12, 2020

What the script does is,

Looks through your database for any Movies (by section id) that do not have proper tagging, and forces plex to do a scan on JUST that item.

You need sqlite3, and curl installed.

@agneevX
Copy link
Author

agneevX commented Nov 13, 2020

i tried the script, it just does a scan, doesn't pull the metadata.

Are you sure? I just tried it right now and it pulled all the info for the item.

@bad1dea
Copy link

bad1dea commented Nov 13, 2020 via email

@agneevX
Copy link
Author

agneevX commented Nov 13, 2020

How often do you get mismatches? Personally, I've never encountered mismatches.

@bad1dea
Copy link

bad1dea commented Nov 13, 2020 via email

@dennisoderwald
Copy link

Here you go..

https://gist.github.com/bad1dea/406076a2c6708930bc18371f059f5845

Thank you. I took the liberty of optimizing the query, as it would have skipped some titles that did not meet the criteria. So I make sure that every file is updated.

SELECT id FROM metadata_items WHERE refreshed_at IS NULL AND media_item_count > 0 AND library_section_id IS $PLEX_MOVIE_SECTION_ID ORDER BY added_at ASC

@asw13537
Copy link

my section Id for movies is 11 , check the image, movies metadata_type in my movies is 12 or 1, so i need to amend your script I think and change the 18 to either 12 or 1..Im not sure can you advise
SELECT metadata_item_id
FROM taggings)
AND metadata_type IS NOT 18
AND library_section_id IS $PLEX_MOVIE_SECTION_ID
ORDER BY title ASC;"

https://ibb.co/rF8SNtL

@bad1dea
Copy link

bad1dea commented Nov 13, 2020

Leave 18 alone -that is Metadata TYPE.. not section id.. change the variable.. not any of the numbers..

18 = Collections, not Movies.

PLEX_MOVIE_SECTION_ID=11

@bad1dea
Copy link

bad1dea commented Nov 13, 2020

Only edit the below, you can replace the QUERY with the one supplied by dennis if that suites you better.

PLEX_DATABASE_PATH="Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" # Full path to PLEX DB
PLEX_TOKEN="xxx" # Plex Token -- Can use PLEX_AUTOSCAN Token
PLEX_URL="http://127.0.0.1:32400" # URL to PLEX Server (must be reachable)
PLEX_MOVIE_SECTION_ID="1" # Set this to SECTION ID of Movies

@asw13537
Copy link

asw13537 commented Nov 13, 2020

thanks for your help but when i run it with your config. Nothing actually scans or refreshes. I don't see anything happening with it. SQL connects, runs and finishes but i see nothing happening in plex. Checking alerts and console.

I am running the script on the same host. Reverse proxy. The web url is reacable
plex.domain.com:443
My section id is right 11.

I know when i run the curl on its own, works when i fill in details manually. Any thoughts?

Not sure if this holds any relevance, but the metadata that is missing rating, cast ect, it does pull down some like synopsis. Would this have an impact on the script filtering for missing data?

@asw13537
Copy link

asw13537 commented Nov 14, 2020

I have your script now working, however it will only refresh the metadata for one movie, normally the last movie that has has been added. It's not picking up on the other movies that require metadata.

Ameded the script to also look for audience_rating is NULL this picks up on the movies that it is not refreshing the metadata for. Granted not ideal as a couple of movies that i have which dont have a rating but works fine.

@agneevX agneevX changed the title Add support for new Plex Movie agent Incompatibility with the new Plex Movie agent Dec 7, 2020
@Horribleness
Copy link

Horribleness commented Dec 9, 2020

Plex_Autoscan is working well with the latest changes to PMS 1.21.1.3759 (changelog):

  • (Scanner) New movies would have incomplete metadata if the scan was invoked from the command line (#12156)

@agneevX
Copy link
Author

agneevX commented Dec 10, 2020

This would explain the behavior when Fix Mismatched is disabled.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants