mirror of
https://github.com/blacktwin/JBOPS.git
synced 2025-12-11 19:37:18 +00:00
Merge 255c2ebb21 into 4580ca0bc6
This commit is contained in:
commit
54ea75c84a
@ -23,6 +23,8 @@
|
|||||||
# --rating_key {rating_key} --summary_prefix "** SPOILERS **"
|
# --rating_key {rating_key} --summary_prefix "** SPOILERS **"
|
||||||
# To upload the episode artwork instead of creating a local asset (optional, for when the script cannot access the media folder):
|
# To upload the episode artwork instead of creating a local asset (optional, for when the script cannot access the media folder):
|
||||||
# --rating_key {rating_key} --blur 25 --upload
|
# --rating_key {rating_key} --blur 25 --upload
|
||||||
|
# To replace episode title with "Aired %B %d, %Y (May 13, 2025) (optional, for shows where the title is a spoiler e.g. Jeopardy!)
|
||||||
|
# --hideTitle
|
||||||
# * Watched (optional):
|
# * Watched (optional):
|
||||||
# To remove the local asset episode artwork:
|
# To remove the local asset episode artwork:
|
||||||
# --rating_key {rating_key} --remove
|
# --rating_key {rating_key} --remove
|
||||||
@ -36,6 +38,7 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
import shutil
|
import shutil
|
||||||
from plexapi.server import PlexServer
|
from plexapi.server import PlexServer
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
PLEX_URL = ''
|
PLEX_URL = ''
|
||||||
PLEX_TOKEN = ''
|
PLEX_TOKEN = ''
|
||||||
@ -45,7 +48,7 @@ PLEX_URL = os.getenv('PLEX_URL', PLEX_URL)
|
|||||||
PLEX_TOKEN = os.getenv('PLEX_TOKEN', PLEX_TOKEN)
|
PLEX_TOKEN = os.getenv('PLEX_TOKEN', PLEX_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_prefix=None, remove=False, upload=False):
|
def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_prefix=None, remove=False, upload=False, hideTitle=False):
|
||||||
item = plex.fetchItem(rating_key)
|
item = plex.fetchItem(rating_key)
|
||||||
|
|
||||||
if item.type == 'show':
|
if item.type == 'show':
|
||||||
@ -76,8 +79,9 @@ def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_pref
|
|||||||
# 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))
|
||||||
|
|
||||||
# Unlock the summary so it will get updated on refresh
|
# Unlock the summary & title so they will get updated on refresh
|
||||||
episode.editSummary(episode.summary, locked=False)
|
episode.editSummary(episode.summary, locked=False)
|
||||||
|
episode.editTitle(episode.title, locked=False)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if image:
|
if image:
|
||||||
@ -115,7 +119,9 @@ def modify_episode_artwork(plex, rating_key, image=None, blur=None, summary_pref
|
|||||||
if summary_prefix and not episode.summary.startswith(summary_prefix):
|
if summary_prefix and not episode.summary.startswith(summary_prefix):
|
||||||
# Use a zero-width space (\u200b) for blank lines
|
# Use a zero-width space (\u200b) for blank lines
|
||||||
episode.editSummary(summary_prefix + '\n\u200b\n' + episode.summary)
|
episode.editSummary(summary_prefix + '\n\u200b\n' + episode.summary)
|
||||||
|
if hideTitle:
|
||||||
|
episode_title = episode.originallyAvailableAt.strftime("%B %d, %Y")
|
||||||
|
episode.editTitle('Aired ' + episode_title)
|
||||||
# Refresh metadata for the episode
|
# Refresh metadata for the episode
|
||||||
episode.refresh()
|
episode.refresh()
|
||||||
|
|
||||||
@ -128,6 +134,7 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument('--summary_prefix', nargs='?', const='** SPOILERS **')
|
parser.add_argument('--summary_prefix', nargs='?', const='** SPOILERS **')
|
||||||
parser.add_argument('--remove', action='store_true')
|
parser.add_argument('--remove', action='store_true')
|
||||||
parser.add_argument('--upload', action='store_true')
|
parser.add_argument('--upload', action='store_true')
|
||||||
|
parser.add_argument('--hideTitle', action='store_true')
|
||||||
opts = parser.parse_args()
|
opts = parser.parse_args()
|
||||||
|
|
||||||
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
|
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user