Web Images News Groups Scholar Blogs Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
iTunes script
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
tonysathre  
View profile  
 More options Oct 21, 11:21 pm
Newsgroups: microsoft.public.scripting.vbscript
From: tonysathre <tonysat...@gmail.com>
Date: Wed, 21 Oct 2009 16:21:05 -0700 (PDT)
Local: Wed, Oct 21 2009 11:21 pm
Subject: iTunes script
I've been looking for a way to embed the iTunes downloaded album art
into the actual MP3 files so when I'm streaming my music from home
computer to my iPhone using Simplify Media, it shows the artwork. I
have found a script that can automate this, but apparently it only
works on iTunes 7. The COM interface, or ActiveX controls must be
different. Could anyone port this script to work with iTunes 9? The
script is below.

'
########################################################################### ####
' #
' # itunes_insert_artwork.vbs
' #
' # This script will tag your files using artwork downloaded using
iTunes 7
' #
' # written by: Robert Jacobson (http://mysite.verizon.net/teridon/
itunesscripts)
' # Last Updated: 03 Jan 2007
' # Version 1.0
' #
' # This script is GPL v2.  see http://www.gnu.org/copyleft/gpl.html
' #
' # Use option "-k" to keep the artwork files extracted
' # (in the same location as the song file)
' # (the default is to remove the files)
'
########################################################################### ####

Option Explicit

Dim iTunesApp        ' iTunes.Application object used to access the
iTunes application.
Dim tracks           ' The tracks collection object of the Library
object.
Dim TrackPath        ' The path to the track
Dim ArtPath              ' The path to the artwork
Dim i                ' A counter variable.
Dim Msg              ' A string for a message.
Dim f                ' A file object.
Dim sources
Dim source
Dim playlists
Dim playlist
Dim playlistName
Dim j
Dim m
Dim c
Dim songName
Dim artist
Dim result
Dim listarray
Dim num
Dim k
Dim track
Dim numtracks
Dim FormatArray(4)
Dim ExtArray(4)
Dim Artobj
Dim Art
Dim ArtDir
Dim Format
Dim BasePath
Dim fso
Dim NumFiles
Dim KeepFiles
Dim args
Dim arg

Set fso = CreateObject("Scripting.FileSystemObject")

FormatArray(0) = "Unknown"
FormatArray(1) = "JPEG"
FormatArray(2) = "PNG"
FormatArray(3) = "BMP"
ExtArray(0) = "unk"
ExtArray(1) = "jpg"
ExtArray(2) = "png"
ExtArray(3) = "bmp"

Set iTunesApp  = CreateObject("iTunes.Application.1")
Set sources = iTunesApp.Sources

Dim vers
vers = iTunesApp.Version

Dim Reg1
Set Reg1 = new RegExp
Reg1.Pattern = "^7"
if Reg1.Test(vers) Then
        ' yay
Else
        Wscript.Echo "This script requires iTunes 7"
        Wscript.Quit
End If
KeepFiles = False

Set args = WScript.Arguments
' Scan command line arguments
For Each arg in args
  ' Is it a flag.
  If Instr(1, arg, "-", 1) = 1 or Instr(1, arg, "/", 1) = 1 Then
    ' Check for list flag
    If UCase(arg) = "-K" or UCase(arg) = "/K" then
 KeepFiles = True
    End If
  End If
Next

For i = 1 to sources.Count
        Set source = sources.Item(i)

        IF source.Kind = 1 Then
                Set playlists = source.Playlists
                Wscript.Echo "Select from the following playlists" & chr(13) & chr
(10)
                For j = 1 to playlists.Count
                        Set playlist = playlists.Item(j)
                        playlistName = playlist.Name
                        Wscript.Echo j & ": " & playlistName
                Next
                Wscript.Echo ""
                Wscript.StdOut.Write "Enter comma-separated lists to process: "
                result = Wscript.StdIn.ReadLine

                listarray = split(result, ",")
                For k = 0 to UBound(listarray)
                        num = listarray(k)
                        Set playlist = playlists.Item(num)
                        playlistName = playlist.Name
                        Wscript.Echo ""
                        Wscript.Echo chr(9) & "Processing playlist " & num & ": " &
playlistName

                        Set tracks = playlist.Tracks
                        numtracks = tracks.Count
                        Wscript.Echo chr(9) & "tracks: " & numtracks
                        NumFiles = 0
                        For m = 1 to numtracks
                                If m > tracks.Count Then Exit For
                                Set track = tracks.Item(m)
                                'Wscript.Echo "num: " & numtracks & " Count: " & tracks.Count
& " m: " & m

                                If track.Kind = 1 Then
                                        songName = track.Name
                                        artist = track.Artist
                                        TrackPath = track.Location
                                        Set Artobj = track.Artwork
                                        For c = 1 to Artobj.Count
                                                Set Art = Artobj.Item(c)
                                                if Art.IsDownloadedArtwork Then
                                                        Format = Art.Format
                                                        'Wscript.Echo "Format is " & FormatArray(Format)
                                                        ArtDir = fso.GetParentFolderName(TrackPath)
                                                        'Wscript.Echo "Artdir is " & ArtDir
                                                        'ArtDir = fso.GetBaseName(ArtDir)
                                                        Dim RegX
                                                        Set RegX = new RegExp
                                                        RegX.Pattern = "[/:\\\*\?""""<>]"
                                                        RegX.Global = True
                                                        songName = RegX.Replace(songName, "-")
                                                        'songName = Replace(songName, "/", "-")
                                                        ArtPath = fso.BuildPath(ArtDir, songName & "." & ExtArray
(Format))
                                                        Wscript.Echo "artpath is " & ArtPath
                                                        ' save to file
                                                        Art.SaveArtworkToFile(ArtPath)
                                                        ' insert from file into track tag
                                                        Art.SetArtworkFromFile(ArtPath)
                                                        if (KeepFiles) Then
                                                                ' nothing
                                                        Else
                                                                fso.DeleteFile(ArtPath)
                                                        End If
                                                        NumFiles = NumFiles + 1
                                                End If
                                        Next

                                End If
                        Next
                        Wscript.Echo NumFiles & " files processed in playlist " &
playlistName
                Next

                'End If
        End If
Next

Thanks a lot,

Tony


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Mueller  
View profile  
 More options Oct 24, 12:20 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Alexander Mueller <mille...@hotmail.com>
Date: Sat, 24 Oct 2009 14:20:41 +0200
Local: Sat, Oct 24 2009 12:20 pm
Subject: Re: iTunes script
tonysathre schrieb:

> I've been looking for a way to embed the iTunes downloaded album art
> into the actual MP3 files so when I'm streaming my music from home
> computer to my iPhone using Simplify Media, it shows the artwork. I
> have found a script that can automate this, but apparently it only
> works on iTunes 7. The COM interface, or ActiveX controls must be
> different. Could anyone port this script to work with iTunes 9? The
> script is below.

The COM-interface probably didn't change, simply because
that's forbidden to COM-interfaces. That doesn't mean that
some SW-designers don't care about, but it happens fairly rarely.
Sometimes implementation changes, sometimes it gets corrupted
with a new release - but most likely the problem is a different
one, that has to do with data processed or the logic of the script
itself or the communication between the devices or ...

In order for helping you fixing it you should provide details
of the lines of code that don't "work" any more or the
conditions that are no longer met or simply the observations
you make.
Posting 200 lines of code and hope someone will tell you its
line 179, Column 24 will work if the problem is simply
syntactical, but not if it is functional.

So plz, provide some details of what exactly doesn't work

MfG,
Alex


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Oct 24, 12:44 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Sat, 24 Oct 2009 05:44:04 -0700 (PDT)
Local: Sat, Oct 24 2009 12:44 pm
Subject: Re: iTunes script
On Oct 24, 8:20 am, Alexander Mueller <mille...@hotmail.com> wrote:

You make very good points.  I would add that in many cases, it is
backward compatibility that is the problem and that later version are
likely to work, though not guaranteed.  I was wondering in this case
if the problem is that the script hard codes a test for version 7 and
not 'greater than 6'.  However, since I don't use iTunes (horrors), I
have no way to check if changing the test to allow execution for later
versions would help.
_____________________
Tom Lavedas

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve  
View profile  
 More options Oct 25, 9:05 am
Newsgroups: microsoft.public.scripting.vbscript
From: "Steve" <cerberu...@gmail.com>
Date: Sun, 25 Oct 2009 05:05:36 -0400
Local: Sun, Oct 25 2009 9:05 am
Subject: Re: iTunes script

tonysathre wrote:
> I've been looking for a way to embed the iTunes downloaded album art
> into the actual MP3 files so when I'm streaming my music from home
> computer to my iPhone using Simplify Media, it shows the artwork. I
> have found a script that can automate this, but apparently it only
> works on iTunes 7. The COM interface, or ActiveX controls must be
> different. Could anyone port this script to work with iTunes 9? The
> script is below.

The script *should* work with iTunes 7 *and later* but the version test
is too simple-minded:

> Dim vers
> vers = iTunesApp.Version
> Dim Reg1
> Set Reg1 = new RegExp
> Reg1.Pattern = "^7"
> if Reg1.Test(vers) Then
> ' yay
> Else
> Wscript.Echo "This script requires iTunes 7"
> Wscript.Quit
> End If

The test only accepts version strings that start with "7"; it assumes
that other versions must be earlier. (BTW, similar simple-mindedness is
the same reason that Opera 10.00 identifies itself as "Opera/9.80" in
its browser identification string--scripts that just tested the first
digit of the version would decide that the current version is actually
version 1.)

This test worked fine when iTunes V7.0 was bright and shiny. If the
script is for your personal use only, you can just remove the test (and
cross your fingers whenever you update iTunes). If you intend to share
the script, you can make the version test smarter.

You can download the iTunes COM SDK from
http://developer.apple.com/sdk/itunescomsdk.html
(you might have to join the Apple Developers Club first).

--
Steve

Horse sense is the thing a horse has which keeps it from betting on
people. -W. C. Fields


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tonysathre  
View profile  
 More options Oct 27, 10:12 pm
Newsgroups: microsoft.public.scripting.vbscript
From: tonysathre <tonysat...@gmail.com>
Date: Tue, 27 Oct 2009 15:12:02 -0700 (PDT)
Local: Tues, Oct 27 2009 10:12 pm
Subject: Re: iTunes script
Thanks a lot for the suggestions. I have already tried removing the
following, with no luck:

> Dim vers
> vers = iTunesApp.Version
> Dim Reg1
> Set Reg1 = new RegExp
> Reg1.Pattern = "^7"
> if Reg1.Test(vers) Then
> ' yay
> Else
> Wscript.Echo "This script requires iTunes 7"
> Wscript.Quit
> End If

I have also tried changing this part: Reg1.Pattern = "^7" to 9, but it
didn't work either. Below is the error I get when running it with, or
without those changes.

(67, 1) Microsoft VBScript runtime error: ActiveX component can't
create object: 'iTunes.Application.1'

Thanks,

Tony


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Lavedas  
View profile  
 More options Oct 28, 12:04 am
Newsgroups: microsoft.public.scripting.vbscript
From: Tom Lavedas <tglba...@cox.net>
Date: Tue, 27 Oct 2009 17:04:14 -0700 (PDT)
Local: Wed, Oct 28 2009 12:04 am
Subject: Re: iTunes script
On Oct 27, 6:12 pm, tonysathre <tonysat...@gmail.com> wrote:

You need to open the registry and search for iTunes and check for the
current version (the final number) to see if it has changed.  Or you
can just try removing the number. That often, but no always, works.
________________
Tom Lavedas

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Mueller  
View profile  
 More options Oct 28, 9:21 pm
Newsgroups: microsoft.public.scripting.vbscript
From: Alexander Mueller <mille...@hotmail.com>
Date: Wed, 28 Oct 2009 22:21:11 +0100
Local: Wed, Oct 28 2009 9:21 pm
Subject: Re: iTunes script
tonysathre schrieb:

Better use the version-independent ProgID, e.g.
'iTunes.Application'. If this still doesn't work then
ITunes isn't probably properly installed (or at least its COM-part)

As for the version check, the version-string returns sth like:
'8.1.0.52' (major.minor.revision.build), so you need the digits
before the first dot, which will be 2 digits soon, starting with
iTunes 10. If RegExp is the choice, a better pattern and numeric
check was:

        Set Reg1 = new RegExp
        Reg1.Pattern = "^(\d+?)\..+$"
        Dim majorVer
        majorVer = Reg1.Replace(iTunesApp.Version, "$1")
        If Not IsNumeric(majorVer) Then
                WSH.Echo "Error detecting iTunes-version"
                WSH.Quit
        ElseIf CInt(majorVer) < 7 Then
                WSH.Echo "This scripts requires iTunes 7 or higher"
                WSH.Quit
        'Else 'Version OK
        End If

HTH,
Alex


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google