Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foo-tunes (Read 19941 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foo-tunes

Hello everyone,
being a fan of both foobar2000 on desktop and iPhone on the go :) I couldn't live with
foo_dop not working with iOS 5 devices (no album art, no playback stats) so I started
writing a solution of my own and here is the first version.

https://github.com/kompot/foo-tunes/

Current features are:
- Bidirectional playback statistics update between iPod/iTunes and foobar2000
- Tag mappings support (meaningful album sort by year, iTunes compilation tag based on album artist value are included)
- Album art attach on-the-fly
- Separate folder for iPod music (you should put files to be sent to iPod there)
- Uses iTunes COM interface to interact with iPod, so further updates to iTunes should not break `foo-tunes`

More detailed readme is on github.

Feel free to grab latest sources and try it
https://github.com/kompot/foo-tunes/zipball/master

This is first public release, so please do not expect production quality from it,
but I'm really looking forward to get some feedback. Reply here or post issues on github.

foo-tunes

Reply #1
I'm just posting to tell you I hope you haven't been discouraged by the lack of feedback on your project.  I haven't used your scripts, as I intend to stay on 4.3 on my iPhone 4 as long as possible simply to have a working foo_dop.  But I'm sure eventually I will be forced to upgrade, either due to apps I need requiring iOS5, or because of a phone upgrade when iPhone 5 comes out.

Although not as convenient as foo_dop, from what I read, it looks like it provides the same functionality, so that's good.  Thanks for your efforts!

foo-tunes

Reply #2
Although not as convenient as foo_dop, from what I read, it looks like it provides the same functionality, so that's good. Thanks for your efforts!

Thanks for support :)

As far as I can see right now - main inconvenience is that you can't say "hey, send these
tracks to my iPod and convert them if required". You need 2 clicks:
- convert (or copy)
- run sync.cmd to perform actual sync

At this moment I can't think of a way to do that any other way but writing a foobar plugin.
A tough solution could be writing a method in foo-tunes that takes file pathes as input
and converts them on-the-fly either using foobar2000 converter and command line interface
or some external converter. Probably I'll try to investigate that.

And yeah, I do love foo_dop but with all those cloud changes by Apple you can't be sure solution will be found (media monkey/gtkpod guys trying to hack music sync for 3 months by now, quite a long time).

foo-tunes

Reply #3
Hi kompot,

Thanks for the plugin.
I don't quite understand how this plugin handles embedded album art. It seems that it relies on converter plugin to copy .jpg from original folder to the destination folder (forgive me if I'm worng).
Personally I don't mind to manually sync AAC files to IPhone via Itunes, and I'm looking for a plugin that can sync my FLAC library to AAC library without loosing album arts during conversion.



foo-tunes

Reply #4
I don't quite understand how this plugin handles embedded album art. It seems that it relies on converter plugin to copy .jpg from original folder to the destination folder (forgive me if I'm worng).

Yeah, it acts exactly this way - front.jpg/folder.jpg/cover.jpg/*.jpg should present in the album folder and it's attached by iTunes when adding files to iPod (there's a possibility that iTunes understands embedded album art but I didn't investigate that).

 

foo-tunes

Reply #5
I'll give it a try later! Thanks for your effort.
So, if I'm not interested in preserving playcount data from the iOS5 dvice, I should:
copy the tracks I want on my iOS5 device to the musicNotTrackedFolder
run the sync.cmd

and that's it?


foo-tunes

Reply #7
Doesn't seem to work for me. I'm pretty sure I followed the directions as best as possible. Here's an error I get when I run sync.cmd:

Code: [Select]
D:\Users\blazemonkey\Desktop\kompot-foo-tunes-abddee0>cscript foo-tunes.js
Microsoft ® Windows Script Host Version 5.8
Copyright © Microsoft Corporation. All rights reserved.

D:\Users\blazemonkey\Desktop\kompot-foo-tunes-abddee0\foo-tunes.js(28, 1) Micros
oft JScript runtime error: Bad file name or number


Here's the user definable content in the foo-tunes.js file:

Code: [Select]
file = new ActiveXObject("Scripting.FileSystemObject");
eval(file.OpenTextFile("lib/libraries.js", 1).ReadAll());
eval(file.OpenTextFile("inc/includes.js", 1).ReadAll());

foobar2000Path = "C:\\Program Files (x86)\\foobar2000\\foobar2000.exe";
musicTrackedPath  = "E:\\iTunesSync\\music-iphone\\";
musicNotTrackedPath  = "E:\\iTunesSync\\music-iphone-not-tracked\\";
copyCommandName = "Copy: iTunesSync";
allowedMusicTypes = new Hashtable();
allowedMusicTypes.put("mp3", "");
allowedMusicTypes.put("m4a", "");
tagMappings = ""
  // to be correctly sorted within artist view and within album view
  + '"FORMAT:ALBUMSORTORDER:%album artist% %date%";'
  // for compilations to appear in `compilations` section
  + '"FORMAT:ITUNESCOMPILATION:$if($stricmp($meta(album artist),various artists),1,)";'
;


foo-tunes

Reply #9
Thanks for your report, seems like it fails when directory "logs" is absent. I added an issue about this
https://github.com/kompot/foo-tunes/issues/4

Please, create this folder and try again (and there should appear a log file which might help in debugging).


Hey kompot,
I have this folder present (same folder as the sync.cmd) and I'm still getting this error. Had a poke around the js but I can't see why it's complaining now.
Also wondering how exactly the mappings work. I have album title itself being mapped to
Code: [Select]
[quote]'['%date%[-%INDEX%]']' %album%[/quote]
for instance, and I'd quite like that - so the year is actually visible on the iPhone. Not sure what I'm mapping it to (FORMAT:something?)

Thanks for your work!

foo-tunes

Reply #10
I'm still getting this error. Had a poke around the js but I can't see why it's complaining now.

What error exactly? In the output there is a line reference to foo-tunes.js that fails.
E. g. "foo-tunes.js(28, 1) Microsoft JScript runtime error:" means that line 28 failed (really bad that if error occurs
in an include file it still does complain about foo-tunes.js - don't know how to resolve that)

Also wondering how exactly the mappings work. I have album title itself being mapped to'['%date%[-%INDEX%]']' %album% for instance, and I'd quite like that - so the year is actually visible on the iPhone. Not sure what I'm mapping it to (FORMAT:something?)

foo_masstagger is used for tag mappings
http://wiki.hydrogenaudio.org/index.php?ti...0.9/foo_masstag
exactly you should examine command line interface
http://wiki.hydrogenaudio.org/index.php?ti..._line_interface
So you can set it this way (didn't try but should work)
Quote
+ '"FORMAT:ALBUM:%date% %album%";'

foo-tunes

Reply #11
Doesn't seem to work for me.

Thanks for your report, seems like it fails when directory "logs" is absent. I added an issue about this
https://github.com/kompot/foo-tunes/issues/4

Please, create this folder and try again (and there should appear a log file which might help in debugging).


Hey Kompot, the folder "logs" actually was created on the first go, and the error that I was getting continued after the logs folder was created, but there are no log files generated apparently..

foo-tunes

Reply #12
Hey Kompot, the folder "logs" actually was created on the first go, and the error that I was getting continued after the logs folder was created, but there are no log files generated apparently..

My bad, code to create this folder if absent was already there :-)
But still no clue why that error. Is your logs dir completely empty?
One folder for each script run should be created (named as "year-month-day hour:minute:second").

Will think of a mechanism to debug what actually failed - right now it's known to be in inc/Logger.js

foo-tunes

Reply #13
My bad, code to create this folder if absent was already there :-)


Yeah, I saw it there

But still no clue why that error. Is your logs dir completely empty?


Yeah, so the error I'm getting is precisely the same one -
Code: [Select]
foo-tunes.js(29, 1) Microsoft JScript runtime error: Bad file name or number

It's line 29 now because I added one for album title formatting.

I created the logs directory. As the normal user in the cmd prompt window, I have the necessary permission to write to that folder.
I'm using WinXP in VMware Fusion on a Mac by the way - but it shouldn't make any difference.

foo-tunes

Reply #14
OK; got it. I'm not sure why it works for you, but the problem is it's trying to create folders/filenames with colons in them.
I changed every instance of colons in the date formats to full stops.
Code: [Select]
%H.%M.%S


That seemed to work. I have iTunes already open and run the command. It complains about rescanning folders, but I'm not using the play count stuff (I have the plugin installed but may not have set the folders up as expected)...

I'm now waiting for the bloody thing to do its syncing of apps off the phone - I rarely sync as I hate using iTunes
But it looks like it's doing its thing. w00t!

foo-tunes

Reply #15
OK; got it. I'm not sure why it works for you

Seems like it's Mac OS X that doesn't allow ':' in paths.
Btw, I have ubuntu and virtualbox with WinXP))

So ok, I'll replace ':' with something other.

foo-tunes

Reply #16
OK; got it. I'm not sure why it works for you

Seems like it's Mac OS X that doesn't allow ':' in paths.
Btw, I have ubuntu and virtualbox with WinXP))

So ok, I'll replace ':' with something other.


Cool you're using virtual Windows too

I'm trying again now - I noticed I forgot to configure file operations to copy images, so I'll do that this time.

So I got it to get further that time, but I find it's failing on some foobar commands - rescanning folders and copying the files. I guess I have it configured slightly wrongly.
Code: [Select]
ERROR 2012-02-08 23.54.20     command failed Z:\raven On My Mac\Dropbox\foobar20
00\foobar2000.exe "/command:Rescan Folders"
INFO  2012-02-08 23.54.20     iPod `Peter's iPhone` found, free space 89%
ERROR 2012-02-08 23.54.20     command failed Z:\raven On My Mac\Dropbox\foobar20
00\foobar2000.exe /runcmd-files="Copy: iTunesSync"  E:\Music-for-iPhone-done\

After this, it basically sits there waiting. iTunes has done its sync in the background, but the script appears not to be doing anything else now.

Really for me I'd be happy to simply:
1) copy the files I want to sync into another folder somewhere, with artwork;
2) get the script to change the tags to my desired patterns as necessary, add ITUNESCOMPILATION etc.
3) upload!

I don't really want to *sync*, so once those files have been tampered with, I would just delete them. To my mind they're just temporary files, there to have their tags changed and cover images embedded. I can create/edit playlists and delete files from within the iPhone now after all.

foo-tunes

Reply #17
Oops, OK that could be because I didn't have the iTunesSync command setup in texttools. Done that now.
Nevertheless, the commands are mostly failing. I now have:

Code: [Select]
ERROR 2012-02-09 00.05.20     command failed Z:\raven On My Mac\Dropbox\foobar2000\foobar2000.exe "/command:Rescan Folders"
INFO  2012-02-09 00.05.20     iPod `Peter's iPhone` found, free space 89%
ERROR 2012-02-09 00.05.21     command failed Z:\raven On My Mac\Dropbox\foobar2000\foobar2000.exe /runcmd-files="Copy: iTunesSync"  E:\Music-for-iPhone-done\
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\01 - Living is Free.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\02 - My Roommate is Turning into a Monster.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\03 - Red Devil.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\04 - Mama's Little Boy.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\05 - We Are the Chopped.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\06 - No Sex.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\07 - Rich Guns.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\08 - No Rest for the Wicked.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\09 - Living in Detente.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\10 - Try Not to Stutter.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\11 - I'm All Wet.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\12 - Approaching Zero.mp3
INFO  2012-02-09 00.05.33     adding track to library E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\13 - Forget Your Life.mp3
ERROR 2012-02-09 00.05.33     command failed Z:\raven On My Mac\Dropbox\foobar2000\foobar2000.exe /tag:"FORMAT:ALBUMSORTORDER:%album artist% %date%";"FORMAT:ITUNESCOMPILATION:$if($longer(%track artist%,),1,%ipod_compilation%)";"FORMAT:ALBUM:[%date%] %album%"; "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\01 - Living is Free.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\02 - My Roommate is Turning into a Monster.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\03 - Red Devil.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\04 - Mama'sLittle Boy.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\05 - We Are the Chopped.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\06 - No Sex.mp3" "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\07 - Rich Guns.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\08 - No Rest for the Wicked.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\09 - Living in Detente.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\10 - Try Not to Stutter.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\11 - I'm All Wet.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\12 - Approaching Zero.mp3"  "E:\Music-for-iPhone-done\NoMeansNo\[1982] Mama\13 - Forget Your Life.mp3"


And even then, everything from the 4th line on only happened because I dragged the tracks back into foobar and ran the RunCommand from the context menu...

Two other things: Not sure if I need to put single quote marks around square brackets in masstagger? Can't find that info on the online help. So I want the album title to be
[1982] Mama
Do I put
'['%date%']' %album%
like I would with other tagformatting? And of course escape the single quotes in the javascript  Or do I not need the quotes?

So anyway... It'd be nice if I could get past this to the next step, which would be adding album artwork and changing the tags. Thanks for this script anyway - I feel it'll be very useful once I've ironed out my little problems!


foo-tunes

Reply #19
Nevertheless, the commands are mostly failing.
Seems like there were lots of intefering bugs concerning spaces in paths.

Published version 0.0.2
https://github.com/kompot/foo-tunes/zipball/v0.0.2
these bugs are fixed
https://github.com/kompot/foo-tunes/issues?...mp;state=closed

Give it a try.

Tried 0.0.2, it throws the same error but on a different line..
Code: [Select]
E:\kompot-foo-tunes-086d2de>cscript foo-tunes.js
Microsoft ® Windows Script Host Version 5.8
Copyright © Microsoft Corporation. All rights reserved.

E:\kompot-foo-tunes-086d2de\foo-tunes.js(29, 1) Microsoft JScript runtime error:
 Bad file name or number


foo-tunes

Reply #21
https://github.com/kompot/foo-tunes/zipball/v0.0.2

Ace. This seems to work! Woohoo!
I had my formula wrong - looks like I do need the escaped single-quotes around my square brackets.
So I'll try it again tomorrow, maybe with more than just the NoMeansNo discography *hehe*

kompot: if I want to just put tracks on but not remove tracks which aren't in my local "for iPhone" folder - i.e. if I want to add a second batch of tracks to the iPhone - is the script as it's setup going to do what I want? Or is it going to just replace what's on the iPhone with whatever I try to sync next time?

If not, can you give me some quick pointers as to how to rewrite it to not do that? Is it as simple as pulling out the relevant script call? I'm reasonably adept at programming, just want to be sure.

Similarly, if I don't care about syncing play counts etc, can I detach that from the process easily?

foo-tunes

Reply #22
Right now it will delete tracks from iPod if they are not found in local folder. And as I said before it will also try to sync stats anyway.
Basically, you want a command named "send to iPod one-way". I do understand it's a perfectly healthy use case and I will definitely implement this scenario (send all files in folder not on iPod and quit).

Quote
Is it as simple as pulling out the relevant script call?

It should be (the idea with root script was exactly about that) but I didn't tested that so might fail.

You can try commenting this at least
  iTunes.removeTracksNotOnDisk();
  foobar2000.syncPlaybackStats();

foo-tunes

Reply #23
Tried 0.0.2, it throws the same error but on a different line..

 hands.sys failed - didn't fix `:` everywhere. Please try again.
https://github.com/kompot/foo-tunes/zipball/v0.0.2


Still no luck. Different error this time though, its complaining about ClipboardHelper which was registered successfully, apparently..

Code: [Select]
E:\kompot-foo-tunes-9604a46>cscript foo-tunes.js
Microsoft ® Windows Script Host Version 5.8
Copyright © Microsoft Corporation. All rights reserved.

E:\kompot-foo-tunes-9604a46\foo-tunes.js(31, 1) WScript.CreateObject: Could not
create object named "ClipboardHelper.ClipBoard".

foo-tunes

Reply #24
Tried 0.0.2, it throws the same error but on a different line..

 hands.sys failed - didn't fix `:` everywhere. Please try again.
https://github.com/kompot/foo-tunes/zipball/v0.0.2


Still no luck. Different error this time though, its complaining about ClipboardHelper which was registered successfully, apparently..


Turns out the script needs be run using the 32 bit wscript.exe in Win 7 64 bit. I was able to resolve this by replacing the contents of sync.cmd with:

Code: [Select]
%windir%\SysWOW64\wscript.exe foo-tunes.js