plex_api_helper¶
-
Code.plex_api_helper.
add_media
(item, media_type, media_url_id, media_file=None, media_url=None)[source]¶ Apply media to the specified item.
Adds theme song to the item specified by the
rating_key
. If the same theme song is already present, it will be skipped.Parameters: Returns: py
bool
True if the media was added successfully or already present, False otherwise.
Examples
>>> add_media(item=..., media_type='themes', media_url_id=..., media_url=...) >>> add_media(item=..., media_type='themes', media_url_url=..., media_file=...)
-
Code.plex_api_helper.
change_lock_status
(item, field, lock=False)[source]¶ Change the lock status of the specified field.
Parameters: Returns: py
bool
True if the lock status matches the requested lock status, False otherwise.
Examples
>>> change_lock_status(item=..., field='theme', lock=False)
-
Code.plex_api_helper.
get_database_info
(item)[source]¶ Get the database info for the specified item.
Get the
database_type
,database
,agent
,database_id
which can be used to locate the theme song in ThemerrDB.Parameters: - item :
PlexPartialObject
The Plex item to get the database info for.
Returns: Examples
>>> get_database_info(item=...)
- item :
-
Code.plex_api_helper.
get_plex_item
(rating_key)[source]¶ Get any item from the Plex Server.
This function is used to get an item from the Plex Server. It can then be used to get the metadata for the item.
Parameters: - rating_key :
int
The
rating_key
of the item to get.
Returns: PlexPartialObject
The Plex item from the Plex Server.
Examples
>>> get_plex_item(rating_key=1) ...
- rating_key :
-
Code.plex_api_helper.
plex_listener
()[source]¶ Listen for events from Plex server.
Send events to
plex_listener_handler
and errors toLog.Error
.Examples
>>> plex_listener() ...
-
Code.plex_api_helper.
plex_listener_handler
(data)[source]¶ Process events from
plex_listener()
.Check if we need to add an item to the queue. This is used to automatically add themes to items from the new Plex Movie agent, since metadata agents cannot extend it.
Parameters: - data :
dict
Data received from the Plex server.
Examples
>>> plex_listener_handler(data={'type': 'timeline'}) ...
- data :
-
Code.plex_api_helper.
process_queue
()[source]¶ Add items to the queue.
This is an endless loop to add items to the queue.
Examples
>>> process_queue() ...
-
Code.plex_api_helper.
scheduled_update
()[source]¶ Update all items in the Plex Server.
This is used to update all items in the Plex Server. It is called from a scheduled task.
See also
scheduled_tasks.setup_scheduling
- The method where the scheduled task is configurerd.
scheduled_tasks.schedule_loop
- The method that runs the pending scheduled tasks.
Examples
>>> scheduled_update()
-
Code.plex_api_helper.
setup_plexapi
()[source]¶ Create the Plex server object.
It is required to use PlexAPI in order to add theme music to movies, as the built-in methods for metadata agents do not work for movies. This method creates the server object.
Returns: PlexServer
The PlexServer object.
Examples
>>> setup_plexapi() ...
-
Code.plex_api_helper.
start_queue_threads
()[source]¶ Start queue threads.
Start the queue threads based on the number of threads set in the preferences.
Examples
>>> start_queue_threads() ...
-
Code.plex_api_helper.
update_plex_item
(rating_key)[source]¶ Automated update of Plex item using only the rating key.
Given the rating key, this function will automatically handle collecting the required information to update the theme song, and any other metadata.
Parameters: - rating_key :
int
The rating key of the item to be updated.
Returns: py
bool
True if the item was updated successfully, False otherwise.
Examples
>>> update_plex_item(rating_key=12345)
- rating_key :
-
Code.plex_api_helper.
upload_media
(item, method, filepath=None, url=None)[source]¶ Upload media to the specified item.
Uploads art, poster, or theme to the item specified by the
item
.Parameters: Returns: py
bool
True if the theme was uploaded successfully, False otherwise.
Examples
>>> upload_media(item=..., method=item.uploadArt, url=...) >>> upload_media(item=..., method=item.uploadPoster, url=...) >>> upload_media(item=..., method=item.uploadTheme, url=...) ...