Merge pull request #196 from JonnyWong16/plex-scripts
Add Plex modifying metadata scripts
This commit is contained in:
commit
720dc4b7b4
22
utility/remove_movie_collections.py
Normal file
22
utility/remove_movie_collections.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Description: Removes ALL collections from ALL movies.
|
||||
# Author: /u/SwiftPanda16
|
||||
# Requires: plexapi
|
||||
|
||||
from plexapi.server import PlexServer
|
||||
|
||||
### EDIT SETTINGS ###
|
||||
|
||||
PLEX_URL = "http://localhost:32400"
|
||||
PLEX_TOKEN = "xxxxxxxxxx"
|
||||
MOVIE_LIBRARY_NAME = "Movies"
|
||||
|
||||
|
||||
## CODE BELOW ##
|
||||
|
||||
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
|
||||
|
||||
for movie in plex.library.section(MOVIE_LIBRARY_NAME).all():
|
||||
movie.removeCollection([c.tag for c in movie.collections])
|
52
utility/rename_seasons.py
Normal file
52
utility/rename_seasons.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Description: Rename season title for TV shows on Plex.
|
||||
# Author: /u/SwiftPanda16
|
||||
# Requires: plexapi
|
||||
|
||||
from plexapi.server import PlexServer
|
||||
|
||||
|
||||
### EDIT SETTINGS ###
|
||||
|
||||
PLEX_URL = "http://localhost:32400"
|
||||
PLEX_TOKEN = "xxxxxxxxxx"
|
||||
|
||||
TV_SHOW_LIBRARY = "TV Shows"
|
||||
TV_SHOW_NAME = "Sailor Moon"
|
||||
SEASON_MAPPINGS = {
|
||||
"Season 1": "Sailor Moon", # Season 1 will be renamed to Sailor Moon
|
||||
"Season 2": "Sailor Moon R", # Season 2 will be renamed to Sailor Moon R
|
||||
"Season 3": "Sailor Moon S", # etc.
|
||||
"Season 4": "Sailor Moon SuperS",
|
||||
"Season 5": "Sailor Moon Sailor Stars",
|
||||
"Bad Season Title": "", # Blank string "" to reset season title
|
||||
}
|
||||
|
||||
|
||||
## CODE BELOW ##
|
||||
|
||||
def main():
|
||||
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
|
||||
|
||||
show = plex.library.section(TV_SHOW_LIBRARY).get(TV_SHOW_NAME)
|
||||
print("Found TV show '{}' in the '{}' library on Plex.".format(TV_SHOW_NAME, TV_SHOW_LIBRARY))
|
||||
|
||||
for season in show.seasons():
|
||||
old_season_title = season.title
|
||||
new_season_title = SEASON_MAPPINGS.get(season.title)
|
||||
if new_season_title:
|
||||
season.edit(**{"title.value": new_season_title, "title.locked": 1})
|
||||
print("'{}' renamed to '{}'.".format(old_season_title, new_season_title))
|
||||
elif new_season_title == "":
|
||||
season.edit(**{"title.value": new_season_title, "title.locked": 0})
|
||||
print("'{}' reset to '{}'.".format(old_season_title, season.reload().title))
|
||||
else:
|
||||
print("No mapping for '{}'. Season not renamed.".format(old_season_title))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
print("Done.")
|
Loading…
Reference in New Issue
Block a user