ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
452 stars 43 forks source link

Collection metadata fields population #12

Closed ZeroQI closed 5 years ago

ZeroQI commented 5 years ago

It seem possible to do it through http calls: https://github.com/defract/TMDB-Collection-Data-Retriever/blob/master/collection_updater.py need the library ID though but can get it from http://127.0.0.1:32400/library/sections/?X-Plex-Token=xxxxxxxxx with token method: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

plex_col_id

plex_all_col_xml = GetPlexData(PLEX_COLLECTIONS % section_id)
for plex_col_xml in plex_all_col_xml:
  plex_col_dict = plex_col_xml.attrib
  if plex_col_dict['summary'] != '':  continue  # only get data for collections that have no summary yet
  plex_col_id = plex_col_dict['ratingKey']

Summary

PLEX_SUMMARY = '%s/library/sections/%%s/all?type=18&id=%%s&summary.value=%%s' % PLEX_SERVER
r = requests.put(PLEX_SUMMARY % (section_id, plex_col_id, tmdb_col_dict['overview']), data=payload, headers=HEADERS)

Posters/Art

PLEX_IMAGES = '%s/library/metadata/%%s/%%s?url=%%s' % PLEX_SERVER
def UploadImagesToPlex(url_list, plex_col_id, image_type):
  plex_main_image = ''
  for background_url in url_list:
    if plex_main_image == '':  plex_main_image = GetPlexPosterUrl(PLEX_IMAGES % (plex_col_id, image_type + 's', background_url))
    r = requests.post(PLEX_IMAGES % (plex_col_id, image_type + 's', background_url), data=payload, headers=HEADERS)
    r = requests.put (PLEX_IMAGES % (plex_col_id, image_type,      plex_main_image), data=payload, headers=HEADERS)

Possibility to edit collection posters and summary through metadata field ?

ZeroQI commented 5 years ago

Breakthrough thanks to Dane22, i can download collection information too:

PLEX_COLLECT_URL = 'http://127.0.0.1:32400/library/sections/X/all?type=18&X-Plex-Container-Start={}&X-Plex-Container-Size={}'
XML.ElementFromURL(PLEX_COLLECT_URL, timeout=float(TIMEOUT))

Although when using this function, no need for Plex token, will retrofit to Hama and YouTube Agent when finished with "Local Media Export" agent, a reverse "Local Media Asset" agent with options to export XBMC style NFOs in the future...

ZeroQI commented 5 years ago

now that i use channel as poster picture, it loose interest to set as collection poster... Closing