Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: plex_update.sh - 19: Bad substitution - Ubuntu - Non-Docker #125

Open
LoadingStill opened this issue Oct 9, 2024 · 5 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@LoadingStill
Copy link

Expected Behavior
Describe what you expect to happen.
Click add to watch list on plex, the show adds.

Actual Behavior
Describe what is actually happening.

2024-10-09T03:43:04.409Z	INFO	manager	Detected changes! Refreshing 36 torrents
2024-10-09T03:43:05.486Z	DEBUG	realdebrid	Got info for torrent "SHOW" (progress=100%)
2024-10-09T03:43:05.488Z	DEBUG	manager	Saved torrent "SHOW" to file
2024-10-09T03:43:05.488Z	INFO	manager	Fetched info for 36 torrents
2024-10-09T03:43:05.489Z	INFO	manager	Compiled into 35 torrents, 0 were missing info
2024-10-09T03:43:05.489Z	INFO	manager	Finished refreshing torrents
2024-10-09T03:43:05.489Z	DEBUG	manager	Processing fixers (0 left: [])
2024-10-09T03:43:05.490Z	DEBUG	manager	Finished processing fixers
2024-10-09T03:43:06.472Z	ERROR	manager	Failed to execute hook on_library_update: error executing script: exit status 2; stderr: plex_update.sh: 19: Bad substitution

Detailed Steps
Detail out everything that you did leading up to the issue.
Include any relevant setup information that we should know about.

Watched the elfhosted youtube channel to figure out how to set up, as well a some reddit post.  I can watch everything on plex that is already in debird, but not new shows being added.
I had just set up plex, zurg, rclone.
The only part I do not have working is the add to watch list.

Operating System
What OS are you running? (e.g., Windows, macOS, Linux)
If on Windows, are you using Windows Subsystem for Linux (WSL)?
Ubuntu Server 24.04LTS

Environment Setup
Are you using Docker, or are you using Zurg's binary?
If Docker, please include your docker-compose.yml.
If Zurg's binary, specify the version by running ./zurg version

zurg
Built At: 2024-07-14T09:48:30
Commit: 4179c2745b4fb22fcb37f36de27b3daa39f114f0
Version: v0.9.3-final

Logs
Upload your logs by going to http://ZURGIP:9999/logs/upload and paste the link here

If you are running it in Docker, your container logs will also help.

Rclone Configuration
Attach or detail your rclone.conf.

[zurg]
type = webdav
url = http://localhost:9999/dav
vendor = other
pacer_min_sleep = 0

[zurghttp]
type = http
url = http://localhost:9999/http
no_head = false
no_slash = false

Zurg Configuration
Include your config.yaml or any other relevant configuration files.

zurg: v1
token: "TOKEN-1"
# host: "[::]"
# port: 9999
# username:
# password:
# proxy:
# concurrent_workers: 20
check_for_changes_every_secs: 10
repair_every_mins: 60
# ignore_renames: false
# retain_rd_torrent_name: false
# retain_folder_name_extension: false
enable_repair: true
auto_delete_rar_torrents: true
# api_timeout_secs: 15
# download_timeout_secs: 10
# enable_download_mount: false
# rate_limit_sleep_secs: 6
# retries_until_failed: 2
# network_buffer_size: 4194304 # 4MB
# serve_from_rclone: false
# verify_download_link: false
# force_ipv6: false
on_library_update: sh plex_update.sh "$@"
#on_library_update: /root/zurgfiles/plex_update.sh "$@" - I found this in a github issue and tested it, does not work file path not correct
#for windows comment the line above and uncomment the line below:
#on_library_update: '& powershell -ExecutionPolicy Bypass -File .\plex_update.ps1 --% "$args"'

directories:
  anime:
    group_order: 10
    group: media
    filters:
      - regex: /\b[a-fA-F0-9]{8}\b/
      - any_file_inside_regex: /\b[a-fA-F0-9]{8}\b/

  shows:
    group_order: 20
    group: media
    filters:
      - has_episodes: true

  movies:
    group_order: 30
    group: media
    only_show_the_biggest_file: true
    filters:
      - regex: /.*/

plex_update.sh

#!/bin/bash

# PLEX PARTIAL SCAN script or PLEX UPDATE script
# When zurg detects changes, it can trigger this script IF your config.yml contains
# on_library_update: sh plex_update.sh "$@"

# docker compose exec zurg apk add libxml2-utils
# sudo apt install libxml2-utils

plex_url="http://localhost:32400" # If you're using zurg inside a Docker container, by default it is 172.17.0.1:32400
token="TOKEN-2" # open Plex in a browser, open dev console and copy-paste this: window.localStorage.getItem("myPlexAccessToken")
zurg_mount="/data" # replace with your zurg mount path, ensure this is what Plex sees - media is in /data

# Get the list of section IDs
section_ids=$(curl -sLX GET "$plex_url/library/sections" -H "X-Plex-Token: $token" | xmllint --xpath "//Directory/@key" - | grep -o 'key="[^"]*"' | awk -F'"' '{print $2}')

for arg in "$@"
do
#    parsed_arg="${arg//\\}"
    parsed_arg=$(echo "$arg" | sed 's/\\//g')
    echo $parsed_arg
    modified_arg="$zurg_mount/$parsed_arg"
    echo "Detected update on: $arg"
    echo "Absolute path: $modified_arg"

    for section_id in $section_ids
    do
        echo "Section ID: $section_id"

        curl -G -H "X-Plex-Token: $token" --data-urlencode "path=$modified_arg" $plex_url/library/sections/$section_id/refresh
    done
done

echo "All updated sections refreshed"

# credits to godver3, wasabipls

Changing line 19 from
parsed_arg="${arg//\\}" to parsed_arg=$(echo "$arg" | sed 's/\\//g') allowed debridmediamanager to add content but not from plex just from https://debridmediamanager.com. I do not know what the new code means or why it workd that code was chatgpt and about 2 hours of testing and errors and reddit/github issues.

@LoadingStill LoadingStill added the bug Something isn't working label Oct 9, 2024
@shamanNS
Copy link

shamanNS commented Oct 9, 2024

@LoadingStill

Try changing this line in config.yml from:

on_library_update: sh plex_update.sh "$@"
to be:

on_library_update: bash plex_update.sh "$@"

@LoadingStill
Copy link
Author

changing the sh to bash and testing with the origional code and the code I tired both now show no output at all from plex add to watch list, no error no completed.
But I tested with debridmediamanager site and that still works.

So changing sh to bash removes the error but the logs do not show anthing is happening at all when I add to watch list.

@shamanNS
Copy link

shamanNS commented Oct 9, 2024

That scripts job is only to trigger a partial Plex library updates for a list of file paths zurg sends as newly added content, when new staff is added to your RD Cloud.

You keep mentioning Plex Watchlist, so someting other then zurg has to do that job (of adding stuff to RD Cloud based on new stuff added to Plex Watchlist).

If when you manually add stuff using debridmediamanager web page that stuff appears in your Plex library couple of seconds later then zurg and its 'plex_update.sh' script have done their job correctly. And that would mean that your problems are in some other part of your whole setup.

I had that "bad substitution" problem and fixed it the way I already stated (by replacing "sh" with "bash").

Can't help you further with using Plex Watchlist to populate Plex library with RD cached content since I never used plex_debrid nor Riven. I just search for stuff on DMM and add them from there.

@LoadingStill
Copy link
Author

Thank you for the reply.
I guess I misunderstood how the software works, thank you for clarifying.
I was under the impression by adding to plex watch list zurg would sycn that with plex and RD.

Thank you for the clarification.

@shamanNS
Copy link

shamanNS commented Oct 9, 2024

Nope, other program / scripts do that (like mentioned "plex_debrid" [now deprecated / unmaintained] or "Riven").

Zurg just monitors RD Library content, groups that chaos into categories (movie, show, music, anime..) needed for Plex and with the help from rclone "mounts" that into a folder/directory that you then add to your Plex server. When new stuff appears on RD Cloud zurg adds it into mounted folder and triggers a Plex scan using Plex's API. Zurg doesn't monitor Plex Watchlist.

So, you're missing one more part of the puzzle in order to achieve that goal of automating adding videos into Plex Library by adding shows/movies to Plex Watchlist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants