Jump to content

Important Bug Fix for Playlist paths


Recommended Posts

embylad892746
Posted

If you have movies library loaded in /path1/movies for example. Playlists currently referencing movies in that library will have the paths for movies also listed as /path1/movies/<movie> in the xml playlist.

However, if you change the mapping of your movies folder, .e.g movies are now in /path2/movies then the playlists will NOT be updated. The playlists will actually be broken and not will appear empty because their xml files still hold the original /path1/movies/ paths.

Correction:

When emby cannot find the movie in the playlist /path1/movies<movie> it should at least attempt to replace the path with the current movie paths to find a valid file. E.g. attempt /path2/movies/<movie>.

GrimReaper
Posted

AFAIK it had been like that for years, with Playlists (and Collections when they were using .xml files) not being as much resilient to paths change - which is effectively same as if you removed the library and re-added it. 

Aside from manually editing db and change paths there, can't think of a way to preserve playlist entries. 

embylad892746
Posted (edited)

Thanks for confirming.

The fix is easy to implement. They simply need a couple line script that checks for valid path found in XML. If not valid, search for movie in current library paths and update XML path accordingly.

I'm going to create my own library migration script to do this for now. I'm really surprised this isn't implemented as standard yet.

@Luke can you implement this?

 

 

Edited by embylad892746
Posted
Quote

If not valid, search for movie in current library paths and update XML path accordingly.

It's tricky. What if the server picks the wrong one?

embylad892746
Posted
15 minutes ago, Luke said:

It's tricky. What if the server picks the wrong one?

thanks for reply Luke. But you already know the exact movie name in the original playlist xml: /broken/path/movie.mp4

1. Grab current library root folders

2. Search recursively in each library root folder for movie.mp4.

3. If found, Update XML.

am I missing something? Excuse my ignorance if I am.

Posted
9 minutes ago, embylad892746 said:

thanks for reply Luke. But you already know the exact movie name in the original playlist xml: /broken/path/movie.mp4

1. Grab current library root folders

2. Search recursively in each library root folder for movie.mp4.

3. If found, Update XML.

am I missing something? Excuse my ignorance if I am.

I feel the same way. @Luke if you already know ylthe exact movie name why can't you update the playlist ONLY when you have an exact match?

Posted

Hi, aside from talk of how this could work in the future here is what you need to do right now if you move files that are part of a play list.

This knowledge base article gives instructions for doing so.
https://support.emby.media/support/solutions/articles/44001849016-playlist-manual-migration

PS you used to have to do the same thing with Collections as well until 4.6 server when Luke optimized and changed the way collections work!

  • Like 1
Posted
17 minutes ago, cayars said:

Hi, aside from talk of how this could work in the future here is what you need to do right now if you move files that are part of a play list.

This knowledge base article gives instructions for doing so.
https://support.emby.media/support/solutions/articles/44001849016-playlist-manual-migration

PS you used to have to do the same thing with Collections as well until 4.6 server when Luke optimized and changed the way collections work!

Yep, that's the process I currently use. 😁 

The only problem is that when you're moving a lot of files it's pretty easy to lose track of what you moved. 😅 

Posted
2 hours ago, mbarylski said:

I feel the same way. @Luke if you already know ylthe exact movie name why can't you update the playlist ONLY when you have an exact match?

Because it is possible for the video to actually be named "movie.mp4".

If you have your movies in separate folders (which many do) then the video file name can be anything.

Posted
1 minute ago, ebr said:

Because it is possible for the video to actually be named "movie.mp4".

If you have your movies in separate folders (which many do) then the video file name can be anything.

I meant the actual name of the movie. 

So if my original playlist includes Toy Story (1995) at D:\Movies\Toy Story (1995).mkv, and I move it to D:\Movies\Toy Story (1995).mkv, the name of the movie is still Toy Story (1995). Why couldn't Emby match on Toy Story (1995) and just reset the path?  

GrimReaper
Posted

Why not make Playlists NFO-based and dump .xml, same as Collections were, and write (single or multiple) <playlist> node in item NFO, hence it'll survive any movement/library rebuild? 

Posted
11 minutes ago, GrimReaper said:

Why not make Playlists NFO-based and dump .xml, same as Collections were, and write (single or multiple) <playlist> node in item NFO, hence it'll survive any movement/library rebuild? 

Playlists have additional requirements that make that tricky, such as the ability for a track to appear more than once, as well as maintaining a specific order in the list.

GrimReaper
Posted (edited)
3 minutes ago, Luke said:

Playlists have additional requirements that make that tricky, such as the ability for a track to appear more than once, as well as maintaining a specific order in the list.

Which, I reckon, could be solved by tags in the <playlist> node, like <number> or <sort> (single or multiples) or whatever you pick, as any other needed tag could be added to the node as necessary, since it is item-related, it can be pinpointed to the degree of accuracy that is required?

Edited by GrimReaper
Posted
23 minutes ago, GrimReaper said:

Which, I reckon, could be solved by tags in the <playlist> node, like <number> or <sort> (single or multiples) or whatever you pick, as any other needed tag could be added to the node as necessary, since it is item-related, it can be pinpointed to the degree of accuracy that is required?

I'm afraid that would be a technical nightmare.  For instance, re-arranging the tracks or deleting or adding one in the middle would require changing the tags in ALL items.

GrimReaper
Posted
12 minutes ago, ebr said:

I'm afraid that would be a technical nightmare.  For instance, re-arranging the tracks or deleting or adding one in the middle would require changing the tags in ALL items.

I assume it would be, yes, although not unachievable. As opposed to current schema where playlist is literally nuked because user moved the folder? That doesn't seem quite fair, tbh, moreso of it contains 100+ or 1000+ items, recreating those ain't exactly piece-of-cake, either time-wise or effort-wise, likely resulting in it simply being abandoned/never being recreated. Personally have no use for that feature, but I can imagine a number of users (especially on music side of things) do. 

  • Agree 1
embylad892746
Posted
import os
from os.path import join
import shutil

"""
Update the paths in your emby playlists folder.
Creates a backup before modifying.
Tested on python 3.9.7.


Requirements to run:
	Update playlist_pth --> path of your emby playlists folder
	Update path_dic     --> map your old paths:new paths
"""
playlist_pth = '/your/path/playlists'

path_dic   = {
	'my/old/movies'      : 'my/new/movies',
	'my/old/tv'          : 'my/new/tv',
	'my/other/old/stuff' : 'my/other/new/stuff'}





playlists_lst = []
for root, dirs, files in os.walk(playlist_pth):
	for file in files:
		if file.endswith(".xml"):	
			xml_pth = join(root, file)
			playlists_lst.append(xml_pth)
			

if len(playlists_lst) > 0:
	print("===== Playlists found =====\n")
	for playlist in playlists_lst:
		print(playlist)
	print("\n===========================\n")
else:
	print("*** NO PLAYLISTS FOUND ***")
	exit()

backup_pth = playlist_pth.replace('playlists','playlists_backup')
if os.path.isdir(backup_pth):
	print("*** {} ALREADY EXISTS ***".format(backup_pth))
	print("No files modified")
	exit()

backup = shutil.copytree(playlist_pth, backup_pth)
print("Playlist backed up     --> " + backup)

for pth in playlists_lst:
	for old_pth in path_dic:
			new_pth = path_dic[old_pth]
			fin = open(pth, "rt")
			data = fin.read()
			updated_data = data.replace(old_pth,new_pth)
			fin.close()
			fin = open(pth,"wt")
			fin.write(updated_data)
			fin.close
print("Playlist paths updated --> " + playlist_pth)

Well, for my needs I fixed it with this. What I plan to do in future is create an automated script that:

1)  monitors and keeps a record of my current Emby media paths

2 ) When my media paths change it grabs the file names off the current (outdated) XMLs

3) Searches the library for full path containing the file name (must be exact match)

4) If found updates my XML.

Posted

It depends how you use the playlists and how you move the files but a possible solution is using m3u playlists on disk.
If you know you'll keep the same overall structure but might need to move the whole music library to another disk this would work perfectly.
Using m3u playlist files allows you to use relative paths so it's not tied to a drive letter or share.

If you're actually rearranging folder structures this won't be much help unless you can script or do a little programming.

If you can do that then you are in control of searching for the new location to the media and updating the path in the playlist. 

  • Agree 1
Posted
2 minutes ago, cayars said:

It depends how you use the playlists and how you move the files but a possible solution is using m3u playlists on disk.
If you know you'll keep the same overall structure but might need to move the whole music library to another disk this would work perfectly.
Using m3u playlist files allows you to use relative paths so it's not tied to a drive letter or share.

If you're actually rearranging folder structures this won't be much help unless you can script or do a little programming.

If you can do that then you are in control of searching for the new location to the media and updating the path in the playlist. 

I've used m3u's for music playlists, but can they also be used for video playlists?

Posted
Just now, Luke said:

Yes they can.

Very cool. I might have to test that out. If I created a playlist in Emby, is there a way to convert that xml playlist to an m3u?

Posted

Not with anything built in but that wouldn't be a hard plugin to do or that info could be pulled via API as well.
So it could be quite possible to generate the playlists from data in Emby.

Posted
1 minute ago, cayars said:

Not with anything built in but that wouldn't be a hard plugin to do or that info could be pulled via API as well.
So it could be quite possible to generate the playlists from data in Emby.

Ok, I know I looked before and couldn't find anything. Unless there's some tool that you can think of, I'll just have to stick to my existing Emby video playlists.  

Posted

I don't know of any plugins that do this either but it wouldn't be a bad idea.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...