Add option for summary prefix in hide_episode_spoilers.py
This commit is contained in:
parent
126f14bd3d
commit
8c6689796c
@ -19,6 +19,8 @@
|
|||||||
# --rating_key {rating_key} --image spoilers.png
|
# --rating_key {rating_key} --image spoilers.png
|
||||||
# To blur the episode artwork (optional blur in pixels):
|
# To blur the episode artwork (optional blur in pixels):
|
||||||
# --rating_key {rating_key} --blur 25
|
# --rating_key {rating_key} --blur 25
|
||||||
|
# To add a prefix to the summary:
|
||||||
|
# --rating_key --summary_prefix "** SPOILERS **"
|
||||||
# * Watched (optional):
|
# * Watched (optional):
|
||||||
# --rating_key {rating_key} --remove
|
# --rating_key {rating_key} --remove
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--rating_key', required=True, type=int)
|
parser.add_argument('--rating_key', required=True, type=int)
|
||||||
parser.add_argument('--image')
|
parser.add_argument('--image')
|
||||||
parser.add_argument('--blur', type=int, default=25)
|
parser.add_argument('--blur', type=int, default=25)
|
||||||
|
parser.add_argument('--summary_prefix')
|
||||||
parser.add_argument('--remove', action='store_true')
|
parser.add_argument('--remove', action='store_true')
|
||||||
opts = parser.parse_args()
|
opts = parser.parse_args()
|
||||||
|
|
||||||
@ -99,7 +102,10 @@ if __name__ == "__main__":
|
|||||||
# Delete the episode artwork image file
|
# Delete the episode artwork image file
|
||||||
os.remove(os.path.join(episode_folder, filename))
|
os.remove(os.path.join(episode_folder, filename))
|
||||||
|
|
||||||
elif opts.image:
|
episode.edit(**{'summary.locked': 0})
|
||||||
|
continue
|
||||||
|
|
||||||
|
if opts.image:
|
||||||
# File path to episode artwork using the same episode file name
|
# File path to episode artwork using the same episode file name
|
||||||
episode_artwork = os.path.splitext(episode_filepath)[0] + os.path.splitext(opts.image)[1]
|
episode_artwork = os.path.splitext(episode_filepath)[0] + os.path.splitext(opts.image)[1]
|
||||||
# Copy the image to the episode artwork
|
# Copy the image to the episode artwork
|
||||||
@ -115,5 +121,9 @@ if __name__ == "__main__":
|
|||||||
with open(episode_artwork, 'wb') as f:
|
with open(episode_artwork, 'wb') as f:
|
||||||
shutil.copyfileobj(blurred_artwork, f)
|
shutil.copyfileobj(blurred_artwork, f)
|
||||||
|
|
||||||
|
if opts.summary_prefix and not episode.summary.startswith(opts.summary_prefix):
|
||||||
|
# Use a zero-width space for blank lines
|
||||||
|
episode.edit(**{'summary.value': opts.summary_prefix + '\n\u200b\n' + episode.summary, 'summary.locked': 1})
|
||||||
|
|
||||||
# Refresh metadata for the episode
|
# Refresh metadata for the episode
|
||||||
episode.refresh()
|
episode.refresh()
|
||||||
|
Loading…
Reference in New Issue
Block a user