Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

MovieFan's Database Tool for Plex

MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee
edited April 2015 in Windows

Update 4/14/2015

 

- Change added_at date routine now located in Library sub-routine.  Can now be done on a per library basis.

- Added Find Unmatched feature.  This will identify media on your system not matched up in Plex.

 

*Note - The Find Unmatched currently gives false positives for cross media in your library folders.  Example, local movie posters will show as unmatched photos, and video in a photo library will show as an unmatched video.  I will get these fixed soon.

 
 

Update 4/11/2015

 

There was an error in the script for performing the change added_at feature.  Thanks to hthighway for finding the bug.

 
 

Update 3/31/2015

 

Small bug in the Database export script.  Thanks SA2000 for finding this.

 

New zip file.  I did not bother renumbering the files with a new version since it was literally 2 letters that I had to add.

 

MovieFan's Database Tool for Plex v0.3.1.1.zip

 

Update 3/30/2015

 

Added a few more features.

 

- Database Export now allows you to pick from multiple export folder locations

- Database Export will export all tables, blank tables will result in a 0 byte file and will indicate and error in the log.  This error is normal.  I will change this in a future version with better error messages.

- Database Export will replace linefeed characters in the metadata_items summary field with <LF> so you can search and modify as you feel fit.

- Check for database corruption with SQLITE's integrity check feature

- Find media items marked as unavailable in Plex (A file will be created listing the files.  Due to limitations of the scripting program, the file will list 5000 files at a time, multiple output files will be generated if there are more than 5000 unavailable files.)

 

Update 3/2/2015

 

Bug has been fixed with downloading movie artwork.  I did not bother changing version numbers as it is a very minor fix.  Please download the latest zip package.

 

Update 2/27/20165

 

Version 0.3.0

 

New update to my tool.  I erased all the old info in this post since it is not important anymore.  Please let me know if you find any problems.  I have tested it and they all work on my system.  I only have 1 iTune XML file to test with and it worked on mine.

 

MovieFan&#39;s Database Tool for Plex v0.3.0.zip Updated 3/2/2015

MortScript_and_support.zip

 

I found the correct 32-bit and 64-bit versions of Mortscript.  Please use the correct version for your OS.  They are listed under PC (32-bit) and PC64 (64-bit).

 

I also added the Mortscript user manual in case anyone was curious as to what the code actually does.

 

Features

Backup/Restore/Export Plex Database

Change added date to aired date.  This will allow recently added to sort by recently aired.  Good for when you add old shows and do not want it to show in recently added.

Rename/Import/Export/Delete Playlists (including import iTunes XML playlist file)

Rename/Export Library Info (export will produce a csv file with most information on your media, no trailer or extra info at this time)

Edit custom library icon value

Save currently used movie poster and artwork along side movie

View/modify user settings

Copy watched status from 1 user to another

Delete all watched status from user

Manually download themes from plex.tv

Help Menus to explain what all the options do

Works on 32-bit and 64-bit Windows (using the proper Mortscript executable, included)

 

Known Issues: (not necessarily bugs)

Import a playlist only works for the admin account.  Other options work on any playlist, except smart playlist.

When restoring a backup, if PMS is running, it kills all the Plex process.  This could potentially result in data loss or possible database corruption if the database is being accessed at the time.  Best to exit Plex manually first.  The script cannot do it cleanly.

Changing the added date is a 1-time process.  It does not persist.  If you like this feature, you need to rerun it after each library update

I have not tested using network paths but was told before that it worked and nothing I changed would have affected that.

 

To Do List

Add playlist import for other users

Look for solution to closing Plex properly

Include smart playlists

Add saving of TV Show posters and artwork (this one is complicated, need much more time)

 

How To Install

Just unzip the 2 files into a folder of your choice.  Find the correct version of Mosrtscript.exe and copy it into the same folder.  Then right click on it and run as administrator.  This will register the .mscr extension in the registry.  Running it normally will say it registered, but it really doesn't.  I have also added a new file with Mortscript.  It actually comes with the program but I did not include it before.  It is originally called autorun.exe.  It is a shortcut to run your scripts.  Just rename it to match your script and running it will run the script.  I have already renamed it to match my script.  Just copy the file with the version of Mortscript you use.  I do this so I can associate the .mscr extension with notepad as default so opening the .mscr will allow me to view the file, while running the exe will run the script.  Otherwise you would need to right click and use Open With.  You can skip this file and just run the .mscr file you like.

«13456723

Comments

  • TobbeWilsonTobbeWilson Members, Plex Pass Posts: 34 Plex Pass

    I have tried it with one of my small exported m3u playlists from MediaMonkey but it flickers by so fast i can't see what's happening. It's giving me some kind of error. Is there a way to get a log out of it?

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    At the top of the script find the line

    bolDebug = False

    change the False to True.  This will stop the window from closing so you can see any error messages.  I didn't put in other debugging options yet.  You'll have to close out the window before the script continues.

    Can you send me the playlist?  I didn't account for foreign characters and the like so maybe that is the problem.

  • BavaricanBavarican Members Posts: 8 ✭✭

    I tried it and it went through the process you have described. 

    Unfortunately, there is no playlist created within Plex.

    Where does Plex store its playlists, so I check if anything is there?

    A search turned up nothing.

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee
    The playlist is stored in the regular database with all the other media info.

    I'll work on another version with some error checking. This was a quick proof of concept and I didn't spend too much time fine running it, so you can't tell if it didn't work.

    Sent from my VS980 4G using Tapatalk
  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    Version 0.2 of the program now available.

  • Wolf_BrotherWolf_Brother Members Posts: 178 ✭✭
    edited September 2014

    Version 1

    The process ran as described and seemed to complete successfully terminating in the "Done" message but no playlists showed up in Plex

    Turning debugging on I get the message

    'Sqlite3.exe' is not recognized as an internal or external command, operable program or batch file

    Version 2

    Running it I get the menu with 4 options

    Choosing "List Existing (it says Exiting btw) Playlists it says "the following playlists were found" but doesn't show anything (I already have some in Plex made in it)

    Choosing "Import New Playlist"  and picking the playlist I get this message

    Version_2.jpg

    Turning Debugging on and running the mscr I get the message

    Sqlite3.exe: Error: unknown option: -\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db

    closing this allows the window with the 4 options to load and then choosing "import New Playlist" gives me the same message as with Version 1

    'Sqlite3.exe' is not recognized as an internal or external command, operable program or batch file

    Closing this message and subsequent screens with the message again I finally get a message saying

    Successfully Imported Playlist:

    C:\Users\John Hancock\Music\Playlists\Metal.m3u

    but the playlist doesn't appear in Plex.

    This is the Playlist I was trying to use, it's a small one that I just chucked a few songs together quickly to test it but the same thing happens with any of my other playlists (I changed it to a .txt file so I could upload it but it was a m3u file when I tried to use it of course)

  • BlalalaBlalala Members Posts: 12

    I'm trying to run the converter on my Windows computer to import a .m3u playlist to my Linux Plex Server, on another computer.

    Could you please add an option to select which database file to use and remove the checker that's seraching for files locally on the computer the script is running on?

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    @WolfBrother - Oddly your error message says it is looking for Sqlite3.exe.  It shouldn't have a capital "S", so I'm not sure why it's doing that.  The file is in the package so it should have been extracted to the same folder as the script.  Are you by chance running the script from within the zip file?

    @Blalala - I can do that.  I'll upload a new version in a bit.

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    New version up.

    Version 0.2.1

  • BlalalaBlalala Members Posts: 12
    edited September 2014

    Great work, MovieFan! :D

    I found a typo: "The following Playlsits were founds:"

    The database selection worked fine. Though, I wasn't able to import my playlist that had the ' character in file names.

    When I took a playlist without ' characters, I got a success message. The playlist is also listed when I list the playlists using your scripts.

    However, I can't get the playlist to show inside Plex.

    I stopped the server, uploaded the new database file and fired it up again. No playlist were found.

    When I delete a playlist using the script, I get the message "Successfully deleted Playlist:". Maybe the name of the removed playlist should be below?

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee
    edited September 2014

    I have 1 idea on why the playlist is not showing up.  The playlist is tied to the account connected to PMS.  Typically this account has an id number of 1.  If you somehow have added and removed accounts, your's might have become another number.  My script assumes the account is 1.  If you don't mind helping me, can you type the following, including the quotes" into a command prompt window and provide me the result.  Include the actual db file you are using.

    sqlite3.exe "full path to db file\db filename.db" "SELECT account_id FROM metadata_item_accounts;"

    You should get 1 result, a number.  Then find the following section in the code.

    ###   Create Library Item in###   Create Library Item in database
    ###   Without this, there is no playlist shown on the WebApp
    ###   Have not checked if other clients need this
    
    strSql = """INSERT INTO metadata_item_accounts (account_id, metadata_item_id) "
    strSql = strSql & "VALUES (1, " & intPlaylistID & ")"""
    strParam = strFlag & strExe & " " & strDB & " " & strSql
    RunWait(strCmd, strParam)
    

    Replace the 1 with the number from the above stem.

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    I'll work on the other items later when I'm back at my main computer.  Any other feature suggestions?  Do you think an export playlist would be useful?  I'm also looking into how to handle if the file is not in the database.  Right now it just gives an error and stops.  I was thinking of adding an override to continue the import, skipping those files it couldn't find.

  • BlalalaBlalala Members Posts: 12

    Of course I want to help!

    The sqlite command resulted in "1". When I'm accessing my server, I use the Plex Home Theater from my home Windows PC. Could that have something to do with it?

    I'm replacing this database file: "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"

    For me, an exporter wouldn't be neccesary. I only want to read my playlists created from Foobar in Plex.
    Another feature that'd be nice is a playlist replacer. So that I don't need to remove the playlist and then have to add it again. That's not really a big deal, so don't implant it if it takes too much time.

    An override option for skipping files could be good. Please have a look at the problem with ' too. :)

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    So it looks like the database is being modified correctly, so it could be PHT.

    I don't think PHT supports playlists yet, at least not according to the support page.  https://support.plex.tv/hc/en-us/articles/202477593-Play-Queue-Support-Plex-Home-Theater.  Test it with the WebApp if you can.

    I'll have the ' issue fixed in the next version.  It's actually an easy fix.  This might also affect if there is a ' in the music filename.  I'll check for that as well.  I'll also include the other things you mentioned.

  • BlalalaBlalala Members Posts: 12
    edited September 2014

    That's very nice.

    I have checked the permissions for the database file, they're set right. The playlist is not listed in the WebApp either.

    Also, if I update the library via the WebApp, I can't list the playlist using the script from the updated database file.

    I tried to create a playlist in the WebApp using some songs, but the playlist "can't be loaded". Maybe something's wrong at my side?

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    Hmm.  I wonder if your database structure is different from mine.  What server version are you on?  I'm on 0.9.9.13.  I can't imagine Plex made any significant changes to the structure that would impact the script from working.

    Would you be willing to share the db file with me so I can trouble shoot the problem?  Include the version with the Playlist created from the WebApp.  Just upload it somewhere and PM me the link.

  • BlalalaBlalala Members Posts: 12

    I'm using 0.9.9.14. I'll PM you my database file.

  • Wolf_BrotherWolf_Brother Members Posts: 178 ✭✭
    MovieFan wrote on September 10 2014, 8:41 AM: »

    @WolfBrother - Oddly your error message says it is looking for Sqlite3.exe.  It shouldn't have a capital "S", so I'm not sure why it's doing that.  The file is in the package so it should have been extracted to the same folder as the script.  Are you by chance running the script from within the zip file?

    No I'm not running it from within the zip file. It was extracted to a folder on the desktop, all four files are there. MortScript.exe, sqlite3.exe, stop script.mscr and m3u Playlist Converter v0.2.mscr

    The error message wasn't using a capital "S" it was lowercase that was an error on my part.

  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee
    Try again with 0.2.1. I've added more error handling. Maybe it doesn't like your desktop, although that doesn't make sense, but try moving the folder to something outside of Window's control.

    Sent from my VS980 4G using Tapatalk
  • MovieFan.PlexMovieFan.Plex Members, Plex Pass, Plex Ninja Posts: 14,831 Plex Employee

    Blalala - I am seeing problems with your db file.  In your table that identifies the files to include in the playlist, there are text values where the database expects numbers.  This is corrupting the database so that it doesn't work properly.

    Do you happen to have a backup of the db file before trying out my script?  I just want to check if it was something my script did.  I don't think it was, but ti doesn't hurt to check,.

«13456723
Sign In or Register to comment.