Comments (42)
So I've fixed a couple of things and also added a total execution time to the script.
The only minor issue is that to get some useful information in the unraid web interface I need to use a field that it gets then duplicated when sending it via the Agents (in my case Discord)
But otherwise it works.
I will likely continue to work on it tomorrow (well... today)
from plexcache.
I can add that, I will keep you posted!
from plexcache.
Yep, that did the trick. Now it works flawlessly! Thank you very much!
from plexcache.
Unfortunately is how unraid handles the formatting when forwarding the notification to discord.
One alternative is to have each result as unique message, but then it would not be a summary anymore.
So I have now modified in a way that it's more coherent, have a look at the new script (be aware of your settings).
from plexcache.
Apologies! It has been working fine so far but only now I noticed this mistake and actually started giving me the same error. It should be fixed now.
Regarding the onDeck media error, it seems to be an error with the token.
Try and re-run it, see if it still has the error, please send me the log. (Keep an eye for sensitive info)
from plexcache.
Great! Please let me know of any errors or anything you would like to be implemented
from plexcache.
Can the unraid ui notification
Finished moving files with 0 errors.
changed from a warning to a notice?
Done, just changed it, it was never meant to be a warning to be fair!
20 hours later still no errors. Looks like everything working ok. Does your script involve any measures to verify the file transfers complete without any file corruption?
I'm glad it is working fine!
The script doesn't implement any measure to verify the files, yet. It is a good idea and I will very likely add it.
I'm currently working on a rewrite of the whole script, separating each part so it will be easier to work on it, and one day might also expand the compatibility to jellyfin.
from plexcache.
I'm closing this because it has been implemented and no errors have been encountered so far.
from plexcache.
pip install requests and plexapi fixed it. Thanks again. Next time new issue?
from plexcache.
Probably some plugin or unraid update must have removed the necessary modules...something I will need to keep in mind...
pip install requests and plexapi fixed it. Thanks again. Next time new issue?
Yes please, I was wondering where was your message at first because when I went on 'issues' there was only one open, but I did receive an email notification of your message π
from plexcache.
How are you running the script? Directly on unraid or are you using Chronos?
I did read your message earlier and I've been trying to integrate the functionality as I like the idea! Problem is I'm having issues using the notify command from Chronos, but if the script is run directly on unraid then it's a different deal and should be ready, it just needs to be tested.
from plexcache.
Unraid through user scripts on a daily basis. I would gladly test it.
from plexcache.
Check the updated one, it should work, let me know.
https://github.com/bexem/PlexCache/blob/main/plexcache.py
Have a look at the variables inside, you will notice
notification = "unraid" # Unraid, Webhook or Both
unraid_level = "warning" # Set the desired logging level for the notifications. Leave empty for notifications only on ERROR. (Options: debug, info, warning, error, critical)
webhook_level = "" # Set the desired logging level for the notifications. Leave empty for notifications only on ERROR. (Options: debug, info, warning, error, critical)
webhook_url = "" # Your webhook URL, leave empty for no notifications.
webhook_headers = {} # Leave empty for Discord, otherwise edit it accordingly. (Slack example: "Content-Type": "application/json" "Authorization": "Bearer YOUR_SLACK_TOKEN" })
Let me know if it works for you
from plexcache.
Notification works great. But, notification_level "info" just throws out every cached item. Can there be a flag for like a summary? Like the script outputs?
Total size of media files to be moved to array: 3.37 GB
Free space on the array: 38.62 TB
Moving media to array...
Moving media files to array...
Finished moving files with 0 errors.
Editing file paths...
Total size of media files to be moved to cache: 12.67 GB
Free space on the cache: 801.39 GB
Moving media to cache...
Moving media files to cache...
Finished moving files with 0 errors.
Thank you for using bexem's script:
from plexcache.
Another thing: this is what the notification looks like:
from plexcache.
Done both (theoretically). https://github.com/bexem/PlexCache/blob/main/plexcache.py
The summary is still bare-bone but it's there.
Please let me know for any issues or further improvements.
from plexcache.
Discord notifications work very well.
Unraid WebUI notifications still the same. They should just reflect the status of the script anyway. Like worked with 0 Errors or something like that, right?
from plexcache.
I'm not doing "It works on my end" because I want to understand why it doesn't on yours and fix it, but this how it show on my unraid (6.12.3)
Try on a unraid terminal to execute this?
/usr/local/emhttp/webGui/scripts/notify -e "Test" -s "Test2" -m "Test3" -d "Test4" -i normal
The script basically runs the exact same command:
notify_cmd = f'{self.notify_cmd_base} -e "PlexCache: Summary" -s "{record.name}" -m "{record.msg}" -d "{record.msg}" -i "{icon}"'
with "notify_cmd_base":
self.notify_cmd_base = "/usr/local/emhttp/webGui/scripts/notify"
from plexcache.
the Webui:
discord
do you ever sleep? π
from plexcache.
I only work nights, I keep the schedule also during my days off. Although I'm about to go. π΄
So it works fine in your end too, but not when run by the script? That is just so odd, they are the same commands, I will need to investigate.
from plexcache.
Ok, let me now if you want anything else tested. Good night!
from plexcache.
I can't say if it is fixed because I can't seem to be able to replicate the same behaviour, but I've changed a couple of things, let me know if it's any better.
from plexcache.
I tested the script with the unraid console and it works there. However, no notifications are sent. Neither to discord nor to Unraid UI. Furthermore, I get the following error when I run the script (I assume it's still this one: https://github.com/bexem/PlexCache/blob/main/plexcache.py) via Unraid User Scripts:
Script location: /tmp/user.scripts/tmpScripts/Plex Cache/script
Note/tmp/user.scripts/tmpScripts/Plex Cache/script: line 2: import: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 3: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 4: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 5: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 6: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 7: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 8: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 9: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 10: from: command not found
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 12: syntax error near unexpected token `"*** PlexCache ***"'
/tmp/user.scripts/tmpScripts/Plex Cache/script: line 12: `print("*** PlexCache ***")'
from plexcache.
I tested the script with the unraid console and it works there. However, no notifications are sent. Neither to discord nor to Unraid UI. Furthermore, I get the following error when I run the script (I assume it's still this one: https://github.com/bexem/PlexCache/blob/main/plexcache.py) via Unraid User Scripts:
Script location: /tmp/user.scripts/tmpScripts/Plex Cache/script Note/tmp/user.scripts/tmpScripts/Plex Cache/script: line 2: import: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 3: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 4: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 5: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 6: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 7: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 8: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 9: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 10: from: command not found /tmp/user.scripts/tmpScripts/Plex Cache/script: line 12: syntax error near unexpected token `"*** PlexCache ***"' /tmp/user.scripts/tmpScripts/Plex Cache/script: line 12: `print("*** PlexCache ***")'
How are you trying to execute it in Unraid user Scripts?
from plexcache.
add the script as user script and press the run script button.
from plexcache.
Uhm no, you need to execute the python scrpt from a script in user script.
See https://github.com/bexem/PlexCache/wiki/UserScripts#option-2-user-scripts-plugin
from plexcache.
Oh, yeah, ofc, that makes so much more sense...
from plexcache.
Yeah I know...As far as I know, user script can only run bash/sh scripts, but my project is done with python, so it needs to run through User Script rather than by User Script π
from plexcache.
ok that makes more sense of course. However, the notifications still don't work. Neither Discord nor WebUI
from plexcache.
Can you show me how you have the script set?
from plexcache.
uhh...oh..i have to confess... i haven't set webhooks up.
from plexcache.
Ok. Now it's working. WebUi works great. But Discords notifications gets send twice.
from plexcache.
Set
Notification = "unraid"
or
Notification = "system"
The webhook is useful if you are running it on a system that doesn't use the same 'notify' service or for example, in Chronos as it cannot easily access and run the host executables.
from plexcache.
maybe a tiny little detail, but could the discord summary be formatted so each entry gets its own line?
this looks so clean and neat
this, not so much
I know its nitpicking....π
from plexcache.
It's beautiful! Thank you so much!
from plexcache.
Hi, me again. I really thought everything would be perfect with your script. Unfortunately, I get the following error messages via email:
Event: PlexCache
Subject: CRITICAL
Description: Error checking free space and moving media files to the array: name 'summary_message' is not defined
Importance: alert
Event: PlexCache
Subject: ERROR
Description: Error: Failed to Fetch one-of-my-users-username onDeck media. Error: (401) unauthorized; http://plex.ip.adress/ <html><head><script>window.location = window.location.href.match(/(^.+\/)[^\/]*$/)[1] + 'web/index.html';</script><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
Importance: alert
and last but not least:
Event: PlexCache
Subject: ERROR
Description: Failed to get access token for %s
Importance: alert
from plexcache.
No Apologies needed! You doing great work. The script works so far without any errors. I ran it several times without any errors and will report back if any errors occur.
from plexcache.
20 hours later still no errors. Looks like everything working ok. Does your script involve any measures to verify the file transfers complete without any file corruption?
from plexcache.
Can the unraid ui notification Finished moving files with 0 errors.
changed from a warning to a notice?
from plexcache.
Hello, I wasn't sure if I should create a new ticket or just attach my problem here... I was wondering why I didn't get any more notifications and ran the script via console today. I get the following error:
File "/mnt/user/appdata/plexcache/plexcache.py", line 1, in
import os, json, logging, glob, socket, platform, shutil, ntpath, posixpath, re, requests, subprocess, time
ModuleNotFoundError: No module named 'requests'
from plexcache.
Have you tried installing the module again?
pip install requests
from plexcache.
A reboot apparently removes the modules. Keep it in mind.
I will probably will add a script to run a system reboot to install the necessary modules in the instruction, until a better solution comes up in my mind!
from plexcache.
Related Issues (15)
- Allow user to define which Sections to process
- Setup.py "no such file exists in directory" HOT 39
- Feeling dumb... HOT 91
- FileNotFoundError HOT 5
- Error: [Errno 2] No such file or directory. Files exist can touch and ls. HOT 47
- Conflict with Mover/Mover Tuning HOT 10
- Monitor "Now playing" and move to cache? HOT 6
- Some Watchlist "Problems" HOT 63
- Looking for Clarification regarding use in Ubuntu HOT 18
- Error moving file HOT 6
- First run not working properly, 2nd run will not run due to not enough size HOT 1
- OnDeck read error.
- Run in a container / as a plug in?
- /mnt/user/system/./locatefileinarray.sh: No such file or directory HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plexcache.