I’m running Plex via a freenas (aka truenas) plugin. Having a heck of time upgrading the plugin to the latest version. So my solution was to install a separate instance of the plugin and then re-building the libraries.
All good so far. Now in the web gui I have two servers showing “old” and “new”. The libraries are re-built now, so basically each library duplicated. The problem is on the “new” server, everything is indicated as “Unplayed” (as expected).
Is there a config file or such that I can copy over somehow to indicated the Played status on my new server? Will be a heck of job to go through every show and movie manually!
But this must be done before anything is played on the new server. Otherwise you may see negative play counts and other weird behavior.
And it will only work for “matchable” items.
from plexapi.server import PlexServer
from plexapi.myplex import MyPlexAccount
def main():
account = MyPlexAccount('<username>', '<password>')
plex = account.resource('<servername>').connect()
seen = get_lines(u'seen.txt')
places = ['TV'] # library name
for place in places:
tv_shows = plex.library.section(place)
for show in tv_shows.all():
episodes = None
error_count = 0
while not episodes:
try:
episodes = show.episodes()
except:
error_count +=1
pass
if error_count > 10:
episodes = show.episodes()
time.sleep(2)
for video in episodes:
for part in video.iterParts():
filename = part.file
###################################
### section for logging history ###
###################################
if video.isWatched:
log(u'%s\n' % filename,u'seen.txt')
###################################
### section for restoring status ###
###################################
if filename in seen:
video.markWatched()
def log(text,file):
f3 = codecs.open(file, 'a', 'utf-8')
f3.write(text)
f3.close()
def get_lines(file):
# try:
f = codecs.open(file,'r', 'utf-8')
names = f.read().split('\n')
f.close()
f = True
while f:
try:
names.remove('')
except:
f = False
pass
# except:
# names = []
return names
if __name__ == '__main__':
main()
The complication for me is that my Plex is running via a plug in in a jail on my freenas server. Need to figure out how to execute the .py in that environment