Created
February 22, 2019 08:01
-
-
Save pjobson/9902177ef6db698a82c7e680d9eabcaf to your computer and use it in GitHub Desktop.
Generates the PLEX "Cinema Trailers pre-roll video" String from a Specified Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# YOUR PREROLL PATH | |
PREROLLPATH="/path/to/your/prerolls/" | |
# YOUR TOKEN | |
PLEXTOKEN="XXXXXXXXXXXXXXXXXXXX" | |
# FIND IN THIS PATH FOR FILES | |
IFS=$'\n' LIST=( $(find ${PREROLLPATH} -type f) ) | |
# INITIALIZE AN ARRAY WITH CURL INFO | |
CURLARR=(curl -X PUT) | |
# INITIALIZE THE HREF | |
CURLHREF='http://localhost:32400/:/prefs?CinemaTrailersPrerollID=' | |
# LOOP THE FILES IN THE ARRAY | |
for i in "${!LIST[@]}"; do | |
# SWAP SPACES WITH %20 (URL ENCODE) | |
PREROLL=${LIST[$i]// /%20} | |
# APPEND TO THE CURLHREF | |
CURLHREF+=$PREROLL | |
# IF NOT THE LAST ELEMENT, ADD ; TO CURLHREF | |
if [ "$(($i + 1))" != "${#LIST[@]}" ]; then | |
CURLHREF+=";"; | |
fi | |
done | |
# APPEND THE CURLHREF TO CURLARR | |
CURLARR+=(${CURLHREF}) | |
# APPEND HEADER SPECIFICATION | |
CURLARR+=(-H) | |
# APPEND TOKEN HEADER | |
CURLARR+=(X-Plex-Token:${PLEXTOKEN}) | |
${CURLARR[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment