FasdUAS 1.101.10 k l !Matthew Russell - 22 Jan 06 l  l  PJHACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK   l l  v0.1a l l NHProof of concept for a system that allows you to fetch and automatically l JDinstall mods (digital bookmarks and/or images and links) to digital  l A;audio via the iTunes interface. There's plenty of room for  l QKimprovement, error checking, user customization, etc. Again, this is merely ! l" "GAa proof of concept hack. If you're an AppleScript guru, feel free!#$ #l% %to pimp this thing out. $&' &l'() (l* *%A few things right off the top:)+, +l- -jdCheck to make sure files being fiddled with are actually m4a or m4b vs mp3 or an unsupported format.,./ .l0 0?9General clean up of sloppy,hacked together AppleScripting/12 1l3 3|vModify name of file that's been bookmarked to reflect bookmarking. Maybe just appent "(bookmarked)" to the track name?245 4l567 6l8 8E?Tracks that are modded are backed up to ~/Music/preModdedTracks79: 9l:;< ;l= =PJHACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK<>? >l?@A @lB B82check to make sure chapter tool exists in the pathACD ClE ErFG FIH .sysoexecTEXTTEXT HmI Iwhich ChapterTool Go $0chaptoollocationchapToolLocationDJK Jl L LZ MN MC OP Oo $0chaptoollocationchapToolLocation Pm Q Qno ChapterTool in NkRRST SIUV .sysodlogaskrTEXT UmW WChapterTool is not in your path! Its last known whereabouts were http://homepage.mac.com/applepodcast/podcasts/Resources/static/podcast_chapter_tool_beta.dmg. Go download it and put it in your path -- somewhere like /usr/bin/VXY  btns XJZZ[ [m\ \OKY]  dflt ]mT^ ^LK_` _l`ab alc c-'get selected track in iTunes and mod itbde dl!f fO!gh gk%iijk jI%* .miscactvnullnullklm lr+5no nl+3p pe+3q qc+3rs rn+1tu t1/1  sele u4+/v  cwin vm-. sm12  list oo 0thelisttheListmwx wr6?yz yI6;{ .corecnte******** {o67 0thelisttheList zo 0 trackcount trackCountx|} |l@@}~ ~Z@^ =@E o@C 0 trackcount trackCount mCD kHZ IHW .sysodlogaskrTEXT mHK "No track selected. Try again  btns JLQ mLO OK  dflt mRS LXZ l__ l__ F@assuming only 1 track selected. If more than 1, choose first one r_i n_e 4`e  cobj mcd o_` 0thelisttheList o 0thetracktheTrack rju njq 1mq  pLoc ojm 0thetracktheTrack o 0thepaththePath lvv rv lv nv 1}  strq lv} nv} 1y}  psxp ovy 0thepaththePath o 0 theposixpath thePOSIXPath s o 0 theposixpath thePOSIXPath o "0theoriginalpaththeOriginalPath l r l n 1  pnam o 0thetracktheTrack o 0 thetrackname theTrackName l l HBgot a track, now prompt user for a location to get a packaged mod. r I .sysodlogaskrTEXT b m 0*Enter a URL for a mod you want to get for  o 0 thetrackname theTrackName  dtxt m http://  btns J m Cancel m OK  dflt m o 0reply Z = n 1  bhit o 0reply m Cancel L l l r l n 1  ttxt o 0reply o 0themodlocationtheModLocation no error checking for now. l I .sysoexecTEXTTEXT m rm -rf /tmp/tmpmod *$clean up if there was a last time... I~} ~.sysoexecTEXTTEXT m mkdir -p /tmp/tmpmod/} Q l I|{ |.sysoexecTEXTTEXT b b m  curl  oz z 0themodlocationtheModLocation m  > /tmp/tmpmod/mod1{ ,& drop it off in an accessible location Ryxw y.ascrerr ********xw k   O  I v v.sysodlogaskrTEXT m   3-Some error occurred while fetching. Aborting.u  u btns  J   t  m OKt sr s dflt mqqr m  null iTunes.appЙQFQU|)H(P ~hookalisL Macintosh HD3H+ iTunes.app_B Applications3c$Macintosh HD:Applications:iTunes.app iTunes.app Macintosh HDApplications/iTunes.app/p L oop l!!nmnm l!!ll A;copy the original iTunes file to a safe location for backup l!, r!, I!(kj k.sysoexecTEXTTEXT m!$  echo ~j oi i0 thehomedir theHomeDir expand the tilde l--hghg !" !r-8#$ #b-4%& %o-0f f0 thehomedir theHomeDir &m03' '/Music/preModdedTracks/ $oe e"0thesafelocationtheSafeLocation"() (I9Dd*c d.sysoexecTEXTTEXT *b9@+, +m9<- - mkdir -p  ,o<?b b"0thesafelocationtheSafeLocationc)./ .IEXa0` a.sysoexecTEXTTEXT 0bET12 1bEP34 3bEL56 5mEH7 7 mv  6oHK_ _0 theposixpath thePOSIXPath 4mLO8 8  2oPS^ ^"0thesafelocationtheSafeLocation`/9: 9lYY]\]\:;< ;lYY[=[ =keextract the actual filename out of thePOSIXPath, meaning the actual name of the file as it is on disk<>? >QY@AB @k\CCDE Dr\gFG Fn\cHI H1_cZ Z txdl I1\_Y Y ascr GoX X0 olddelims oldDelimsEJK JrhuLM LJhmNNOW OmhkP P/W MnQR Q1ptV V txdl R1mpU U ascrKST SlvUV UrvWX Wlv~YT Ynv~Z[ Z4y~S\ S citm \m|}RR [ovyQ Q0 theposixpath thePOSIXPathT XoP P0 thefilename theFileName V1+ there will be an extraneous ' at the end. T]O ]r^_ ^oN N0 olddelims oldDelims _n`a `1M M txdl a1L L ascrO ARKJI K.ascrerr ********JI Bkbbcd cref eoH H0 olddelims oldDelims fngh g1G G txdl h1F F ascrdij iIEkl E.sysodlogaskrTEXT kmm mICThere's a problem determining the track's actual filename. AbortinglDno D btns nJppqC qmr rOKCoBsA B dflt sm@@Ajt? tL>>??uv ul=<=<vwx wl;y; y<6designate actual path to "safe" file that's backed up.xz{ zr|} |b~ ~o: :"0thesafelocationtheSafeLocation o9 90 thefilename theFileName }o8 8"0thesafefilepaththeSafeFilePath{ l7676 l55 ?9unwrap the mod and place its contents in a clean location I43 4.sysoexecTEXTTEXT m .(cd /tmp/tmpmod; tar xzf /tmp/tmpmod/mod13 l2121 l00 f`designate that we're modding the file we just safely moved but want to write it's modded version l// $back to the original location. r b b b m 1+cd /tmp/tmpmod; ChapterTool -x mod.xml -a ' o. ."0thesafefilepaththeSafeFilePath m   -o  o- -"0theoriginalpaththeOriginalPath o, ,.0thechaptertoolcommandtheChapterToolCommand l+*+* I)( ).sysodlogaskrTEXT o' '.0thechaptertoolcommandtheChapterToolCommand( Q  I&% &.sysoexecTEXTTEXT o$ $.0thechaptertoolcommandtheChapterToolCommand% R#"! #.ascrerr ********"! k  I  .sysodlogaskrTEXT m >8Some error occurred while running ChapterTool. Aborting.  btns J m OK  dflt m L  l   I , .hookAdd cTrk@alis 4   file l c o 0thepaththePath m  TEXT  insh n( 4!(  cPly m$'  Library 4!  cSrc m   Library l--    l--  XRthis file is not duplicated in the iTunes library, but none of its tag info is set l--    l-- ("get the current track's properties Q-b k0Y r0= l09 n09 159  pArt l05 105  pTrk o 0 copyartist copyArtist r>K l>G n>G 1CG  pAlb l>C 1>C  pTrk o 0 copyalbum copyAlbum rLY lLU nLU 1QU  pGen lLQ 1LQ  pTrk o 0 copygenre copyGenre R .ascrerr ******** lcc rcp lcl ncl 1hl  pnam lch 1ch  pTrk o "0sanitychecknamesanityCheckName lqq lqq OIthe newly duplicated track should appear just below the current selection lqq ("but do a sanity check to make sure Iqv .hookNextnullnull lww lww lww =7just setting a few properties here. Knock yourself out. Zw    =w   owz "0sanitychecknamesanityCheckName  lz nz 1  pnam lz 1z  pTrk  k r o 0 copyartist copyArtist l n 1  pArt l 1  pTrk r o 0 copyalbum copyAlbum l n !  1  pAlb !l" "1  pTrk# #r$% $o 0 copygenre copyGenre %l& &n'( '1  pGen (l) )1  pTrk  I*+ .sysodlogaskrTEXT *m, ,B >OK;?  dflt ?m6@ @l hm!"eAB AlBC ClDED .aevtoappnull****EFGH .aevtoappnull**** FkIICJJJKKdGH\IQW\ '-78Pmr~}|{zyxw,19> .sysoexecTEXTTEXT $0chaptoollocationchapToolLocation  btns  dflt .sysodlogaskrTEXT .miscactvnullnull  cwin  sele  list 0thelisttheList .corecnte******** 0 trackcount trackCount  cobj 0thetracktheTrack  pLoc 0thepaththePath  psxp  strq 0 theposixpath thePOSIXPath "0theoriginalpaththeOriginalPath  pnam 0 thetrackname theTrackName  dtxt 0reply  bhit  ttxt 0themodlocationtheModLocation 0 thehomedir theHomeDir "0thesafelocationtheSafeLocation  ascr  txdl 0 olddelims oldDelims  citm 0 thefilename theFileName "0thesafefilepaththeSafeFilePath .0thechaptertoolcommandtheChapterToolCommand  file  TEXT  insh  cSrc  cPly .hookAdd cTrk@alis  pTrk ~ pArt }0 copyartist copyArtist | pAlb {0 copyalbum copyAlbum z pGen y0 copygenre copyGenre x"0sanitychecknamesanityCheckName w.hookNextnullnullj EOkvk OhYhO*j O*k/,&EOj E`O_jaakvk OhYhOak/E`O_a,E`O_a,a,E`O_EQ`O_a,E`Oa_%aa a!a"lvla# E`$O_$a%,a&hYhO_$a',E`(Oa)j Oa*j Oa+_(%a,%j WX-.a/a0kvk UOhOa1j E`2O_2a3%E`4Oa5_4%j Oa6_%a7%_4%j O7_8a9,E`:Oa;kv_8a9,FO_aa?kvk OhO_4_=%E`@OaAj OaB_@%aC%_%E`DO_Dj O _Dj WX-.aEaFkvk OhO*aG_aH&/aI*aJaK/aLaM/l NO.*aO,aP,E`QO*aO,aR,E`SO*aO,aT,E`UWX-.hO*aO,a,E`VO*j WO_V*aO,a,._Q*aO,aP,FO_S*aO,aR,FO_U*aO,aT,FYaXaYkvk OaZa[kvk OPUascr ޭ