-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Looking for Clarification regarding use in Ubuntu #22
Comments
Hi there to you too!
Yes, exactly, you got it right.
You would need to do that (map the cache drive to the container) and yes that would happen but then it would spin down as it would not be actively used anymore because plex would then read the file from the cache drive (in theory).
I would not know how plex would "prefer" the file in the ssd, would it not need like two libraries? Like the script would keep that FastMovies and FastTVSeries libraries up-to-date keeping in the just the ondeck/watchlist files? But it would get confusing on the clients as they would have duplicated media on the homepage (An OnDeck version of the episode of the slow library and another for the fast one) I am fully open to suggestions as I like to improve the code and help and include other users, but unraid is the only system I actively support as is the one I use. |
Plex has this multiple editions/versions/etc. feature , which should be able to make this idea work without extra library confusion: One library, three folders to search for content. I copypasted the same moviefolder to all three, didn't change or rename anything. Plex understands that it's the same movie and merges it. I also tried the same thing with a show (without tmdbid) and it works too. For whole shows, seasons, episodes:
The trickier part was finding out how plex decides what to play first. I'll assume that the uppermost version is the one that`ll be played first, when pressing the play button, without choosing a version (still have to actually confirm via iotop for example, that my assumption is watertight, will do when I've the time). btw: "Play Version" a new button that pops up after multipling the files this way. After playing around a bit (renaming files, adding libraryfolders/files in different sequences, copying movies to empty libraryfolder, etc.). I found out that the order isn't alphabetically and so far it seems most likely that plex chooses to play the version of the file, that was first discovered by it. So for example folder a is empty, folder b is empty -> put movie in folder b, copy movie to folder a => version in folder b will always be played first, no matter the alphabetical order. There are still some things I could try this way, but none seem useful in the context of: copy the, as from plex as identical recognized, movie to cache and play from there first. But yeah, it should work in theory, which would make it possible to let the hdd sleep and also avoid the move to cache and then move back to hdd and rescan/redo preview thumbnails stuff. There ought to be a possibility to rename the files for playorder (when directly pressing play without choosing the version), maybe even a "set priority-libraryfolder"-option from within plex or via plexapi, maybe a modified media scanner but I haven't seen anything at the first few glances. I'll look further when I have the time. |
That's great! I have no idea if it works properly, let me know, if it does, we can work on it! Forgot to say: you do need to manually create a version of the media (I don't know if just a duplicate is enough or you also need to rename it slightly). The script right now does no file manipulation. |
Wow thanks! Okay, this is what I got so far:
just fyi: I have a separate mirrored library in a different language which doesn't have the cachepath as a folder. Seems like that contributes to the error? |
Thank you for trying, oddly it was giving an error but apparently the versioning of the media is actually not (hopefully yet), I'm now having a look at the whole plexapi documentation, I honestly thought it was there but I was clearly very wrong. |
I'm sure that there will be a way, I will definitely check out plexapi myself tomorrow (already past midnight here). Plexforums/tagging/plexmatch or similiar from vanillaplex led to nothing. But so far I could confirm via iotop that the uppermost file is played by default. So there's definitely at least this hacky manual plexdance I found out that could be scripted:
Thanks again, I'll keep you posted too! |
Uhm...So the script would need to:
*And what about the tv series/anime? It would break all the other episodes if we rename the whole Show folder and/or the Season folder. I understand is temporary, so it might actually be fine. I had a look at the plexapi documentation again and I see no trace of setting the favourite version or edition, but I hope I'm just blind 😅 |
the "-" is random. Will answer in more detail tomorrow, seriously tired. I found that after doing this "plexdance" the Media ids of the duplicate files are changin (look at episode -> media info> view xml). first the default played, uppermost file ( the one on the hdd) had Media id="545138" and the file on the cache <Media id="545226". After the dance the cachefile had same id but the file on hdd was <Media id="545250". Notice the number increase. Pretty sure that's what actually corresponds to the default play order (If everything else is the same). Maybe it's possible to "reindex" those specific files and force the change of defaultplay that way?
from what I've seen, I can still continue from where I paused before the whole plexdance 🤷♂️ even tried vinland saga But yeah, have to sleep, dying, will write again tomorrow |
Haven't found a way via plexapi so far but I can confirm that everything works out reproducibly, for single files (maybe as precaution instead of whole folder?) without breaking anything when:
so yeah, for a first working prototype script and without a more elegant solution in sight right now, that seems to be it. I think that plex has some awareness and special handling of minimal changes to filenames. The small "back and forth" thing seems necessary to break things only "a little bit" without breaking them fully |
I've asked a little bit with chatgpt, haven't tested yet but will test and confirm later. It aims to do the "copy to cache rerename dance" for all users. Just writing now mainly because I don't know if I have the time later. Maybe it helps or you can already see problems with this if you're interested:
|
maybe this ?
|
Oh wow, that was a journey! |
I kinda got carried away trying to get a full script running with help from chatgpt. But I'm stuck. I'll try to show you. It should offer crontab support and notifications via apprise
There's an interactive setup.py that produces a config.py:
the resulting config.py looks like this:
and this is the plex_cache_script.py that uses the config.py:
There are currently two problems, I could identify so far: second, the Yeah, I'm currently out of my depth on this. Need to understand a lot more first. But I hope that this can help you in some way, for a proper solution 😅👍 I'll be trying again tomorrow. I really should've started with the basics first |
You've done a lot! I was expecting you to try and implement your logic into my script so that you had most of the work done. But either way I might have noticed when the problem is with the function build_target_path, the function was stripping away the source prefix entirely, leaving just the relative path of the file, and then it was joining this with TARGET_MOUNT. It didn't account for retaining the test1 or test2 directory, which led to the omission in the target path.
About time.sleep(10), you are not using any multithreading so it definitely should work. But I noticed in the plexapi documentation you can check if a library is currently refreshing, you could use that to wait the right time before proceeding:
|
I mean, have you seen your 1383 lines script?😄 It's kinda overwhelming for a low-level script noob. I just hope that I get at least something to work, then I'll look into that whole integrating thing So I modified my wonky script with your suggestions and the files in question get copied to |
Ahahah fair point!! It used to be a short and simple script, now I get lost every time I don't look at it for a couple of days!
Instead of refreshing the whole library, might be worth ask plex to check for changes just in the path, might shave some time off, if it actually work as apparently is not??
|
Got it to work! Just a super simple static script focused on the rename-scan-dance to change the order. The trick was 10 sec sleeping directly after rename, but before scanning. For good measure the same thing with sleep after renaming back to original. Assumption is that the files have already been duplicated: one in cache, one in hdd. The files getting the rename-scan-dance will always be positioned last. Tested it on a movie library and also with tv shows: config.py
plex_rename_scan.py
Ondeck/continue works. Tested a few different scenarios and only thing I noticed: when the cache media is in first position and the file is deleted (which for example reflects the case, when media has already been seen and cache can be freed) , the media will be marked as unavailable even the other version can be chosen and played. The library need to be rescanned and trash needs to be emptied, but it didn't update as fast as I would have wished, took a few tries to completly loose the cache path and have the hdd file being the only one. Plex seems to have some preventative measure for drive disconnects or media corruption that might play into this. Another solution for this might be a reverse rename-scan-dance where the files in the cache get this treatment before being deleted to make space for new files to be cached. I'll be looking further, it may also make sense to exclude the files instead of renaming. You know for the first step when moving files to cache just to be absolutely sure, that it get's played from cache. Also metafiles like theme.mp3, may need the same treatment to guarantee that plex doesn't wake the hdd (Have seen that you thought about subtitles too). |
@Deathproof76 I wonder if you settled on what you wrote last, or if you tried other things (like plexignore)? Kind of wanted to do the same (prefer files on cache instead of array) and noticed all the same problems you did (Plex only cares about the order of discovery of media and so on). |
Hello and thank you for your work on PlexCache and also the wiki! I would love to use it, but I still have some questions regarding its setup outside of unraid.
I'm using Ubuntu without bcache or similar things , just straight up ext4 formatted drives and plex in docker and for example:
I have an empty ext4 formatted ssd and a hdd where the media folder for my plex docker is mounted to. I tell the symlink version of the script that the cache folder is on the sdd. What happens if I start the script? Will the specified movies/shows be moved to the cachefolder on the ssd and in their place on the hdd there'll only be a symlink left? So that means I would have to mount the cache folder in the container too. Won't the hdd be woken up anyways when the symlink is accessed by plex?
Just an Idea, which I will look up later: Can't the files simply be copied to the ssd whilst also remaining on the hdd and renamed in such a way that plex prefers the file on the ssd?
The text was updated successfully, but these errors were encountered: