ZeroQI / Lambda.bundle

Local Media Export, a reverse Plex 'Local Media Assets' agent to export metadata locally
GNU General Public License v3.0
134 stars 18 forks source link

Exporting works fine but importing does not #26

Open RomLecat opened 3 years ago

RomLecat commented 3 years ago

Hello,

I have an issue with Lambda. It exports my media metadata informations correctly, but it does not import it.

I deleted my whole library and recreated it to test it. Collections that have been made are not recreated, manually matched items are not matched. I also tried to put the 91 Days anime tvshow.nfo into the Boku no Hero Academia one to see if it would swap metadata: it did not. Local media agent works (it swaps the cover correctly).

Capture d’écran 2021-01-05 à 22 36 07 Capture d’écran 2021-01-05 à 22 34 46

Here are the Lambda and Local Media logs: com.plexapp.agents.hama.log com.plexapp.agents.localmedia.log

Please let me know if you need anything else. Thanks!

ZeroQI commented 3 years ago

Lambda should run as secondary agent and update metadata from local information. Series need to be matched by primary agent for secondary agent to be called (unless code is changed to make it a primary agent) Collections are restored when the series with said collection runs the secondary agent too...

RomLecat commented 3 years ago

I see, but even if the anime is matched (Boku no Hero Academia is on my last test, which should be present in the logs), Lambda does not overwrite information.

Would it be possible to have it as a primary agent ? My goal is to have a setup like this:

Is that possible ?

ZeroQI commented 3 years ago

If it is a primary agent, there is no longer meta gathered to be backed up, there is no unique I'd generated so if I create one then the metadata cannot be updated by another primary agent until you reassign every series...

It is working for other people so please include generic logs and Lambda logs so I can figure out why local media assets secondary agent works and not Lambda

RomLecat commented 3 years ago

So, if my understanding is correct, there is no way to retrieve the anidb/tvdb contained on tvshow.nfo to achieve this ?

Here are new logs: com.plexapp.agents.hama.log com.plexapp.agents.localmedia.log

Do you need other ones that those two ?

ZeroQI commented 3 years ago

Before re-writing the code completely, for something that works for other people, I would need:

In short, Lambda doesn't run. Why? It use to run before to export, we need it to run to restore, even if it does badly, to troubleshoot. If it doesn't run anymore, plex has a problem "Meitantei Konan Zero no shikkōnin" has a weird character, might cause issues ERROR (agentkit:462) - We seem to be missing the hash for media item [/media/Animes/Kuroko no Basket/Saison 3/Kuroko.no.Basket.S3.05(55)Multi.BDrip.1080p.FLAC.H264-GundamGuy.mkv] => seem like you need to clean bundles, delete trash, optimise database

RomLecat commented 3 years ago

I just realized I gave you twice Hama logs instead of Lambda... Sorry about that.

I removed the entire library, deleted trash, cleaned db, bundles, fixed some movies names with weird characters and created it again. Once the scan is done and metadata starts to be pulled, I'll provide you fresh logs.

RomLecat commented 3 years ago

Here you go: com.plexapp.system.log com.plexapp.agents.lambda.log

ZeroQI commented 3 years ago

Lambda updates whichever side is empty between Plex and local sides, and use the agent setting for source in case of conflicts It is running and saying the fields are identical

Logs will show which field is local and remote and which action is taken, and cannot see wrongdoings in that extract Normally troubleshooting procedure:

Here i miss a big chunk of data (.1, .2, etc) and it basically says the local meta is identical to plex ones

2021-01-06 21:59:47,207 (7ff29affd700) :  INFO (__init__:193) - [=] No update - episode_nfo: /media/Animes/Code Geass Hangyaku no Lelouch/Saison 2/.nfo
2021-01-06 21:59:47,209 (7ff29affd700) :  INFO (__init__:193) - [=] No update - episode_nfo: /media/Animes/Code Geass Hangyaku no Lelouch/Saison 2/.nfo
RomLecat commented 3 years ago

I made another try using 91 Days. I switched its file with the one of another anime and fixed paths:

root@plex2:/mnt/media/Animes/91 Days# cat tvshow.nfo
<?xml version='1.0' encoding='utf-8'?>
<tvshow xsi="http://www.w3.org/2001/XMLSchema-instance" xsd="http://www.w3.org/2001/XMLSchema">
  <uniqueid default="true" type="anidb">14247</uniqueid>
  <title>Go-Toubun no Hanayome</title>
  <runtime>25</runtime>
  <dateadded>2019-03-30 00:35:13</dateadded>
  <path>/media/Animes/91 Days</path>
  <basepath>/media/Animes/91 Days</basepath>
  <playcount text="0">0</playcount>
  <plot>Fûtarô Uesugi est un lycéen issu d'une famille modeste. Un jour, il reçoit une alléchante proposition pour un poste fort bien rémunéré en tant que professeur particulier à temps partiel. Mais voilà, les filles dont il doit s'occuper sont dans sa propre classe ! De plus, ce sont des quintuplées ! Toutes les cinq sont très séduisantes, mais ce sont des élèves à problèmes car elles détestent étudier et leurs notes s'en ressentent. La première mission de Fûtarô sera donc de gagner la confiance des sœurs Nakano...</plot>
  <studio>Tezuka Productions</studio>
...

The current metadata of 91 Days (which did not changed after multiple rescans/refresh metadata): Capture d’écran 2021-01-09 à 15 08 44

And the log files of Lambda (which indicates "No updates" while there is): Lambda logs.zip

ZeroQI commented 3 years ago

I will focus first on backed-up collections not restoring issue for now

Settings:

2021-01-09 14:42:10,854 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['collection_poster'] = 'show-poster.ext'                               , default = 'Ignored'
2021-01-09 14:42:10,855 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['collection_fanart'] = 'show-fanart.ext'                               , default = 'Ignored'
2021-01-09 14:42:10,856 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['collection_resume'] = 'show-{}-summary.txt'                           , default = 'Ignored'
2021-01-09 14:42:10,857 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['collection_nfo'   ] = 'collection.nfo'                                , default = 'Ignored'
2021-01-09 14:42:10,858 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['collection_folder'] = 'root'                                          , default = 'root'
2021-01-09 14:42:10,859 (7fab8f9bdf40) :  INFO (__init__:267) - [X] Prefs['metadata_source'  ] = 'plex'                                          , default = 'local'

Why is it set to metadata source plex?

Notes

If you set a collection manually and refreshes metadata, it should restore. If so, the fix would be to move lines 661 and 670 to 651 to create collection NFO from local info even if collections empty, as per the code below:

  dirname    = os.path.join(library_path if Prefs['collection_folder']=='root' else AgentDataFolder, '_Collections', title)
  nfo_xml = nfo_load(NFOs, dirname, 'collection_nfo')
  while collections and (count==0 or count<total):
RomLecat commented 3 years ago

Why is it set to metadata source plex?

Because I actually run tests on my "master" Plex instance for now, which means I sometime edit metadata and have to overwrite nfo/covers, so I set it to Plex temporarily, just to let Lambda rewrites data, then I switch back to "Local". Don't worry, the tests I've made are always with metadata source local and not Plex, and it was also set to local when I created the library (even if it probably doesn't matter, since I refreshed metadata later).

If you set a collection manually and refreshes metadata, it should restore.

I tried to set a collection on an item which should be a part of a collection with a different name (without the "lock", so it can be overwritten), didn't help. When I refreshed metadata, the collection was gone (since I disabled the lock on the attribute, I guess this is expected since my HamaTV Collection setting is set to "None").

I also tried to create the Collection in which the anime should go, didn't help.

Can you please attach the collection.nfo in library root folder?

I don't have any. I only have a "_Collections" folders, like this:

root@plex2:/mnt/media/Animes# tree _Collections/
_Collections/
├── ACCA 13-ku Kansatsu-ka
│   ├── collection.nfo
│   └── show-poster.jpg
├── Accel World
│   ├── collection.nfo
│   └── show-poster.jpg
ZeroQI commented 3 years ago

@Hakujou You have left the default option, 'collection_folder' at library root: [X] Prefs['collection_folder'] = 'root' That is indeed the folder created [/mnt/media/Animes/_Collections/] for the collection information

According line 651 of https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/__init__.py it will only process the loop if there is collections in Plex: while collections and (count==0 or count<total):, so can you manually set collection entry 'test' and see if the loading works as expected?

If it works, the code need altering to load the collection file, count the number of collections and put it in total, unless just removing 'collections and' works line 651

RomLecat commented 3 years ago

I tried to make a Collection named 'test' with one item inside (which was never part of collection before) and refreshed all metadata, no luck.

Here are the logs: com.plexapp.agents.lambda.log