Webtool, Subtitle Manager (Development)

Hello everyone

 

I have made a PHP site that connects to the plex web api, locally stored on your pc. It lists all subtitles that you have and lets you delete those that are not integrated in a video file.

 

The point with this was to make it easy to see what automatically downloaded subtitle belongs to what video file. It also shows the locally stored subtitles so you can see what you have.

 

Please give me some feedback on this.

 

System requirements:

A webserver that is configured to run PHP.

DevTools (Made by dane22) version >0.0.0.8. Available in The Unsupported Appstore or in the forum thread

 

Installation:

  1. Download the Zip-file and unpack it in your web directory
  2. Modify "settings.php" and change:
    1. $DevToolsSecret to the same you've set when installing DevTools.
    2. $Server to point to your PMS server. If it's running on the same as your webserver, then you don't need to change this.
  3. Enjoy

Recommended way of usage:

  1. Remove the subtitles you want via this script.
  2. Use the new button added in 0.5.4 to let the script to the refresh of Plex for you.

Changelog

Updated post with version 0.5.4

A few things have happened since the last update:

  • Requirements of DevTools changed to 0.0.0.8
  • Added link to let user force refresh the section from the tool. Visible next to the page numbers.
  • Changed the "recommended way of usage"
  • Added an auto select for duplicate subtitles from opensubtitle agent.
  • Fixed a bug with "Show only multiple/language"

 

Updated post with version 0.5.1

Added Select / Deselect all to subtitlelists.
Changed requirements to DevTools v0.0.0.6 after implementing ShowSRT function that uses DevTools to read the file.
Removed "ListDir.php" as it's not needed anymore.
Modified "ReadFile.php" to fetch the file to be viewed from DevTools instead of accessing it directly to make it work on linux etc.
 
V0.5.0
Moved away from features that required PHP to have access to other places on your harddrive.
These features are handled by DevTools from now on. (Deletion of files, file exists)
Currently requires DevTools v.0.0.0.5 made by Dane22 on the Plex Forums
Modified the settings.php do reflect this change. Now only contains 3 settings that a user should fiddle with.
Continued in making the presentation better.
Improved the logging and presentation of the same.

 

Updated post with version 0.4.2

Changes:

Corrected the error with "localhost".

 

Updated post with version 0.4.1

Changes:

Added some logging.

Can be forced by changing Debug to true in Settings.php. This is a very basic and much information log so don't use it unless you have to.

Also, the $Server variable needs to be ip-adress. I've noticed a massive performance hit when using dns name, even localhost. So use ip-adress.

 

Updated post with version 0.4

Changes:

- Moved away from databaseaccess and is now fully using the webapi.

- I recommend using https://forums.plex.tv/topic/121506-rel-devtools/ as that allows the script to automatically detect the path to Plex Media Server/Media/Localhost.

- If you select a subtitle in the Plex.tv/web interface, it will be marked as such when displayed in the script as can be seen on the screenshot.

- When you delete a subtitle, Plex is not updated automatically. The script will however notice that the subtitle isn't there anymore and mark the row accordingly.

- The search feature is now working properly.

- The interface has had a facelift.

- Added some more options to control output.

- The pagesystem is now working as intended and reacts to options and search results.

As usual, i've tested it but report if you find anything wrong or have suggestions for improvements.

Massive thanks to dane22 for help with finding subtitles/hashes and for hinting me about devtools.

 

 

Moved to GitHub:

https://github.com/dagalufh/PlexUSM

Looks cool, I will try it out first thing tomorrow!

Does it delete only locally stored subtitles? or also subtitles fetched by the agent?

I have a problem clearing out subtitles fetched by the agent from the database, and yours would do a big favor if it cleans it! (I have too many duplicate subtitles downloaded for some shows).

Yeah thats the exact problem i'm hoping to bring a solution to. It lists the subtitles of both agents and local and allows easy removal of those. But you need to disable the agents and to a rescan of metadata after removal since Plex still thinks they are there otherwise. Glad you want to try it out :)

Awesome! Will provide you feedback once I try it!

I tried it, it does the job well so far!

Though it needs a lot of tweaking, the management experience is extremely difficult for large libraries of TV Shows or even Movies.

I suggest either going for the following:

- Browser Addon, to manage the subtitle within the opened metadata file of an episode/movie in Plex/Web.

- Styling the script to imitate something close to a Plex/Web Experience.

- Adding search functions or features to find only media files with duplicate subtitles (ex, more than 1x sub for each enabled language  "en" "ar" "de"... etc).

Nice to hear it’s working. I already had an idea for a search function. I’ll try to fix it soon. And for the ability to only show entries with >1 srt/language was a great idea. I’ll fix that at the same time and try to post an update in a day or so. Depending on how the kids behave at eavning/night. :slight_smile:


Summary:

  • Will add ability to search for movie/tv by title.
  • Will add ability to only show videos with more than one subtitle.
  • Will add option to completly hide those without subtitles.
  • Will look into appearence and such to look like Plex or something… Ideas welcome!

I've updated the main post with version 0.2. A bunch of changes. :) Please test it out and give me your feedback. :)

Hi,

If I understand well, it works only for Windows PMS server and it needs to run locally. Am I right?

Thanks.

Hi radar

I think it would work under linux or osx aswell, but since i don't have any of those operatingsystems up n' running i can't test it out. It should be fine to adjust the paths to the database to the plex database location in those OS:s.

It needs to run locally since it accesses the servers filesystem inorder to remove the subtitle directly from the drive. No communication is done externally.

Would be nice if someone would like to try it out on a different OS and give some feedback on it's reaction.

Oh boy, i need a cup of tea. Hope i'm making some sense. :)

I didn’t set php on my Mac. But can do some tests on my syno if you want.

Do it if you want, entierly up to you. :)

Just toss me some feedback if you do use it. :)

It doesn't work on QNAP NAS because it is set for windows PMS only sadly.

Ismelda, can you please elaborate this? So i can possibly fix it?

Isn't there a plex database file (com.plexapp.plugins.library.db) on the QNAP NAS aswell?

And there has to be a metadata-media folder (AppData/Local/Plex Media Server/Media/Localhost/) somewhere also?

Should it not be possible to just change the paths in the index.php to correspond to those on a QNAP NAS?

I'm not familiar with NAS so i need all the help i can get with how the structure is.. As i said, should be the same basic idea? Just have to find the paths i guess.

The PMS on QNAP NAS (I don't know for any of the other NAS) is located in a /.qpkg/PlexMediaServer/ folder. It is a linux based system.

So the Settings in your index.php need more flexibility to consider this kind of path and like I said I don't even know what the other NAS use as path... Plus accessing the linux System through a php file when the qpkg folder is not supposed to be openly accessible in the first place might be tricky... You have to put the PlexUSM folder in a web folder on the nas then launch the index.php from there which is easy enough but then go up a folder and then find the .qpkg folder and so on. Seems relatively straightforward but linux is so weird... I have no idea what it might do.

I'd say :

$PathToPlexMediaFolder = "../.qpkg/PlexMediaServer/Library/Plex Media Server/Media/localhost"

and

$PathToPlexDatabase = "../.qpkg/PlexMediaServer/Library/Plug-in Support/Databases/com.plexapp.plugins.library.db"

should be working on a QNAP... I didn't look though if you just using this would do the job. You migh have some reference on other files to windows path or something?

Anyway those give me a blank page just as with windows settings so it is not that. I am clueless with Linux anyway.

PlexExport uses a totally different approach to gather metadata from PMS, on whatever plateform you are. So maybe there are idea to gather from their "cli.php" file.

I'll look into that. I'm not using any specific paths other than those two. The rest is gathered from the database so that is not depending on OS.

I think you have to go up higher than just one directory on linux to reach it, not sure.

I'll look into what PlexExport uses and how they have it solved. :)

Hi, 

Here are the paths for synology (replace volume1 by the volume where you have installed your Plex). 

$PathToPlexMediaFolder = "/volume1/Plex/Library/Application Support/Plex Media Server/Media/localhost/";
$PathToPlexDatabase = "/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db";

However, even if I have added these paths to PHP open_basedir (i tried with and without backslash before the spaces), I have error message about accessing the files.

I have been able to make it working partially on my synology nas by copying the database and the localhost folder to /tmp and to edit the according paths. Partially because it doesn't see my library, it asks to select a library but I can't figure out where and how.

Any idea how to fix PHP access to the folder and this library issue?

Thanks.

PS: Here is the screenshot, I think you should have put one, we like to see what we'll get if it works :)

Hi radar. I tried adding a screenshot but chrome just timed-out all the time. :frowning:


Thanks for adding one. :slight_smile:


I’ll check into the access rights. I am rather sure that the user, running the webbserver needs access to those directories.


Currently i think your webbserver has access to see the file, not to read it. Think you might try a chmod to add the webbuser as full read rights on the copied file and sew if that works.

I did chmod 777 on both files.

Can you see anything in the php error log? :confused:

I've look at the PlexExport and how they do it, it's a nice method but i can't manage to find the hash of the movie with that method. And that is needed in order to find automatically downloaded subtitles.