Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ inputs:
description: Accept Plex's EULA.
default: "false"
required: false
additional_server_queries_put:
additional_server_queries:
description: >-
Space separated list of additional PUT requests to send to the server. The requests are sent before the
library sections are created. You can use this to enable third party metadata agents, as an example.
e.g. `/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>`
Space separated list of additional requests to send to the server. The type of request should be at the beginning
of the endpoint, followed by a `|`. If no `|` is found the default request type of `PUT` will be used.
The requests are sent before the library sections are created.
You can use this to enable third party metadata agents, as an example.
e.g. `put|/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>`
default: ""
required: false
bootstrap_timeout:
Expand Down Expand Up @@ -325,9 +327,9 @@ runs:
if [[ "${{ inputs.accept_eula }}" == "true" ]]; then
accept_eula="--accept-eula"
fi
if [[ -n "${{ inputs.additional_server_queries_put }}" ]]; then
echo "additional_server_queries_put: ${{ inputs.additional_server_queries_put }}"
server_queries_put="--additional-server-queries-put ${{ inputs.additional_server_queries_put }}"
if [[ -n "${{ inputs.additional_server_queries }}" ]]; then
echo "additional_server_queries: ${{ inputs.additional_server_queries }}"
server_queries_put="--additional-server-queries ${{ inputs.additional_server_queries }}"
fi
if [[ "${{ inputs.use_docker }}" == "false" ]]; then
use_docker="--no-docker"
Expand Down
10 changes: 6 additions & 4 deletions docs/source/about/github_action.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Inputs
- Accept Plex's EULA.
- ``false``
- false
* - ``additional_server_queries_put``
- Space separated list of additional PUT requests to send to the server. The requests are sent before the
library sections are created. You can use this to enable third party metadata agents, as an example.
e.g. `/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>`
* - ``additional_server_queries``
- Space separated list of additional requests to send to the server. The type of request should be at the beginning
of the endpoint, followed by a `|`. If no `|` is found the default request type of `PUT` will be used.
The requests are sent before the library sections are created.
You can use this to enable third party metadata agents, as an example.
e.g. `put|/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>`
- ``""``
- false
* - ``bootstrap_timeout``
Expand Down
63 changes: 52 additions & 11 deletions scripts/plex_bootstraptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,14 @@ def alert_callback(data):
"--accept-eula", help="Accept Plex's EULA", default=False, action="store_true"
) # noqa
parser.add_argument(
"--additional-server-queries-put",
help="Comma separated list of additional PUT requests to send to the server. The requests are sent before the "
"library sections are created. You can use this to enable third party metadata agents, as an example. "
"e.g. `/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>`",
"--additional-server-queries",
help="Space separated list of additional requests to send to the server. The type of request should be at the "
"beginning of the endpoint, followed by a `|`. "
"If no `|` is found the default request type of `PUT` will be used. "
"The requests are sent before the library sections are created. "
"You can use this to enable third party metadata agents, as an example. "
"e.g. "
"`put|/system/agents/com.plexapp.agents.imdb/config/1?order=com.plexapp.agents.imdb%2C<my_movie_agent>` ",
default=[],
nargs='*',
) # noqa
Expand Down Expand Up @@ -734,13 +738,50 @@ def alert_callback(data):
)

# send additional server queries
if opts.additional_server_queries_put:
print("Sending additional PUT requests to the server")
print("Additional PUT requests: {}".format(opts.additional_server_queries_put))
for query in opts.additional_server_queries_put:
query = query.strip()
print("Sending PUT request to {}".format(query))
server.query(key=query, method=server._session.put)
if opts.additional_server_queries:
request_map = {
"delete": server._session.delete,
"get": server._session.get,
"post": server._session.post,
"put": server._session.put,
}

print("Sending additional requests to the server")
print("Additional requests: {}".format(opts.additional_server_queries))

completed_queries = []
start = time.time()
runtime = 0
while runtime < 60 and len(completed_queries) < len(opts.additional_server_queries):
for query in opts.additional_server_queries:
query = query.strip()
if query not in completed_queries:
if '|' in query:
method, key = query.split('|')
method = method.strip()
key = key.strip()
else:
method = 'put'
key = query.strip()

if method not in request_map:
raise SystemExit("Invalid method specified: {}".format(method))
if not key.startswith('/'):
raise SystemExit("Invalid key specified: {}".format(key))
print("Sending {} request to {}".format(method, key))
try:
server.query(key=key, method=request_map[method])
except NotFound as err:
# if 404, wait
print("error: {}".format(err))
time.sleep(5)
else:
completed_queries.append(query)
finally:
runtime = time.time() - start

if len(completed_queries) < len(opts.additional_server_queries):
raise SystemExit("Did not successfully complete all additional server queries")

# Create the Plex library in our instance
if sections:
Expand Down