Advertisement
Acid_Alchamy

plex

Apr 16th, 2023
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. ### Plex.tv ###
  2. # Plex Theme songs list:  https://support.plex.tv/hc/en-us/articles/201178657-Current-TV-Themes
  3. # Submit, Request songs:  https://support.plex.tv/hc/en-us/articles/201572843 / Limitations: 30s length, 44.1 Kh, 128 to 256 kbps / Naming convention: "TV Show Name - TVDBID.mp3"
  4. #
  5. # To do: TVDB has one song per serie but Japanese anime has one per season, having a song for AniDB series would be more factually correct using AniDB series definition.
  6. #        Can we add an OP video as Theme song? if not, recover theme song from opening video with ffmpeg script
  7. #        Package of anime theme songs 30s length indexed on anidbid OR TVDBid but with season xxxxx-s1
  8.  
  9. ### Imports ###
  10. # HAMA Modules #
  11. import common
  12. from common import Log, DictString, Dict, SaveDict # Direct import of heavily used functions
  13.  
  14. ### Variables ###
  15. THEME_URL = 'https://tvthemes.plexapp.com/{}.mp3'
  16.  
  17. ### Functions ###
  18. def GetMetadata(metadata, error_log, TVDBid, title):
  19.   Log.Info("=== Plex.GetMetadata() ===".ljust(157, '='))
  20.   url       = THEME_URL.format(TVDBid)
  21.   Plex_dict = {}
  22.  
  23.   Log.Info("Prefs['themes']: '{}', TVDBid: '{}'".format(Prefs['themes'], TVDBid))
  24.   Log.Info("--- themes ---".ljust(157, '-'))
  25.   if 'Plex' in Prefs['themes'] and TVDBid.isdigit():
  26.     title  = title or TVDBid
  27.     result = '*' if url in metadata.themes else common.GetStatusCode(url)
  28.     Log.Info("result code: '{plex}', url: '{url}'".format(plex=result, url=url))
  29.     if result in (200, "*"):  Log.Info("[ ] theme: {}".format(SaveDict(("Plex/%s.mp3" % TVDBid, 2, None), Plex_dict, 'themes', url)))
  30.     else:                     error_log['Plex themes missing'].append("TVDBid: '{}' | Title: '{}' | {}".format(common.WEB_LINK % (common.TVDB_SERIE_URL + TVDBid, title), title, common.WEB_LINK % ("mailto:[email protected]?cc=&subject=Missing%%20theme%%20song%%20-%%20'%s%%20-%%20%s.mp3'" % (title, TVDBid), 'Upload')))
  31.   else:  Log.Info("Not pulling meta - 'Plex' in Prefs['themes']: '{}', TVDBid: '{}'".format('Plex' in Prefs['themes'], TVDBid))
  32.  
  33.   Log.Info("--- return ---".ljust(157, '-'))
  34.   Log.Info("Plex_dict: {}".format(DictString(Plex_dict, 1)))
  35.   return Plex_dict
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement