Bienvenue invité ( Connexion | Inscription )
15 Sep 2007, 09:59
Message
#1
|
|
|
Nouveau Membre Groupe : Membres Messages : 5 Inscrit : 25 Feb 2002 Membre no 2 132 |
Bonjour
Autant le dire tout de suite : je débute en applescript Mon but : Inclure à l'intérieur de chaque piste (fichier physique, pas bibliotèque itunes) un artwork (image) correspondant a un fichier .jpg présent sur mon disque ex : Mettre dans toutes les pistes de l'album "dark side of the moon" l'image "dark side of the moon.jpg" Ce qui marche : J'ai fait un scrip d'une 50aine de lignes qui cherche dans un dossier du disque une image "xxx.jpg" ou xxx correspond aux titres des albums de la selection courante des "tracks" dans itunes. Ca toune dans un "repeat" et ca marche : je récupère la référence du fichier et ça marche (si je fais Tell Application "finder" / open vFileRef / End tell les images trouvées s'ouvrent bien) Ce qui ne marche pas (que je ne sais pas faire) Pour chaque "track" courante (je suis dans une boucle) j'aimerais: - charger l'image - la mettre dans l' "artwork" de la track (j'insite un peu : je veux que l'image soit inclue dans le fichier lui-même, PAS dans la bibliothèque itunes) Est-ce que quelqu'un maitrise le sujet ? Merci de votre aide. Tanguy ---------- Ci-dessous le script en question... (également en pièce jointe) ---------- global vFileRef global vPictFolder global vArtworkData global vPictFullPath global v_TrackSelection tell application "Finder" set vPictFolder to choose folder with prompt "Select the folder pl ease." --set the vPictName to item 5 of v_PictNames -- ok --set the vPicture to item 5 of v_PictItems -- ok --set the vNbpict to count items of v_PictItems --display dialog (vNbpict as string) end tell tell application "iTunes" --activate --set myPlaylist to library playlist if selection is not {} then set v_TrackSelection to a reference to selection repeat with vTrack in v_TrackSelection set vAlbumName to album of vTrack set vAlbumArt to artworks of vTrack set vAlbumpictName to vAlbumName & ".jpg" tell application "Finder" -- verifies if the file exists if (exists file vAlbumpictName of folder vPictFolder) then set vPictFullPath to (vPictFolder & vAlbumpictName) set vFileRef to file vAlbumpictName of folder vPictFolder open {vFileRef} else set vFileRef to empty reference --display dialog ("The picture " & vAlbumpictName & " does NOT exist.") end if end tell if vFileRef is not null then (* C'est ici que j'ai besoin d'aide : J'ai une référence de fichier mais je ne sais pas quoi en faire :-( -> Si la track a déjà un "artwork" je veux le remplacer par l'image -> Si la track n'a pas d'artwork je veux le créer (une tracj peut avoir plusieurs artwork ? c'est pas clair... je n'en veux qu'UN par track) *) end if end repeat else display dialog ("select tracks first !") end if end tell Ce message a été modifié par Tanguy - 15 Sep 2007, 09:59. |
|
|
|
![]() |
| Guest_JackJr300_* |
16 Sep 2007, 18:49
Message
#2
|
|
Guests |
Bonjour
C'est possible en AppleScript avec la classe «data» picture,. on ne peut pas utiliser le chemin de l'image JPEG. Donc, il faut convertir le fichier JPEG au format PICT, et le lire avec (read as picture). Voici le script, il convertit le JPEG en PICT dans un fichier temporaire, va effacer les artworks existants et va insérer l'image dans le fichier. CODE property tempfile : ((path to temporary items as string) & "itunespicturefile_temporaire.pict") global vPictFolder set vPictFolder to choose folder with prompt "Select the folder please." tell application "iTunes" set v_TrackSelection to selection if v_TrackSelection is not {} then repeat with vTrack in v_TrackSelection set thisPict to my getpictData((get album of vTrack) & ".jpg") if thisPict is not "" then delete artworks of vTrack set data of artwork 1 of vTrack to (thisPict) end if end repeat else display dialog ("select tracks first !") end if end tell on getpictData(vAlbumpictName) tell application "Finder" to tell file vAlbumpictName of folder vPictFolder to if exists then set t_file to it as string else return "" end if do shell script "/usr/bin/sips -s format pict " & quoted form of POSIX path of t_file & " --out " & quoted form of POSIX path of tempfile return read (tempfile as alias) from 513 as picture end getpictData |
|
|
|
Tanguy Apple script et iTunes 15 Sep 2007, 09:59
Tanguy CITATION(JackJr300 @ 16 Sep 2007, 19:49) ... 17 Sep 2007, 18:29
JackJr300 Bonjour
CITATION(Tanguy @ 17 Sep 2007, 18... 18 Sep 2007, 03:29
Tanguy OK, j'ai compris le principe du dico; il n... 19 Sep 2007, 20:46
JackJr300 Bonjour
CITATION(Tanguy @ 19 Sep 2007, 20... 20 Sep 2007, 04:40![]() ![]() |
| Nous sommes le : 4th April 2026 - 20:42 |