How to change subtitles automatically imported.

Hi all,

Sometimes the subtitles automatically imported are wrong, so I have to manually change them in the Nas… But is not very strict forward so I decided share with you and see if you can help out to find a better way.

This is a real example, I downloaded a movie from Yifi lets say “AAA” and for some reason the subtitles are from a random tv show".

  1. My first step is to find where is those saved in my Nas server, so I run this script from the terminal:
    plex_pull_search

First I copy the SQLite DB to my computer with rsync

rsync root@192.168.1.XXX’/mnt/HD/HD_a2/Nas_Prog/Plex/Library/Plex\ Media\ Server/Plug-in\ Support/Databases/com.plexapp.plugins.library.db’ ~/temp/plex/library.db

then I query by the name, finding those that have subtitles

sqlite3 ~/temp/plex/library.db “SELECT hints,url FROM media_items, media_streams WHERE media_items.id = media_streams.media_item_id and hints LIKE ‘%$1%’ and url <> ‘’”

so if I run “sh plex_pull_search AAA”, I will find all the subtitles of the server for the movie “AAA”
An example of the out put would be:
name=AAA|media://9/517f640f76cad8635042254c68d751fc14c8ecd.bundle/Contents/Subtitles/en/com.plexapp.agents.opensubtitles_6511dfa146a3829cebd5bae37653cf073a06a1c5.srt
name=AAA&source=bluray&year=2016|media://5/ffa345b05008e87adb053baa60702ac6bffa907.bundle/Contents/Subtitles/en/com.plexapp.agents.opensubtitles_6511dfa146a3829cebd5bae37653cf073a06a1c5.srt

So now I know that my subtitles are in “media://5/ffa345b05008e87adb053baa60702ac6bffa907.bundle/Contents/Subtitles/en/com.plexapp.agents.opensubtitles_6511dfa146a3829cebd5bae37653cf073a06a1c5.srt”

  1. The second step is replace those subtitles with some that works, so I run this script:
    plex_push_srt
    echo “mode usage plex_push_srt from_local to_remote”
    #This is the path where the Media is in my NAS
    MEDIA_PATH="/mnt/HD/HD_a2/Nas_Prog/Plex/Library/Plex\ Media\ Server/Media/localhost/"
    REMOTE_PATH=2 #I replace the "media://" with my Media path in the Nas server DIR_TARGET="{REMOTE_PATH/“media://”/$MEDIA_PATH}"
    echo $DIR_TARGET
    #Replace my server subtitle, with the local subtitles I know the work
    scp “1" root@192.168.1.XXX:"{DIR_TARGET}”

so If I run “sh plex_push_srt ~/Downloads/my_local_works_subtitles.srt media://5/ffa345b05008e87adb053baa60702ac6bffa907.bundle/Contents/Subtitles/en/com.plexapp.agents.opensubtitles_6511dfa146a3829cebd5bae37653cf073a06a1c5.srt”

It will replace the wrong subtitles, so I can watch the movie with the manually upload subtitles.

Details:

  • I have try to save the subtitles with the movie with the same name and different extension, but that doesn’t work.
  • My tv is quite old (first generation smart tv), and doesn’t allow me to select the subtitles… So once a movie with wrong subtitles start, I have to watch that movie with very distracting subtitles.
  • My NAS is quite old as well
  • I run Plex in my NAS, connected to my Tv, I have ssh and samba access.

My concerns about this:

  • If for some reason Plex doesn’t automatically find subtitles, I can’t use this method (there is not path in the server for the subtitles), what I can do is create a new row in local and rsync it to the server, but I’m afraid I will corrupt the DB and won’t be able to use it any more.
  • I love/hate how Plex manage the subtitles, it usually works, but seems to me like a black box, is not configurable at all… Can’t manage by myself the subtitles.
  • Is really not an easier way to do this? Now that I have the script is quite easy, but I have to investigate quite a bit to find out how it works.

Sorry about the Markdown… it treats the bash comments as headers, can’t find any way to edit it