Skip to content

Commit

Permalink
Actually fixed the optimize call to PlexAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Casvt committed Jul 15, 2024
1 parent 00dbc5a commit d03d7f9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions media_versions/auto_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@
plex_api_token = getenv('plex_api_token', plex_api_token)
base_url = plex_base_url.rstrip('/')

profile_to_id = {
'Mobile': 1,
'TV': 2,
'Original Quality': 3
}
profiles = ("mobile", "tv", "original")


@dataclass
Expand Down Expand Up @@ -245,7 +241,7 @@ def auto_optimize(
result_json = []
counter = 0

if profile not in profile_to_id:
if profile not in profiles:
raise ValueError("Invalid profile")

for media in _get_library_entries(ssn, library_filter):
Expand All @@ -263,7 +259,7 @@ def auto_optimize(

plex.fetchItem(int(media['ratingKey'])).optimize(
locationID=-1,
targetTagID=profile_to_id[profile]
target=profile
)
result_json.append(media['ratingKey'])
counter += 1
Expand All @@ -285,7 +281,7 @@ def auto_optimize(
# Setup arg parsing
# autopep8: off
parser = ArgumentParser(description="Optimize the targeted media if it isn't already.")
parser.add_argument('-P', '--Profile', type=str, choices=list(profile_to_id.keys()), required=True, help="The optimization profile")
parser.add_argument('-P', '--Profile', type=str, choices=profiles, required=True, help="The optimization profile")
parser.add_argument('-L', '--Limit', type=int, default=-1, help="Maximum amount of media that the script is allowed to send to the queue")

ts = parser.add_argument_group(title="Target Selectors")
Expand Down

0 comments on commit d03d7f9

Please sign in to comment.