Author Topic: iPod & iPhone Driver Plugin 2.0  (Read 18305 times)

BoringName

  • Full Member
  • ***
  • Posts: 209
This is a fork of the original iPod & iPhone Driver Plugin 2.0 made by Boroda. Most of it is the original code, I've just changed the functionality enough that it deserves to be listed separately.

I will update this post with more info after I have finished uploading the plugin to website.

edit: Ok that's done. https://getmusicbee.com/addons/plugins/463/ipod-amp-iphone-driver-2-0/

Here are the main differences.
- An option form when you first activate the plugin to choose what you want to sync.
- Play counts and skip counts will be added to MB play/skip count total and be zeroed in iTunes. The original plugin overwrote values depending on last played date.
- The option to disable refreshing metadata from files in iTunes. This substantially increased the sync time on the library I used for testing. It was 36000 songs stored on a mechanical drive. Normal sync was 40-50min, with metadata refresh turned off this went down to 8 minutes.
It's only necessary if you change data for a song that is stored in the id3 tags. It's quicker to just delete the song out of itunes and let it get added in the next sync. Just be careful not to delete a song with play counts and if you have played the song on your device, click work offline instead of plugging in your device and do a sync. When it's finished sync your device with iTunes separately. Any play counts will get incremented the next time you sync with MB.
Obviously if you have changed a lot of songs then tick refresh meta and wait it out or if you have a smaller library it's probably worth leaving it ticked.
- Playlists are now deleted from iTunes and added straight back in to be repopulated. There was a bug (in iTunes 10 anyway) where the tracks wouldn't all get removed before repopulating which would result in double ups. It's a work around for the bug and means less api calls.

Clearly this means iTunes is no longer an exact sync of MB. It assumes iTunes is solely there to facilitate communications between MB and iDevices.

Not sure if it makes much difference but I deleted auto playlists out of iTunes. Recently added etc...

The progress information is all over the place but I think that is an MB issue. It will say "5 of No Files" instead of "5 of 36000". And the message bar at the bottom of the screen has incorrect percentages.

I have only tested this on an iPod Classic. I have no idea how it will go with an iPhone. I assume if the plugin doesn't play nice with it you can just click the work offline button, sync to iTunes and then sync your iPhone with iTunes separately. It's just the play counts will not get updated until you do another sync with MB.

I would recommend not syncing ratings from iTunes to MB. iTunes does that stupid pseudo rating thing with hollow stars and I'm not sure how that gets returned by the API. Use at your own risk.

Out of the 36000 songs, 5 failed to copy initially. If your library is big you have to wait a little while for MB to produce a summary window (just be patient). The screen isn't fun to navigate. It isn't obvious but you can click on the right side of the screen and scroll down. My issues seemed to be some really long files paths (109 characters) and a track with accented characters in name. Nāgá - In Hearts Wake.

This is the order that things occur assuming everything is enabled.
1. Any missing tracks are added to iTunes. If it's a playlist it gets deleted in iTunes and recreated (empty at this stage).
2. Any tracks that have been previously synced will refresh metadata from files, ratings will be synced to iTunes and the last played date in iTunes will be overwritten if MB is greater.
3. Playlists are repopulated with tracks. Any files not selected in the sync are removed from iTunes (if deleting missing items is checked)
4. Ratings, play counts and skip counts are synced back to MB (play/skip counts increment MB). If any of these options are enabled the last play date in MB will be overwritten if iTunes is greater. There is no progress indicator for this part, just a message at the bottom of the screen, just be patient, it took less than a minute on my library.

Once its done it will display a successful message at the bottom of the screen (assuming there were no copy fails in point 1.)
Last Edit: June 14, 2022, 01:22:50 PM by BoringName

Bjork77

  • Newbie
  • *
  • Posts: 19
Hey there, I was on. the previous thread. Just wanted to say thanks again for publishing this, and I'm going to be giving this a go on my 7th gen classic 1nce I get home. for some reason my 5ht gen iPod syncs perfectly with musicale without any extra help, but my 7th gen has been much more cumbersome. Hopefully this does the trick!

BoringName

  • Full Member
  • ***
  • Posts: 209
Hey there, I was on. the previous thread. Just wanted to say thanks again for publishing this, and I'm going to be giving this a go on my 7th gen classic 1nce I get home. for some reason my 5ht gen iPod syncs perfectly with musicale without any extra help, but my 7th gen has been much more cumbersome. Hopefully this does the trick!

7th gen is the one I have been testing on. Technically still 6th gen (grey front, black wheel). I have replaced the HDD with an iFlash card and installed 2 x SD cards for 384gb of storage. Works well.

I had a few issues with split albums and some albums displaying the wrong track order on the iPod. This was all associated with inconsistent values in the "album artist" field.

edit: I think MusicBee should sync with the your iPod. I read in another post on here that someone solved their issues by creating a /music folder on the iPod. But play counts won't sync. That was the sole reason I made this version of the plugin, my partner loves her play counts!
Last Edit: June 15, 2022, 01:12:46 AM by BoringName

Bjork77

  • Newbie
  • *
  • Posts: 19
So good news, It works with my 7th gen! the only downside is that for some of my music, I endup getting this error when syncing to iTunes: "Object reference not set to instance of object." I think it has to do with the format of some of my songs, but using the on-the-fly conversion doesn't seem to fix it either.

BoringName

  • Full Member
  • ***
  • Posts: 209
So good news, It works with my 7th gen! the only downside is that for some of my music, I endup getting this error when syncing to iTunes: "Object reference not set to instance of object." I think it has to do with the format of some of my songs, but using the on-the-fly conversion doesn't seem to fix it either.

I think it's more likely a bug in the code or with the itunes API than a file name problem. Any issues I had with songs would just say the copy failed, it wouldn't produce an error like that.

I'm not a programmer and most of the code isn't mine. There is a good chance something I added isn't right. My only experience coding in C# is this plugin. Just putting that out there to temper expectations.

That being said, if you can give me more info about when the error occurs I will do my best.
What version of iTunes?
When exactly does the error occur in the process and what happens.
Does it stop the sync or carry on?
Does it work successfully sometimes?

If your library isn't too large you could probably break it up into playlists of a couple of hundred at a time and just sync individual playlists until you get the error, that should help narrow it down.

edit: A screen shot of the error would be good too.

Bjork77

  • Newbie
  • *
  • Posts: 19
Certainly!

So I've tried using both the offline mode and when the iPod is plugged into the computer. the error happens on any of my files that are lossless (flac to be specific.) I'm only doing one playlist, and it's about 300 songs long. the sync will fail, but it will copy over about 30 percent of the songs in that list (they are lossy). this is with iTunes version 12.12.4.1. The sync will finish with an error, and for all the songs in the list that didn't transfer properly they  were displayed in the results list with this message- "Object reference not set to instance of object".

BoringName

  • Full Member
  • ***
  • Posts: 209
I've got a library of 1000 old songs on my comp I had for my dad (other library I have been testing is on a different computer). This library is a bit of a mess. I tried out the latest version of iTunes 12.12.4.1

First off, the default view options are horrendous.

Anyway, it synced all 1000 songs with no issues (just to iTunes not any devices). Some of them had file paths over 160 char so I guess path length wasn't a problem on the 4 songs that failed on the main library.

I then created a playlist and dumped half the songs in it and tried to sync that, during the "adding songs to playlist" stage it only got through about 150 songs before it stopped. No popup error like yours though, it just stopped processing and said the sync didn't complete at the bottom of the screen.

I'm just going through which songs are missing in the playlist in iTunes and it does seem to be an intermittent thing. There was a bug in version 10 where it wouldn't delete all the songs from the playlist, it would miss a few and when tracks were added back in they were doubled up.

The forum let me know you replied when I tried to post this (cool feature). So yeah, I think there are 2 issues here. 1. There is an issue syncing Flac files. 2. There is an intermittent problem when adding tracks to a playlist I mentioned above.

I'll see what I can do.

Bjork77

  • Newbie
  • *
  • Posts: 19
I got that notification too, haha. Anyways Thanks for looking into it. I use my 5.5 gen classic primarily (better dac) so don't feel rushed by any means. I can't stand the newest version of itunes, but running older versions of itunes causes all sorts of problems (for me at least), especially when I was trying to restore this ipod in the first place.

BoringName

  • Full Member
  • ***
  • Posts: 209
I can't stand the newest version of itunes.

For the few hours I have been playing with it today, I want to stick a fork in my eye. Just horrible.

So the intermittent problem I had just disappeared. I added some code to debug and it was fixed, removed the code I added and it still worked. I guess just closing everything down to copy over the new plugin files fixed whatever problems I was having. Bit strange but I couldn't get it to repeat the problem....

With your problem, iTunes does not support FLAC files and I think the "conversion on the fly" is broken in MusicBee.

No matter what options I selected, it would not even attempt to convert the files. Whether I changed them in the sync screen or Edit Preferences->Devices->iPod & iPhone Driver->Configure.

However, I was able to force a convert by making sure the FLAC files didn't have an embedded image and then saved an album cover just as a file in the folder.

But this just created a new FLAC file in the temp folder which also fails.

Strangely when I trigger this convert, it obeys the "Convert to" setting in the  "on the fly" section. But it doesn't actually convert to the that format. The file in the temp folder just becomes a FLAC file with it's extension changed to whatever I have selected,  .mp3 or .m4a etc...

I've added ALAC support via ffpmeg into MusicBee but it makes no difference.

From what I can tell, the plugin is reporting to MB what formats are supported so that isn't the issue, in any case, when "convert all files" is selected it should do a conversion and it doesn't.

Sorry but there is nothing I can do about this, it's something Steven (MB creator) will have to fix. I'll post it in the bug forum thread.

Your only solution is converting those files into a supported format. ALAC is apples version of FLAC, it's easy to convert with ffpmeg
ffmpeg -i track.flac -acodec alac track.m4a

In other news, I've found if you have delete missing tracks selected it prompts you approve every single track... clicking ok 800 times isn't fun. I'm going to add an "Ok All" to that form.

I also found a bug when syncing small playlists which I will try and fix up. It will say the playlist is deleted. I assume because I need to give it a second to recreate the playlist I just deleted before I start throwing files at it.

BoringName

  • Full Member
  • ***
  • Posts: 209
FYI to anyone using iTunes greater than version 12.5, I've hit the following bug when "delete files that are not on the auto-sync list from the device" is checked -
https://discussions.apple.com/thread/8060627

Tested the crap out of it this afternoon and it's completely random when it will throw the error.

Considering it's still present in version 12.12, I guess they are never going to fix it.

I'll try and figure out a workaround.

edit: Yeah, I don't think I'm getting around that one. Once it has a fit, that's it, any API call just gets rejected until itunes is restarted. I tried version 12.5.5 and 12.5.4 and they were both incredibly slow to add new songs after the first dozen or so, it would get over 10 seconds per song. I've had enough for today, I'll give some other versions a try tomorrow.
Last Edit: June 16, 2022, 01:22:06 PM by BoringName

Bjork77

  • Newbie
  • *
  • Posts: 19
I can't stand the newest version of itunes.

For the few hours I have been playing with it today, I want to stick a fork in my eye. Just horrible.

So the intermittent problem I had just disappeared. I added some code to debug and it was fixed, removed the code I added and it still worked. I guess just closing everything down to copy over the new plugin files fixed whatever problems I was having. Bit strange but I couldn't get it to repeat the problem....

With your problem, iTunes does not support FLAC files and I think the "conversion on the fly" is broken in MusicBee.

No matter what options I selected, it would not even attempt to convert the files. Whether I changed them in the sync screen or Edit Preferences->Devices->iPod & iPhone Driver->Configure.

However, I was able to force a convert by making sure the FLAC files didn't have an embedded image and then saved an album cover just as a file in the folder.

But this just created a new FLAC file in the temp folder which also fails.

Strangely when I trigger this convert, it obeys the "Convert to" setting in the  "on the fly" section. But it doesn't actually convert to the that format. The file in the temp folder just becomes a FLAC file with it's extension changed to whatever I have selected,  .mp3 or .m4a etc...

I've added ALAC support via ffpmeg into MusicBee but it makes no difference.

From what I can tell, the plugin is reporting to MB what formats are supported so that isn't the issue, in any case, when "convert all files" is selected it should do a conversion and it doesn't.

Sorry but there is nothing I can do about this, it's something Steven (MB creator) will have to fix. I'll post it in the bug forum thread.

Your only solution is converting those files into a supported format. ALAC is apples version of FLAC, it's easy to convert with ffpmeg
ffmpeg -i track.flac -acodec alac track.m4a

In other news, I've found if you have delete missing tracks selected it prompts you approve every single track... clicking ok 800 times isn't fun. I'm going to add an "Ok All" to that form.

I also found a bug when syncing small playlists which I will try and fix up. It will say the playlist is deleted. I assume because I need to give it a second to recreate the playlist I just deleted before I start throwing files at it.

Thanks for looking into this; I think what I'll end up doing is making a copy of the files I want on the iPod and transferring them to ALAC, then syncing them from my laptop as opposed to my computer, so the library is separate from my primary library.

BoringName

  • Full Member
  • ***
  • Posts: 209
Steven is looking into the problem so we might have a fix at some point in the future.

I've had a fun morning testing versions of iTunes. Here are the results.
12.5.3.16 - This is the latest version that works perfectly.
12.5.4.42 - Extremely slow to add new tracks. Up to 30 seconds per track, Unusable
12.5.5.5 - Extremely slow to add new tracks. Up to 30 seconds per track, Unusable
12.6.0.95 - Not as slow to add new tracks but still unusable.
12.6.1.25 - Not as slow to add new tracks but still unusable.
12.6.2.20 - Not as slow to add new tracks but still unusable.
12.7.0.166 - Adding new tracks is fine but has the delete bug present in 12.12.4.1

So the latest version the plugin fully work on is 12.5.3.16
Everything between that and 12.7.0.166 is stuffed.

I'm not going to test them all but I will assume everything from 12.7.0.166 to 12.12.41 has the delete bug. So on these versions syncing playlists and using "delete files that are not on the auto-sync list from the device" will cause an intermittent error when deletions need to be made. If you don't need those things these versions might work for you.
If you only sync a few playlists (less than 5) you might not encounter the bug very often but it will happen occasionally, it's completely random. When it happens you need to close MusicBee and make sure iTunes closes with it then try again. Syncing playlists causes it because it deletes the playlist first then recreates it, I had to set it up this way to get around another bug that caused songs in the playlists to get doubled up. I really hate iTunes!

BoringName

  • Full Member
  • ***
  • Posts: 209
Thanks for looking into this; I think what I'll end up doing is making a copy of the files I want on the iPod and transferring them to ALAC, then syncing them from my laptop as opposed to my computer, so the library is separate from my primary library.

This will be fixed in MusicBee 3.5
The following options both convert FLAC files to the specified format in the "Convert to" field.
"Only convert with a format not supported by the device"
"Only convert files with a lossless format"

Files that don't match that criteria get copied across as they are (unless art needs to be imbedded).

You might be able to get it earlier if you keep an eye on this thread for the next beta release.
https://getmusicbee.com/forum/index.php?topic=36464.0


You can get it here now - https://getmusicbee.com/forum/index.php?topic=36529.msg201338#msg201338

To get ALAC encoding in MusicBee you need to add your own encoder. I just used ffmpeg, links to compiled versions are here - https://ffmpeg.org/download.html#build-windows
You need to choose one of the windows options under Get packages & executable files. Extract those Exe files to a folder.

In MusicBee under Edit Preferences->File Converters, scroll down and tick "ALAC Enabled". Then add the location of "ffmpeg.exe" that you saved earlier. Click save. You might need to restart MusicBee before the ALAC option appears in the "Convert to" drop down.
Last Edit: June 19, 2022, 10:17:10 AM by BoringName

Bjork77

  • Newbie
  • *
  • Posts: 19

That's awesome! Thanks for keeping me updated about this. I'll have to give it a go sometime tommorow.

BoringName

  • Full Member
  • ***
  • Posts: 209
I've just updated the plugin. No functional changes, it just co-operates a little better with MB.

When syncing files it will display the progress counts a little better.

The message bar at the bottom of the screen is now readable instead of the hot mess it used to be, so you can navigate to other tabs and still see the progress. Edit: If you have the "status bar" enabled.

It still has a few issues though -
1. If deletes have to be performed you will see the counter go over 100%. Short of a major rewrite of the plugin I can't see a way around this for now so it might be that way for a while.

2. The total includes playists but they don't actually get displayed when syncing occurs. So if you have 80 songs across 20 playlists. The counter will get to 80 of 100 and then complete. Again, I can't see a way around this without a major rewrite.

edit: Actually I have a fix for the playlists. I'll do a bit more testing before I push that out.

edit2: So I totally lied and found a way to do it all without a major rewrite. It will add a small amount of overhead at the start of the sync but I think it's worth. I just want to test it on my partners large library to see how it goes before I push it out in the next few days.
Last Edit: June 21, 2022, 12:45:25 PM by BoringName