Closed eqpaisley closed 7 years ago
So I end up with a .ts file even after creating an .mkv file. Is this intentional?
Sort of... I wasn't actually sure if Plex needs the filename to be the same after processing (i.e. it moves it to a Show/Season folder afterwards). The script could be tweaked to rename to an .mkv file as long as Plex doesn't care.
Also, I'm having some permissions issues, is there a way to make sure the script runs as super-user?
You might want to follow this guide when setting permissions on your plex server. Make sure your media library (the root folder of the library and all folders underneath) are writable by the Plex user/group. Make sure your script is executable by that group too. I broadly have persmissions set to 777 in the installation instructions, but you could limit that to 755 and make sure that Plex is in the group that has access to execute.
Hope this helps!
BTW - I did a bit of poking around on my side and it appears that Plex passes a temporary path to the script (i.e. /path-to-media-library/.grab/
I have never worked in linux or bash before but I got brave and made some changes to the script that are working perfectly.
HandBrakeCLI -i "$FILENAME" -f mp4 --aencoder copy -e qsv_h264 --x264-preset veryfast --x264-profile auto -q 30 --maxHeight 720 --decomb bob -o "$TEMPFILENAME"
Because I want mp4 files of lower quality (well, I don't want lower quality but I do want small files). And:
mv -f "$TEMPFILENAME" "${FILENAME%.ts}.mp4"
Which properly names my files as MP4. Plex sees and recognizes them just fine.
I still have a problem, however, but it's nothing to do with your script. Plex creates folders for new shows and the permissions of the parent folder (777) do not pass through. So I cannot access the newly created folders over my win10 samba connections (well I can access them but I cannot delete from them). Is it possible to add some kind of line in this script that changes permissions? Could I add a chmod -R 777 to the top of the file to blanket change all folders and subfolders.
Oh cool! So that must mean that even though we rename the file, Plex is smart enough to move it to the correct place anyway. Good to know!
And as for the script running the CHMOD command - it's probably not going to work well. This is territory I'm not too familiar with myself, but from what I understand there are ways to have files inherit the permissions of the directory. Check this out: https://superuser.com/questions/151911/how-to-make-new-file-permission-inherit-from-the-parent-directory
Is it possible to run a chmod command from within a bash script? Can I just make an early line in the script
chmod -R 777 /plexmedia/myvideos
I know - from using it on the command line - that this command workds to fix newly created folder permissions. It changes /plexmedia/myvideos and ALL folders within to full read, write, execute. My question is - though it's brute force approach - can this be added to a bash script?
My understanding is that if the Plex user is running the script, it would only have permissions granted to that user. So if the directories and files in question were created and are owned by the Plex user/group then I suspect that the script could run the chmod command to adjust permissions. The problem may be that if the directory is created by Plex after the script runs, it might not be able to affect that directory.
Great script, thank you. It seems that the filename contains the same extension, even after conversion. So I end up with a .ts file even after creating an .mkv file. Is this intentional?
Also, I'm having some permissions issues, is there a way to make sure the script runs as super-user?