INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Prevent Loss Of Playlist Links After File Update  (Read 1443 times)

AlreadyFree

  • Junior Woodchuck
  • **
  • Posts: 56
Prevent Loss Of Playlist Links After File Update
« on: November 25, 2020, 11:45:11 pm »

I'm going back and reripping a lot of my cd's into flac that I had previously had ripped as mp3's. This is causing a problem with previously saved playlists. Even though I have the playlists locked (which I thought would preserve the playlists despite library changes) but once I delete the mp3's and replace with the reripped flac's any instances of those tracks that were also listed in a playlist disappears. The expected behavior in this case would be for the locked and saved playlist to retain it's track listing but simply report a broken link placeholder for missing tracks, allowing me to manually replace the missing tracks with the updated ones without completely losing track of my playlist structure. Is there any better way to do this that I am missing?
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Prevent Loss Of Playlist Links After File Update
« Reply #1 on: November 25, 2020, 11:56:20 pm »

There is a trick you can do.

First, understand that if you delete a file from the library, it will be removed from playlists.

So how to do this without (apparently) deleting the files?  That's the trick. This is easier if you use another program to do your ripping.


Select the tracks in question.
Use RMCF in MC to rename the tracks from .mp3 to .flac
Close MC.
Rip your tracks to flac, and copy the new flac files over the existing mp3 files (that were renamed .flac) using the exact same locations and filenames.
Start MC.
Do an update tags from library, and reanalyze the audio.
Done.

If you're ripping in MC, do the rip to a new location (so they are essentially duplicate files), the delete the new files from the library without removing them from the disk. Then close MC and continue as before.

You could also do it another way: export all the playlists as MPL, then edit the MPL files to change all .mp3 filenames to .flac.  Then delete and replace all your files and reimport the playlists.

Either way can work.

Good luck....
Logged

AlreadyFree

  • Junior Woodchuck
  • **
  • Posts: 56
Re: Prevent Loss Of Playlist Links After File Update
« Reply #2 on: November 26, 2020, 12:03:08 am »

Well I was definitely hoping for a more elegant way to do it. And I really don't think MC should be deleting song entries from locked playlists in the first place. But I hadn't thought of either of the workarounds you suggested, so thanks!
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Prevent Loss Of Playlist Links After File Update
« Reply #3 on: November 26, 2020, 12:11:24 am »

Where you and MC disagree is that MC tracks playlist membership by file.  The advantage is that you can have 20 different versions of a track/file in your library, with only one of them on a playlist. The consequence, though, is what you are now experiencing. Playlist membership lives and dies with the file, and it is not transferable.

FYI, you would have the same problem in lots of other programs, although the fix would vary.

The export playlist method I gave you is not too burdensome as it can be done by a global search and replace in a text editor.

Anyway, good luck.  Glad I was able to clarify things for you.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Prevent Loss Of Playlist Links After File Update
« Reply #4 on: November 26, 2020, 12:37:35 am »

I think one of Glynor's tools, or MCUtils, or "Swag of Tools" has a way to automate the process as well. i.e. A method to "replace these files with those files". A search should find it.

I was going to say, but Wer beat me:
Playlists don't contain a list of files that belong to them. Files contain a list of Playlists that they belong to. So if you delete the file, reference to their Playlists is also lost.
Playlists can exist in isolation to the files, but only in a very limited way. Basically the name I think. i.e. You can create a new Playlist, add no files to it, and it will still exist.

Forgive the interruption.  ;)
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #5 on: November 26, 2020, 10:13:03 am »

Yup. MCFileIngester, which is part-of MCAutoQueue, was built to automate exactly this:
https://vimeo.com/85110224

https://yabb.jriver.com/interact/index.php/topic,76147.0.html
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Dawgincontrol

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 679
  • We have met the enemy and he is us.
Re: Prevent Loss Of Playlist Links After File Update
« Reply #6 on: November 26, 2020, 10:29:34 am »

I'm going to be THAT GUY who tells you not to convert mp3's to FLAC. 

You will gain nothing but confusion as to which files are lossy and which are not.  MP3's are, by definition, inferior files and missing data original to the music.  You may not think there is a difference, but there is.

My bad.  Misread your intent.  Still good advice for others.  ;)
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #7 on: November 26, 2020, 11:06:28 am »

I'm going to be THAT GUY who tells you not to convert mp3's to FLAC. 

Nobody is doing that. They said they were going to re-rip their discs.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

AlreadyFree

  • Junior Woodchuck
  • **
  • Posts: 56
Re: Prevent Loss Of Playlist Links After File Update
« Reply #8 on: December 01, 2020, 02:34:45 am »

Yup. MCFileIngester, which is part-of MCAutoQueue, was built to automate exactly this:
https://vimeo.com/85110224

https://yabb.jriver.com/interact/index.php/topic,76147.0.html

Awesome. I'll give that a look.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #9 on: December 01, 2020, 12:55:01 pm »

Playlists don't contain a list of files that belong to them. Files contain a list of Playlists that they belong to. So if you delete the file, reference to their Playlists is also lost.
Playlists can exist in isolation to the files, but only in a very limited way. Basically the name I think. i.e. You can create a new Playlist, add no files to it, and it will still exist.

Technically, this is not correct. Though, in effect it works the way you described.

A standard Playlist in MC is a MCPlaylistAutomation object in the database which contains an ordered list of MCFileAutomation objects (well, the internal objects corresponding to those MC*Automation Interfaces, anyway). The MCFileAutomation objects reference particular files on disk via their .GetFilename() method.

If you disable the Fix Broken Links feature of Auto-Import, and then move a bunch of the files around on disk, the Playlists will still contain all of the original files. None of them will work, though, as the "links" where those MCFileAutomation objects point to the real files on disk will all be broken. In practice it is no different from a very simple M3U playlist (a text file with a list of file paths). If you move the files the M3U points to, then the playlist is broken, and won't play the missing files.

With Fix Broken Links enabled, then the "File Objects" all get removed from the Library when Auto-Import sees that the links are broken, so then they also are removed from the Playlists (since a Playlist is a list of File Objects). So, the reason the files vanish has nothing to do with the way MC handles Playlists, it is because of the Fix Broken Links feature.

This is an esoteric distinction, but worth noting since this response wasn't quite correct.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Prevent Loss Of Playlist Links After File Update
« Reply #10 on: December 01, 2020, 02:19:00 pm »

Thanks Glynor.

I've never found a way to really dig into how it is all handled internally, and no-one from JRiver has clarified the Playlist issues raised. Not that I've tried very hard to dig into the issue, as it is opaque to users. I use that explanation because it is "simple" to understand, and clarifies things for people a bit. I'm not a programmer and neither are most of the people using MC, so simple is good, and discussing database objects is bad.  ;D

I guess I could read through articles that you have marked as belonging to COM Automation... but, not right now.  ;)
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #11 on: December 01, 2020, 04:04:03 pm »

I've never found a way to really dig into how it is all handled internally

Playing with the COM Automation interface really shows you pretty clearly how it is organized under the hood.

The COM Automation interface is, of course, abstracted somewhat from how it really is implemented under the covers. You're accessing much more limited interfaces for the underlying "objects" in the application, and only a small subset of what they have access to with privileged "internal" code.

That said, an Interface object (like these) in C++ based programming almost always means that the "real" object itself they use internally (or a parent of it) implements all of the same methods and properties. It just may have many, many more items to access (and have better "abilities" within those methods and properties, like things that are read-only may be read-write internally). That's not always true, and they could have reorganized things internally and kept the COM Automation Interface unchanged, of course, but it probably was like that at least at one point.

Still, though, it gives you the general idea. The "Playlist" object (for regular Playlists, not Smartlists) is basically a list, with some additional methods (actions/commands) and properties hung off of it: Name, Path (in the Tree), Type, etc. One of the Playlist object's properties is the list itself, and if you access that property, it "contains" a set of items. Those items are "File" objects, each of which have their own properties and methods.

When you view a set of tracks anywhere in MC (whether a Playlist, a View, or Playing Now), it is showing you a list of those File Objects, and the columns in the View correspond to the properties of the files.* The File Objects themselves (the entries for your imported files in the database, each with a particular ID number) are what matters. If you move the files around outside of MC, those File Objects still exist. The problem is that their .Filename property no longer points to a real file on disk, and if it tries to open the file, the OS says "not found".

So, you can still use that File Object, and it is retained in any Playlist object that references it, but before it'd be able to do anything that uses it in any way that touches the file itself on disk (playing, tagging, etc), you'd have to fix the .Filename property to point back to the file on disk again.

If you have Fix Broken Links enabled in Auto-Import, then MC will detect File Objects with broken .Filename links, and it will try to fix them instead of importing them as new files. If you moved them to somewhere new on the file system, but generally kept the folder containing the files themselves the same (it tends to look for whole directories that match), then it'll probably be able to "fix" it automatically and instead of re-importing them, it'll "reconnect" them by updating the File objects with new .Filename properties.

But, if Auto-Import runs but can't "see" the new files because they're outside of the currently added Watched Folders set or they've changed in such a way that MC isn't sure they're the same files, then Fix Broken Links removes the broken File Objects from the Library (it moves the File Objects to the Removed Items database, and takes them out of the "Main" database). This deletes them from the Playlist object because they no longer exist. The Playlist object is a list of those "file objects".

But, if you have Fix Broken Links disabled, then it does nothing. If they moved to a folder that is watched, it might re-import the files as new separate File Objects (with new ID numbers) but it won't delete the original ones. The new File Objects won't be in the Playlists but they'll work. The old ones will be in your Playlists still, they'll just all be broken.

That's simplifying quite a bit, but that's the general idea.

*  I don't know for sure, but I'd bet this is literally what is happening: to open a view, you attach a generic list object to the "list" property of a View Controller object (or something of that sort), and then the View Controller object does what it is going to do to show this list of file objects (which it knows how to handle) onscreen. All "views" of files in MC are these list objects, whether they come from a search or Playing Now, or a View, or whatever. Playlists are just a special kind of List that are saved in the database and can be manually managed. Smartlists are a different kind where the GetList() command returns a list of objects that match a search. Views are a fancier version of Smartlists, and they're attached to much fancier View Controllers. But, at the bottom of it all, it is a bunch of different kinds of lists of a huge pile of file objects.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #12 on: December 01, 2020, 04:59:58 pm »

I'm going way, way off the deep end here, but... This made me think of it, and I thought it worth writing down.

I often find it interesting and useful to imagine programs as gigantic sci-fi factories that are automated in such a way as the world has never seen: containing millions of pieces of boutique machinery perfectly built to smoothly and seamlessly (we hope) work together for whatever task it is designed to accomplish like the gears of a Swiss watch. Some of these machines inside the factory are enormous, and some tiny and simple. But the factory itself is also a machine, which contains all of these other machines. The users don't ever actually see inside the machine (that would be unsafe, they'd be killed, and there's probably no air in there) but they are sitting in a control booth, miles away, looking at screens displaying the results of the machine.

In MC's machines, I envision the File Objects as little round ball-like orbs with all kinds of ports on them. The entire machine is designed to warehouse, move, and operate these balls, and the database is an enormous cube filled with thousands upon thousands of them.

Lists are these hanging chains of "orb holders", infinitely long (but always somehow just exactly as long as they need to be), that the machine whips around and inserts into other machines that "do things" with the orbs. The player machine, for example, attaches onto the list machines like a zipper. Then it strips the orbs out of the list holder one-by-one and then attach another spider-like machine to the orb which causes it to erupt in sound and light, until its energy is spent. The database is the huge warehouse cube, with miles upon miles of racks of orbs like bowling balls in the universe's largest bowling ball storage facility. At the front of it, are special machines that build those list machines, and fill them with millions of unbelievably fast little "grabber claw" robots that zip down the aisles of orbs to select the right ones, bring them back, and hand them off to the list builder machine that sent it.

And that is, I think, why programmers refer to code as beautiful. Or at least some of the time... When you can see the machine and it is simple, and perfect, and everything has a purpose and no movement or item is wasted in the machine.

The problem is, of course, when you are told you have to build 300 of these new machines for the factory by next Tuesday, and you realize that no one at the company even knows what all of the parts of the machine do anymore, and they just keep putting up new parts and support beams for the old parts that seem to still work right some of the time. Which brings me to: https://www.stilldrinking.org/programming-sucks

Quote
Every friend I have with a job that involves picking up something heavier than a laptop more than twice a week eventually finds a way to slip something like this into conversation: “Bro,1 you don’t work hard. I just worked a 4700-hour week digging a tunnel under Mordor with a screwdriver.”

They have a point. Mordor sucks, and it’s certainly more physically taxing to dig a tunnel than poke at a keyboard unless you’re an ant. But, for the sake of the argument, can we agree that stress and insanity are bad things? Awesome. Welcome to programming.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72444
  • Where did I put my teeth?
Re: Prevent Loss Of Playlist Links After File Update
« Reply #13 on: December 01, 2020, 06:28:37 pm »

I often find it interesting and useful to imagine programs as gigantic sci-fi factories that are automated in such a way as the world has never seen: containing millions of pieces of boutique machinery perfectly built to smoothly and seamlessly (we hope) work together for whatever task it is designed to accomplish like the gears of a Swiss watch. Some of these machines inside the factory are enormous, and some tiny and simple. But the factory itself is also a machine, which contains all of these other machines. The users don't ever actually see inside the machine (that would be unsafe, they'd be killed, and there's probably no air in there) but they are sitting in a control booth, miles away, looking at screens displaying the results of the machine.
You sound like Elon Musk.  I like it.
Quote
And that is, I think, why programmers refer to code as beautiful.
I don't think I've ever heard a programmer call code beautiful.  Usually, it's "Who wrote this garbage?  It's unreadable.  I'm going to have to re-write it from scratch."
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Prevent Loss Of Playlist Links After File Update
« Reply #14 on: December 01, 2020, 07:04:01 pm »

I don't think I've ever heard a programmer call code beautiful.  Usually, it's "Who wrote this garbage?  It's unreadable.  I'm going to have to re-write it from scratch."

Oh for sure. Read the article I linked to...  ;D ;)
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72444
  • Where did I put my teeth?
Re: Prevent Loss Of Playlist Links After File Update
« Reply #15 on: December 02, 2020, 06:41:05 am »

Oh for sure. Read the article I linked to...  ;D ;)
Hilarious!

I liked this, of course:

"There’s a theory that you can cure this by following standards, except there are more “standards” than there are things computers can actually do ..."
Logged
Pages: [1]   Go Up