ZeroQI / Lambda.bundle

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

Issue with multiple tags export (genre, actors) #12

Open mukalaaa opened 4 years ago

mukalaaa commented 4 years ago

first thanks a lot for creating such an amazing plugin

I was wondering if there is a way to make your plugin appear under PhoenixAdult.bundle

PhoenixAdult.bundle is a plugin that fetches metadata for porn scenes from famous porn websites. you can find the plugin here in GitHub, if you wanna have a look at it.

I want to download and save those metadata using your amazing plugin but unfortunately it doesn't appear under PhoenixAdult.bundle agent.

Thanks a lot

ZeroQI commented 4 years ago

Note for me: what would 'com.plexapp.agents.none' do?

https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/__init__.py line 698 Change from: contributes_to = ['com.plexapp.agents.hama', 'com.plexapp.agents.imdb', 'com.plexapp.agents.none'] To: contributes_to = ['com.plexapp.agents.hama', 'com.plexapp.agents.imdb', 'com.plexapp.agents.none', 'com.plexapp.agents.phoenixadult']

Please report if it fixes and i will add it to master code, and if so, please consider donating if you can afford it.

ZeroQI commented 4 years ago

https://forums.plex.tv/t/rel-lambda-local-assets-metadata-double-agent-for-plex-metadata-export/295681/126

edited line #35 in the “PhoenixAdult” plugin to make your plugin show under PhoenixAdult agent. accepts_from = [‘com.plexapp.agents.localmedia’, ‘com.plexapp.agents.lambda’] [‘com.plexapp.agents.hama’, ‘com.plexapp.agents.imdb’, ‘com.plexapp.agents.none’, ‘com.plexapp.agents.phoenixadult’]

Pending confirmation that metadata was refreshed and Lamdba logs to troubleshoot if so

mukalaaa commented 4 years ago

Ok, here is the update So, I managed to get it working using your instructions at your amazing plugin does generate nfo files and posters. So, I started testing with 2 adult clips but i noticed few issues:

1- one of the adult clips has multiple genres but it only shows one genre when using lambda 2- it does not show actors and actresses at all not even empty slots, they just disappear 3- the 2 clips are part of one collection but lambda does not show collections or related movies

Any ideas?

mukalaaa commented 4 years ago

one more thing, can you please point me to how can we submit donations to you. You work and effort are highly appreciated and we would like to contribute!

Thanks

ZeroQI commented 4 years ago

Readme includes a troubleshooting and donation section:

The good point with Lambda is the ability to backup and restore data so even if the agent that gave the metadata stops working you can load the backed up metadata...

Issues:

mukalaaa commented 4 years ago

lambda settings

com.plexapp.agents.lambda.log.zip

here is a screenshot of the settings and the zip folder contains three logs for lambda

please let me know what you find

ZeroQI commented 4 years ago

Latest log ends in .log. When it creates new ones, it pushes down .log.1, .log.2, .log.3, .log.4, .log.5 and delete what falls over... I ask to update one serie as otherwise multiple threads run concurently and logs are a mess as showing two or more processing running concurrently and logs become un-readable...

Let's focus on Z:\Brazzers\bangbrosclips.19.12.13.amia.miley for now (most issues)

Issue saving poster:

SaveFile("/library/metadata/11441/thumb/1586599851", "Z:\Brazzers\bangbrosclips.19.12.13.amia.miley", "movies_poster", "{}.ext"...) xml_field: ""
Exception writing to Z:\Brazzers\bangbrosclips.19.12.13.amia.miley\bangbrosclips.19.12.13.amia.miley.jpg
IOError: [Errno 2] No such file or directory: u'\\\\?\\Z:\\Brazzers\\bangbrosclips.19.12.13.amia.miley\\._bangbrosclips.19.12.13.amia.miley.jpg'

Genre bug

2020-04-11 13:11:10,881 (423c) :  INFO (logkit:16) - SaveFile("Blow Job", "Z:\Brazzers\bangbrosclips.19.12.13.amia.miley", "movies_nfo", "{}.nfo"...) xml_field: "genre"
2020-04-11 13:11:10,881 (423c) :  INFO (logkit:16) - [?] plex_value:  "Blow Job", type: "<type 'str'>"
2020-04-11 13:11:10,881 (423c) :  INFO (logkit:16) - [?] local_value: "", type: "<type 'str'>"
2020-04-11 13:11:10,882 (423c) :  INFO (logkit:16) - [@] Local update - movies_nfo: bangbrosclips.19.12.13.amia.miley.nfo directory already exists
2020-04-11 13:11:10,882 (423c) :  INFO (logkit:16) - xml_import() - xml: <Element movie at 0x563bee0>, xml_tags: genre, root: movie, multi: True, thumb: Blow Job
2020-04-11 13:11:10,882 (423c) :  INFO (logkit:16) - [X] tag: "genre" created with attributes: "{'text': 'Blow Job'}"
2020-04-11 13:11:10,882 (423c) :  INFO (logkit:16) - SaveFile("Brunette", "Z:\Brazzers\bangbrosclips.19.12.13.amia.miley", "movies_nfo", "{}.nfo"...) xml_field: "genre"
2020-04-11 13:11:10,884 (423c) :  INFO (logkit:16) - [?] plex_value:  "Brunette", type: "<type 'str'>"
2020-04-11 13:11:10,884 (423c) :  INFO (logkit:16) - local_value - Exception: "list index out of range", genre, Brunette

Collection

2020-04-11 13:11:10,908 (423c) :  INFO (logkit:16) - [=] Z:\Brazzers\_Collections\Bangbros Clips\Ignored path: "Z:\Brazzers\_Collections\Bangbros Clips\Ignored"
2020-04-11 13:11:10,915 (423c) :  CRITICAL (core:574) - Exception writing to Z:\Brazzers\bangbrosclips.19.12.13.amia.miley\bangbrosclips.19.12.13.amia.miley.nfo (most recent call last):
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-77cb9455c\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\storage.py", line 81, in save
    f = open(tempfile, mode)
  File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-77cb9455c\Framework.bundle\Contents\Resources\Versions\2\Python\subsystem\ospathfix.py", line 70, in builtins_open
    return __builtins__['_open'](longpathify(uni(filename)), mode, buffering)
IOError: [Errno 2] No such file or directory: u'\\\\?\\Z:\\Brazzers\\bangbrosclips.19.12.13.amia.miley\\._bangbrosclips.19.12.13.amia.miley.nfo'
mukalaaa commented 4 years ago

Ok in order to make this more clear I deleted all logs deleted the library created library again created new log

using windows 10 with one user only and write read permissions are not a problem since i can get the metadata generated but it is missing many things such as genres, actors, related movies..etc

I am testing this new library with 2 files:

  1. assparade.15.02.02.valerie.kay Genre: blowjob, pornstar actors available
  2. blowjobfridays.19.12.27.casca.akashova Genre: blowjob, caucasian actors available also each one of them shows related movies and pointing to one another because boths clips belong to bangbros studio

Now, I deleted the library then i recreate it using only your plugin, to make it read the exported metadata without re downloading them again

everything is loaded, title, poster and plot... but it only shows one genre which blowjob, it doesnot show the rest...also it doesnot show actors at all... there is not even a section of empty slots for them, same thing for related movies, it shows nothing

here is a copy of the new clean logs as well as nfo files com.plexapp.agents.lambda.log.zip

mukalaaa commented 4 years ago

@ZeroQI any update regarding this issue? was the latest clean log I sent you enough? or do you want something more or specific from me to do? I will be more than happy to provide whatever you need to make this work

I really appreciate everything you are doing

ZeroQI commented 4 years ago

Source:

Fields impacted:

Files impacted:

Collections

Actors

Added following code: for tag in video.iterchildren('Role' ): SaveFile(tag.get('tag') , path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'Name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb')}}}, multi='actor', tag_multi='role')

Genres

Please

mukalaaa commented 4 years ago

Hello again and thank you in advance for your work and effort to fix this issue I use Kodi and i can tell you that kodi nfo files do support actors in movie not just series

I downloaded your latest plugin but to my surprise I did not see it under phoenixadult agent, I guess you did not add it yet in your code, so I added it manually using your instructions: Change from: contributes_to = ['com.plexapp.agents.hama', 'com.plexapp.agents.imdb', 'com.plexapp.agents.none'] To: contributes_to = ['com.plexapp.agents.hama', 'com.plexapp.agents.imdb', 'com.plexapp.agents.none', 'com.plexapp.agents.phoenixadult']

Then restarted plex and updated the metadata twice for the 2 clips Now, I do see an empty slot for actors but it says unknown, no name or picture of the actor only one genre and no collections or related movies

here is the logs along with the new nfo files

com.plexapp.agents.lambda.log.zip

Thank you so much

mukalaaa commented 4 years ago

Btw, I have been using XBMCnfoMoviesImporter to reload the nfo files and posters

because, when I use your plugin to to read the metadata locally, it doesnt show anything except for the poster!! but when i use XBMCnfoMoviesImporter, i can see the plot, genres and titles no plot, genres, actors or even title... it only loads the poster !!

please have a look the snapshot to see if this is the right way to make lambda reads local metadata or not ? sett

mukalaaa commented 4 years ago

Here is a copy of an nfo file created by kodi just now, as you can see it shows multiple actors and actually kodi does also export their pictures as well in a seperate folder named "actors" located within the same folder of the media file

so it would like this:

I hope it can help

ZeroQI commented 4 years ago

Lambda is a secondary metadata agent, not a primary one You cannot update the metadata if the unique id has not been assigned by the primary medatada search() function, and if i were to change that you would have to change agent and update metadata so it continues to fetch metadata. So no change to restoration for now.

collection part crashes at the end of the agent on

NFO

  <actor>
    <name>Rebecca Sharon</name>
    <type>Actor</type>
  </actor>

Currently

  <actor>
    <role/>
    <Name>Casca Akashova</Name>
    <thumb/>
    <role/>
  </actor>

Line 391 since the role was unfilled and set as primary key, switch to name as unique key. for tag in video.iterchildren('Role' ): SaveFile(tag.get('tag') , path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb')}}}, multi='actor', tag_multi='name')

Genre

Now 2nd genre fail with local_value - Exception: "list index out of range", this code at fault

      if isinstance(xml_field, dict):
        local_value = xml_import(nfo_xml, xml_field, nfo_root_tag[field], multi, thumb, tag_multi, return_value_only=True)
      else:
        tag = nfo_xml.find( './/'+xml_field )
        if tag is not None:  local_value = tag[0].text
ZeroQI commented 4 years ago

please update agent, update movie metadata, return new logs. Nearly there... it cannot read second xml tag value for genre if one already there

ZeroQI commented 4 years ago

Please update to latest code, refresh metadata then attach the logs. Should be able to fix the genre with that and actors should be fixed

mukalaaa commented 4 years ago

Hey ZeroQI

Sorry for the late reply, I did as you asked but unfortunately, it still shows one genre and only one actor. Furthermore, the actor it shows, it shows it in a strange way, please have a look at the snapshot and logs

cast com.plexapp.agents.lambda.log.zip

Thanks a lot

Note: I am still unable to make your plugin loads the local metadata files generated by lambda, I am using XBMCnfoMoviesImporter to make plex use the local metadata

ZeroQI commented 4 years ago

it should be loaded mostly by the local media assets agent for the posters, thune, and the rest by lambda once the main agent set the unique id. Never used XBMCnfoMoviesImporter but tried to make the nfo complies to xbmc format...

It seems to stop crashing so have to sort actor and genre limited to one entry...

Edit: reproduced issue, need to code now

ZeroQI commented 4 years ago

When multi tags are concerned, the agent always update the first, impacts actors and genre, direcotors... Coding in progress but very long to fix while the code will likely be very short in the end

mukalaaa commented 4 years ago

I appreciate everything you are doing... Thank you! I dont even think the word thank you is enough for your time and efforts. I admire your dedication and fast responses.

is there anything I can do to help?

ZeroQI commented 4 years ago

Uploaded new version.

Way more code changes than i thought initially to fix. For collection, the field is not included in the movie nfo but collection nfo you have to enable in the settings Please test latest code and report, and please consider donating.

ZeroQI commented 4 years ago

So, working?

ZeroQI commented 4 years ago

Please confirm if issue is still present after latest code, or i will archive this issue

Sirfrancis18 commented 4 years ago

So, working?

actors field dont working. only print the first actor in nfo file

Sirfrancis18 commented 4 years ago

image i dont see name actor. Only role of the first actor In movies, exist code por name actors , but i dont see for shows

        #Multi tags

        for tag in show.iterchildren('Genre'     ):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='genre', metadata_field=metadata.genres,      multi=True, tag_multi='genre')
        for tag in show.iterchildren('Collection'):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='tag',   metadata_field=metadata.collections, multi=True);  collections.append(tag.get('tag')); 
        `
ZeroQI commented 4 years ago

https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/__init__.py

Format

  <actor>
    <role/>
    <Name>Casca Akashova</Name>
    <thumb/>
  </actor>
  <actor>
    <role>yyy yyy</role>
    <Name>xxx xxx</Name>
    <thumb/>
  </actor>

I need lambda agent logs to compare the list of actors XML to see if it creates multipe entries tag_multi='actor' should fix, that is the field being duplicated, explains the single entry

Sirfrancis18 commented 4 years ago

com.plexapp.agents.lambda.log com.plexapp.agents.lambda1.log com.plexapp.agents.lambda2.log

image

Sirfrancis18 commented 4 years ago

another tv show com.plexapp.agents.lambda.log

image

com.plexapp.agents.lambda1.log com.plexapp.agents.lambda2.log

ShadowWalker86 commented 4 years ago

I have recently installed Lambda and found this to still be an issue in that when I inspect the generated nfo file there is only 2 genres where metadata in Plex itself may be 20-30 genres. The same issue with actors where it is only generating 1 or 2. Is there anything I can provide, logs or examples that would help in resolving this issue?

ZeroQI commented 4 years ago

@Sirfrancis18 You picked an example [32241, Big hero 6: la serie]. I ask logs, and the example isn't in it... Lines 468-470 for roles:

                for role in directory.iterchildren('Role'):
                  if role.get('tag') in roles:
                    SaveFile(role.get('role'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': role.get('role')}, 'Name': {'text': role.get('tag')}, 'thumb': {'text': role.get('thumb')}}}, multi='actor', tag_multi='role')

replace with:

                for role in directory.iterchildren('Role'):
                  if role.get('tag') in roles:
                    SaveFile(role.get('role'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': role.get('role')}, 'Name': {'text': role.get('tag')}, 'thumb': {'text': role.get('thumb')}}}, multi='actor', tag_multi='actor')

Report if it fixes please.

@ShadowWalker86 I don't use Lambda or Plex anymore so you need to describe well the issue.

ShadowWalker86 commented 4 years ago

Here is an example, it seems to have bought over multiple actors on this refresh but I will try and find another. The genre issue is present on this example though in that it has only copied over 2 genres into the generated NFO file out of the 11 in the Plex Metadata.

Lambda Log com.plexapp.agents.lambda.log

Plex Metadata XML from '_combined' folder - Info.xml.txt

Generated NFO - vixen.19.09.26.evelyn.claire.and.elsa.jean.4k.nfo.txt

ZeroQI commented 4 years ago

NFO brought 3 out of 3 actors in the XML from '_combined' folder (excellent idea to include) However, there is 2 out of 12 genre:

  <genres>
    <item index="0">69 (Position)</item>
    <item index="1">Blonde</item>
    <item index="2">Brunette</item>
    <item index="3">Doggystyle (Position)</item>
    <item index="4">Face Sitting</item>
    <item index="5">Facial</item>
    <item index="6">Hairy Pussy</item>
    <item index="7">Kissing</item>
    <item index="8">Pussy Eating</item>
    <item index="9">Riding</item>
    <item index="10">Small Tits</item>
    <item index="11">Threesome</item>
  </genres>

Code responsible https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/__init__.py

I need to display show XML Agent logs show 2 only:

2020-09-17 18:39:44,551 (22dc) :  INFO (logkit:16) - SaveFile("69 (Position)", "M:\Library\Adult\Vixen\Vixen.19.09.26.Evelyn.Claire.And.Elsa.Jean.XXX.2160p.MP4-KTR[rarbg]", "movies_nfo", "{}.nfo"...) xml_field: "genre"
2020-09-17 18:39:44,552 (22dc) :  INFO (logkit:16) - [?]  plex_value: "69 (Position)", type: "<type 'str'>"
2020-09-17 18:39:44,552 (22dc) :  INFO (logkit:16) - [?] local_value: "69 (Position)", type: "<type 'str'>"
2020-09-17 18:39:44,553 (22dc) :  INFO (logkit:16) - [=] No update - movies_nfo: M:\Library\Adult\Vixen\Vixen.19.09.26.Evelyn.Claire.And.Elsa.Jean.XXX.2160p.MP4-KTR[rarbg]\vixen.19.09.26.evelyn.claire.and.elsa.jean.4k.nfo

2020-09-17 18:39:44,553 (22dc) :  INFO (logkit:16) - SaveFile("Blonde", "M:\Library\Adult\Vixen\Vixen.19.09.26.Evelyn.Claire.And.Elsa.Jean.XXX.2160p.MP4-KTR[rarbg]", "movies_nfo", "{}.nfo"...) xml_field: "genre"
2020-09-17 18:39:44,555 (22dc) :  INFO (logkit:16) - [?]  plex_value: "Blonde", type: "<type 'str'>"
2020-09-17 18:39:44,555 (22dc) :  INFO (logkit:16) - [?] local_value: "Blonde", type: "<type 'str'>"
2020-09-17 18:39:44,556 (22dc) :  INFO (logkit:16) - [=] No update - movies_nfo: M:\Library\Adult\Vixen\Vixen.19.09.26.Evelyn.Claire.And.Elsa.Jean.XXX.2160p.MP4-KTR[rarbg]\vixen.19.09.26.evelyn.claire.and.elsa.jean.4k.nfo

Line 406 for Movies, the XML is displayed, if in debug mode, please enable debug mode in plex, refresh metadata, attach agent logs again

Not sure if linked but it's just before multi tags:

2020-09-17 18:39:44,569 (22dc) :  INFO (logkit:16) - [X] tag: "thumb" found, updating attributes: "{'text': None}"
2020-09-17 18:39:44,569 (22dc) :  INFO (logkit:16) - PLEX_URL_MOVIES - Exception: "'lxml.etree._Element' object has no attribute 'thumb'", e.message: 'lxml.etree._Element' object has no attribute 'thumb', e.args: ("'lxml.etree._Element' object has no attribute 'thumb'",)

You could comment both lines 393 and 398 and if it works, then the crash was linked, and you could replace line 393 with: if 'thumb' in video.attrib: destination = SaveFile(video.get('thumb'), path, 'movies_poster', dynamic_name=filenoext); SaveFile(destination, path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'art': {'poster': {'text': destination }}})

ShadowWalker86 commented 4 years ago

Enabled debug mode, restarted Plex and refreshed metadata for example file. Log here - com.plexapp.agents.lambda.log.1.log

Log file still shows exception. Commented lines 393 and 398, restarted Plex and refreshed metadata for example file. Log here - com.plexapp.agents.lambda.log

Agent log is still only showing 2 of the genre and no change to generated NFO file.

ShadowWalker86 commented 4 years ago

Here is the XML file from the path shown in debug. \Metadata\Movies\e\cf5ed034a8e8e915e7b1cc8ca80940b8a390030.bundle\Contents\com.plexapp.agents.phoenixadult\Info.xml

Info.xml Info.xml.txt

ZeroQI commented 4 years ago

com.plexapp.agents.lambda.log.1.log is empty... Other log show the XML i use as basis and the NFO match:

<?xml version='1.0' encoding='utf8'?>
<Video ratingKey="19952" key="/library/metadata/19952" guid="com.plexapp.agents.phoenixadult://CkjXoX6go4FyeMi|52?lang=en" studio="Vixen" type="movie" title="First Time?" contentRating="XXX" summary="Club Vixen can't stop, won't stop. Elsa is new and Evelyn has been a member for a bit. Their paths cross and we witness the magic happen, beat by beat." year="2019" thumb="/library/metadata/19952/thumb/1600339447" art="/library/metadata/19952/art/1600339447" duration="2949312" originallyAvailableAt="2019-09-26" addedAt="1572808436" updatedAt="1600339447">
<Media id="19053" duration="2949312" bitrate="25164" width="3840" height="2160" aspectRatio="1.78" audioChannels="2" audioCodec="aac" videoCodec="h264" videoResolution="4k" container="mp4" videoFrameRate="24p" optimizedForStreaming="0" audioProfile="lc" has64bitOffsets="1" videoProfile="high">
<Part id="19090" key="/library/parts/19090/1572808436/file.mp4" duration="2949312" file="M:\Library\Adult\Vixen\Vixen.19.09.26.Evelyn.Claire.And.Elsa.Jean.XXX.2160p.MP4-KTR[rarbg]\vixen.19.09.26.evelyn.claire.and.elsa.jean.4k.mp4" size="9279047816" audioProfile="lc" container="mp4" has64bitOffsets="1" indexes="sd" optimizedForStreaming="0" videoProfile="high"/>
</Media>
<Genre tag="69 (Position)"/>
<Genre tag="Blonde"/>
<Director tag="Derek Dozer"/>
<Collection tag="Vixen"/>
<Role tag="Evelyn Claire"/>
<Role tag="Elsa Jean"/>
<Role tag="Johnny Sins"/>
</Video>

I extract all info for that XML but there is info missing... Need to check if i can load different XMLs line 363+...+728

    count, total = 0, 0
    while count==0 or count<total:  #int(PLEX_TVSHOWS_XML.get('size')) == WINDOW_SIZE[agent_type] and
      try:
        PLEX_XML_MOVIES, count, total = xml_from_url_paging_load(PLEX_URL_MOVIES, library_key, count, WINDOW_SIZE[agent_type])
        for video in PLEX_XML_MOVIES.iterchildren('Video'):
          if media.id == video.get('ratingKey'):
            Log.Info('title:                 {}'.format(video.get('title')))

PLEX_URL_MOVIES                 = PMSSEC + '/{}/all?type=1'  + PAGING #How to load XML info: https://support.plex.tv/articles/201638786-plex-media-server-url-commands/

It seems i need to reload the item specifically According "https://support.plex.tv/articles/201638786-plex-media-server-url-commands/" http://[PMS_IP_ADDRESS]:32400/library/metadata/1668?X-Plex-Token=YourTokenGoesHere

F##k... Bug found, wrong method used, work perfectly for the first 2 actors/genre... looking at code, i already load it line 460...

remove

            #Multi tags
            for tag in show.iterchildren('Genre'     ):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='genre', metadata_field=metadata.genres,      multi=True, tag_multi='genre')
            for tag in show.iterchildren('Collection'):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='tag',   metadata_field=metadata.collections, multi=True);  collections.append(tag.get('tag')); 

Move it at 462 (before cutting, after cutting 458 so before 'for directory'...)

          #Multi tags
          for tag in show.iterchildren('Genre'     ):  SaveFile(xml.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='genre', metadata_field=metadata.genres,      multi=True, tag_multi='genre')
          for tag in show.iterchildren('Collection'):  SaveFile(xml.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='tag',   metadata_field=metadata.collections, multi=True);  collections.append(tag.get('tag')); 

This should use extended info an gather more than the 2 items shown in first XML

ZeroQI commented 4 years ago

Bug seem to be 2 genres limit, might be identical for collections Fix added for tv-series Added a commented bug fix

Sorry it is convoluted, but my NAS is shutdown, and stopped usin Plex and don't use Lambda personally so...

ShadowWalker86 commented 4 years ago

Un-commented lines 397-400 and commented lines 403 and 375.

Log shows exception, no genre data appears in log, no change to NFO file - com.plexapp.agents.lambda.log

ZeroQI commented 4 years ago

uncommented lines 397-400 are faulty indeed, replacing with the below should fix movies:

            xml = XML.ElementFromURL(PMSMETA.format(ratingKey), timeout=float(TIMEOUT))
            if xml is not None: #Multi tags
              for tag in xml.iterchildren('Genre'     ):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='genre', metadata_field=metadata.genres,      multi=True, tag_multi='genre')
              for tag in xml.iterchildren('Collection'):  SaveFile(tag.get('tag'), path, 'series_nfo', nfo_xml=nfo_xml, xml_field='tag',   metadata_field=metadata.collections, multi=True);  collections.append(tag.get('tag')); 

Please test fixes (should impact series and movies) and see if movies with loads of actors get them all in the NFO...

ShadowWalker86 commented 4 years ago

Plugin appears to still not pull any genre data with the above fixes. Log here -com.plexapp.agents.lambda.log

ZeroQI commented 4 years ago

Thanks to the logs (contain both xmls) i could spot an issue, should be corrected now

ShadowWalker86 commented 4 years ago

Happy to confirm that all the genres populated on a single refresh into the NFO file. - Fix confirmed.

I did notice however that it took multiple refreshes (4 in the case of the example file) to populate the actors and director, with only one being added each time.

This I can work around but not sure if the same fix that was applied to the genres could possibly be applied when scraping the actors.

For now I am going to run a larger refresh on my library and check genre's against multiple files.

ShadowWalker86 commented 4 years ago

After library scan seems unable to update past 3 actors.

Noticed commented possible fix and made the following change

for tag in xml.iterdescendants('Role' ): SaveFile(tag.get('tag'), path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb')}}}, multi=True, tag_multi='name')

commented out

for tag in video.iterchildren('Role' ): SaveFile(tag.get('tag'), path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb')}}}, multi='actor', tag_multi='name')

Found now able to populate all actors but took multiple refreshes, only adding 1 actor at a time. Does this line require perhaps ?.append at the end?

ZeroQI commented 4 years ago

append is to add to a list so i can display all the list in one line latter... Code improved, may fix the actor, if not please attach agent logs, output allow to see normal and extended xml file so i can fix in one go

ShadowWalker86 commented 4 years ago

Carried out refresh on a different file, this was the second refresh, only updated a single actor this pass.

blacked.18.12.20.kali.roses.4k.nfo.txt

com.plexapp.agents.lambda.log

Let me know if attaching either XML file would help.

ZeroQI commented 4 years ago

I specifically output roles, genres and collections before both XMLs (summarised, extended) output in the agent log for both movies and series, and that output is missing but it did crash...

Now that we are seeing more actors, some other bugs pop up...

2020-09-18 18:43:46,325 (1d30) :  INFO (logkit:16) - SaveFile("Jason Brown", "M:\Library\Adult\Blacked\Blacked.18.12.20.Kali.Roses.XXX.2160p.MP4-KTR[rarbg]", "movies_nfo", "{}.nfo"...) xml_field: "{'actor': {'role': {'text': ''}, 'name': {'text': 'Jason Brown'}, 'thumb': {'text': 'https://secure2-images-blacked.ssl-cdn.com/models/jason-brown/image/1445848791527/jason-brown.jpeg?nvb=20200918061844&nva=20200918091844&hdl=-1&hash=0fe81a9d68973e2f22260'}}}"
2020-09-18 18:43:46,326 (1d30) :  INFO (logkit:16) - [?]  plex_value: "Jason Brown", type: "<type 'str'>"
2020-09-18 18:43:46,326 (1d30) :  INFO (logkit:16) - [?] local_value: "None", type: "<type 'NoneType'>"
2020-09-18 18:43:46,328 (1d30) :  INFO (logkit:16) - [@] Local update movies_nfo: M:\Library\Adult\Blacked\Blacked.18.12.20.Kali.Roses.XXX.2160p.MP4-KTR[rarbg]\.nfo, ratingKey: 
2020-09-18 18:43:46,328 (1d30) :  INFO (logkit:16) - [X] tag: "actor" created with attributes: "{}"
2020-09-18 18:43:46,328 (1d30) :  INFO (logkit:16) - [X] tag: "role" created with attributes: "{'text': ''}"
2020-09-18 18:43:46,328 (1d30) :  INFO (logkit:16) - [X] tag: "name" created with attributes: "{'text': 'Jason Brown'}"
2020-09-18 18:43:46,328 (1d30) :  INFO (logkit:16) - [X] tag: "thumb" found, updating attributes: "{'text': 'https://secure2-images-blacked.ssl-cdn.com/models/jason-brown/image/1445848791527/jason-brown.jpeg?nvb=20200918061844&nva=20200918091844&hdl=-1&hash=0fe81a9d68973e2f22260'}"
2020-09-18 18:43:46,329 (1d30) :  INFO (logkit:16) - PLEX_URL_MOVIES - Exception: "'lxml.etree._Element' object has no attribute 'thumb'", e.message: 'lxml.etree._Element' object has no attribute 'thumb', e.args: ("'lxml.etree._Element' object has no attribute 'thumb'",)

Updated https://github.com/ZeroQI/Lambda.bundle/blob/master/Contents/Code/__init__.py again

ShadowWalker86 commented 4 years ago

Plugin hangs on refresh - com.plexapp.agents.lambda.log

ShadowWalker86 commented 4 years ago

Exception - INFO (logkit:16) - PLEX_URL_MOVIES - Exception: "'lxml.etree._Element' object has no attribute 'thumb com.plexapp.agents.lambda.log

ZeroQI commented 4 years ago

line 400 crash at actor "Jax Slayher" as it doesn't exist in the nfo, for a "thumb" missing before outputting the xml :/ for tag in xml.iterdescendants('Role' ): SaveFile(tag.get('tag'), path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb') if 'thumb' in tag else ""}}}, multi='actor', tag_multi='name'); roles.append(tag.get('tag'))

it outputs line 117 before crashing with PLEX_URL_MOVIES - Exception: "'lxml.etree._Element' object has no attribute 'thumb'", e.message: 'lxml.etree._Element' object has no attribute 'thumb', e.args: ("'lxml.etree._Element' object has no attribute 'thumb'",)

It is a complex recursion (function calls other functions) and tricky to pinpoint, and the thumb may be empty for tag in xml.iterdescendants('Role' ): SaveFile(tag.get('tag'), path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb') if 'thumb' in tag else ""}}}, multi='actor', tag_multi='name'); roles.append(tag.get('tag'))
should become: for tag in xml.iterdescendants('Role' ): SaveFile(tag.get('tag'), path, 'movies_nfo', nfo_xml=nfo_xml, xml_field={'actor': {'role': {'text': tag.get('role')}, 'name': {'text': tag.get('tag')}, 'thumb': {'text': tag.get('thumb')} if 'thumb' in tag else None }}, multi='actor', tag_multi='name'); roles.append(tag.get('tag'))

Posted a change to master code, small code change may resolve, and if not will output xml first to help me troubleshoot

ShadowWalker86 commented 4 years ago

Exception with unexpected indent on line 403, removed indent, restarted Plex and carried out metadata refresh.

No update to NFO file, log file attached - com.plexapp.agents.lambda.log