Jump to content

Move Kodi "played" status to Emby server


mondowondo
 Share

Recommended Posts

mondowondo

I searched and found several frustrated people who tried to move from Kodi database to Emby Server.  Frustrated, because they wanted to move the Played / Unplayed status from Kodi to Emby.  I figured out a way to do it!  I'm not a programmer and have no idea if this will work for you but here is how I did it.  

 

I have Unraid running kodiheadless docker and mariadb as a central db.  This allowed us to have multiple instances of Kodi running off the same central database.  FireTV in the living room, Win10 in the office, Android cell phone, all running Kodi but accessing the central database on the unraid server.  The only reason this may be important is that I have a mariaDB.

 

From win10 MySQL Workbench I connected to the MariaDB instance to run a query to return anything with a playcount greater than zero, then exported this to a .csv file.

SELECT path.strPath, files.strFilename FROM files, path WHERE files.idPath = path.idPath AND files.playcount > 0 
I cleaned up the spreadsheet, removing unnecessary lines and characters using find/replace.  Added a column of "<PlaylistItem><Path>" in front of each entry and "</Path></PlaylistItem>" at the end of each line. 

 

Using the Emby UI, I created a new playlist by adding one random movie to it. Then edited the new \EmbyServer\data\playlists\All Played [playlist]\playlist.xml file to remove that random movie and replaced it (copy/paste) with all the movies/TV episodes I want to mark as watched.  So now the playlist file looks like this.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Item>
  <ContentRating>Rated PG</ContentRating>
  <Added>3/17/19 9:10:38 PM</Added>
  <LockData>false</LockData>
  <LocalTitle>All Played</LocalTitle>
  <RunningTime>1092</RunningTime>
  <Genres>
    <Genre>Action</Genre>
    <Genre>Adventure</Genre>
    <Genre>Comedy</Genre>
    <Genre>Drama</Genre>
    <Genre>Family</Genre>
    <Genre>Crime</Genre>
    <Genre>Romance</Genre>
    <Genre>Fantasy</Genre>
  </Genres>
  <Studios>
    <Studio>Columbia Pictures Corporation</Studio>
    <Studio>New Line Cinema</Studio>
    <Studio>Kentucky Fried Theatre</Studio>
    <Studio>Plan B Entertainment</Studio>
    <Studio>Marv Films</Studio>
    <Studio>20th Century Fox</Studio>
    <Studio>O Entertainment</Studio>
    <Studio>Grand Army Entertainment</Studio>
    <Studio>TriStar Pictures</Studio>
  </Studios>
  <PlaylistItems>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Karate Kid, The (1984).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Keanu (2016).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Kentucky Fried Movie, The (1977).avi</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Kick-Ass (2010).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Kick-Ass 2 (2013).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Kingsman The Secret Service (2015).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Knight And Day (2010).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Knight's Tale, A (2001).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Kung Pow (2002).avi</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/Labor Pains (2009).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Kids/Movies/Labyrinth (1986).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Kids/Movies/Labyrinth (1986).mkv</Path></PlaylistItem>
<PlaylistItem><Path>/mnt/user/TowerVideo/Movies/A-Team, The (2010).mkv</Path></PlaylistItem>
  </PlaylistItems>
  <Shares>
    <Share>
      <UserId>1</UserId>
      <CanEdit>true</CanEdit>
    </Share>
  </Shares>
  <PlaylistMediaType>Video</PlaylistMediaType>
</Item>
After editing and saving the new playlist.xml file I restarted the emby server and Scan All Libraries (each a few times).  After a while the updated library was visible.  I don't know what triggers the UI to pull the info from the playlist.xml file but eventually it did.  Then it was EASY to click the check mark on the playlist to mark everything in the playlist as played.

 

 

PS.  So far this only worked one time... I tried creating another playlist so I could mark more items as watched, so far it hasn't been able to read the new playlist.xml file

 

EDIT: SUCCESS!!! With help from those below and Luke on the server forum I figured out my problem was not every <...Item> was valid. The & in a few items acted as an XML comment so I replaced it with $amp;. I also had two items that were messed up because it was a 'part1' and 'part2' but the SQL returned them on the same line.

I also finished this using a collection.xml instead of playlist because in the GUI there is an option to rescan the collections without rescanning the whole library (faster).

Edited by mondowondo
Link to comment
Share on other sites

mondowondo

I waited to see if time would cause the playlists to read from the xml file.  Unfortunately, the playlist.xml file has been overwritten with the shortened list that shows in the UI.  So where is the playlist info really being stored?  How do we update that store from what is in the playlist.xml?    (or same question regarding the collections.xml file if that's easier to manually update and propagate).

Link to comment
Share on other sites

Angelblue05

I would ask in the server section of the forums. I don't have an answer for you :)

 

The way I usually recommend is to back up to trakt then import from trakt on your server. I think Emby can reads the watched status from nfos. So it would make sense to export content status to nfos from Kodi using the backup function.

Link to comment
Share on other sites

mondowondo

On the server section of the forum Luke suggested that Library Scan should read the XML file and update in the GUI.

 

The library scan will work, but the XML can't point to arbitrary files. The paths in the xml have to exactly match the paths used in library setup.

 

I looked in the log file and figured out the problem.  The file names which included an & were causing the issue.

 

<CollectionItem><Path>/mnt/user/TowerVideo/Kids/Movies/Oliver & Company (1988).mkv</Path></CollectionItem>

 

replaced with 

 

<CollectionItem><Path>/mnt/user/TowerVideo/Kids/Movies/Oliver & Company (1988).mkv</Path></CollectionItem>

 

and after the first scan, the collection updated and was easily marked that collection of movies as read!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...