Skip to content

Commit

Permalink
Fix an issue with Air dates not being existant.
Browse files Browse the repository at this point in the history
Also split the Synopsis cleanups into it's own prefs.
  • Loading branch information
Cazzar committed May 15, 2019
1 parent c4572cc commit c1fb229
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ def Update(self, metadata, media, lang, force, movie):

Log('Assumed tv rating to be: %s' % metadata.content_rating)

if series['air'] != '1/01/0001 12:00:00 AM' and series['air'] != '0001-01-01':
metadata.originally_available_at = datetime.strptime(series['air'], "%Y-%m-%d").date()
airdate = try_get(series, 'air', '1/01/0001 12:00:00 AM')
if airdate != '1/01/0001 12:00:00 AM' and airdate != '0001-01-01':
metadata.originally_available_at = datetime.strptime(airdate, "%Y-%m-%d").date()

metadata.roles.clear()
for role in try_get(series, 'roles', []):
Expand Down Expand Up @@ -243,10 +244,14 @@ def metadata_add(self, meta, images):
del meta[key]

def summary_sanitizer(summary):
summary = re.sub(LINK_REGEX, r'\1', summary) # Replace links
summary = re.sub(r'^(\*|--|~) .*', "", summary, flags=re.MULTILINE) # Remove the line if it starts with ('* ' / '-- ' / '~ ')
summary = re.sub(r'\n(Source|Note|Summary):.*', "", summary, flags=re.DOTALL) # Remove all lines after this is seen
summary = re.sub(r'\n\n+', r'\n\n', summary, flags=re.DOTALL) # Condense multiple empty lines
if Prefs["synposisCleanLinks"]:
summary = re.sub(LINK_REGEX, r'\1', summary) # Replace links
if Prefs["synposisCleanMiscLines"]:
summary = re.sub(r'^(\*|--|~) .*', "", summary, flags=re.MULTILINE) # Remove the line if it starts with ('* ' / '-- ' / '~ ')
if Prefs["synposisRemoveSummary"]:
summary = re.sub(r'\n(Source|Note|Summary):.*', "", summary, flags=re.DOTALL) # Remove all lines after this is seen
if Prefs["synposisCleanMultiEmptyLines"]:
summary = re.sub(r'\n\n+', r'\n\n', summary, flags=re.DOTALL) # Condense multiple empty lines
return summary.strip(" \n")

def try_get(arr, idx, default=""):
Expand Down
28 changes: 28 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,33 @@
"label": "Grab theme music the same way plex theme music would",
"type": "bool",
"default": true
},

{
"id": "synposisCleanLinks",
"label": "Synopsis: Remove links.",
"type": "bool",
"default": true
},

{
"id": "synposisCleanMiscLines",
"label": "Synopsis: Remove the line if it starts with ('* ' / '-- ' / '~ ').",
"type": "bool",
"default": true
},

{
"id": "synposisRemoveSummary",
"label": "Synopsis: Remove anything after Source, Note or Summary.",
"type": "bool",
"default": true
},

{
"id": "synposisCleanMultiEmptyLines",
"label": "Synopsis: Collapse excessive empty lines..",
"type": "bool",
"default": true
}
]

0 comments on commit c1fb229

Please sign in to comment.