iTunes UDF


SUBMITTED BY: Guest

DATE: May 28, 2013, 5:29 p.m.

FORMAT: Text only

SIZE: 15.0 kB

HITS: 919

  1. #include <array.au3>
  2. #include <File.au3>
  3. $vol_percent = 10
  4. $Lyric_text = ""
  5. $p_name = "Playlist"
  6. $file_path = ""
  7. $i_num = 1
  8. Global $iTunesApp = ""
  9. Global $Library_Tracks = ""
  10. Global $file = ""
  11. Global $path = ""
  12. $Library_Playlist = ""
  13. $Playlist_Handle = ""
  14. Func _iTunes_Start()
  15. $iTunesApp = ObjCreate("iTunes.Application")
  16. $Library_Playlist = $iTunesApp.LibraryPlaylist
  17. $Library_Tracks = $iTunesApp.LibraryPlaylist.Tracks
  18. $sel_Track = $iTunesApp.SelectedTracks
  19. $current_Track = $iTunesApp.CurrentTrack
  20. $Player_State = $iTunesApp.PlayerState
  21. $Playlist_Handle = $iTunesApp.LibrarySource.Playlists
  22. EndFunc ;==>_iTunes_Start
  23. Func _iTunes_Library_Tracks()
  24. Dim $aArray[1]
  25. For $item in $Library_Tracks
  26. _ArrayAdd($aArray, $item.Name)
  27. Next
  28. $aArray[0] = _iTunes_Library_CountTracks()
  29. Return $aArray
  30. EndFunc
  31. Func _iTunes_Vol_Up($vol_percent)
  32. $iTunesApp.SoundVolume = $iTunesApp.SoundVolume + $vol_percent
  33. EndFunc ;==>_iTunes_Vol_Up
  34. Func _iTunes_Vol_Down($vol_percent)
  35. $iTunesApp.SoundVolume = $iTunesApp.SoundVolume - $vol_percent
  36. EndFunc ;==>_iTunes_Vol_Down
  37. Func _iTunes_Prev()
  38. $iTunesApp.PreviousTrack
  39. EndFunc ;==>_iTunes_Prev
  40. Func _iTunes_Next()
  41. $iTunesApp.NextTrack
  42. EndFunc ;==>_iTunes_Next
  43. Func _iTunes_Current_LyricsSet($Lyric_text)
  44. $iTunesApp.CurrentTrack.Lyrics = $Lyric_text
  45. EndFunc ;==>_iTunes_Set_Lyric
  46. Func _iTunes_Current_LyricsGet()
  47. Return $iTunesApp.CurrentTrack.Lyrics
  48. EndFunc ;==>_iTunes_Set_Lyric
  49. Func _iTunes_Current_ArtworkSaveToTmp()
  50. $file = _TempFile(Default, Default, ".jpg")
  51. $iTunesApp.CurrentTrack.Artwork(1).SaveArtworkToFile($file)
  52. Return $file
  53. EndFunc ;==>_iTunes_Current_Artwork_Get_tmp
  54. Func _iTunes_Current_Artwork_Get($path)
  55. $iTunesApp.CurrentTrack.Artwork(1).SaveArtworkToFile($file)
  56. EndFunc ;==>_iTunes_Current_Artwork_Get
  57. Func _iTunes_Current_Artwork_Set($path)
  58. $iTunesApp.CurrentTrack.Artwork(1).SetArtworkFromFile($path)
  59. EndFunc ;==>_iTunes_Current_Artwork_Set
  60. Func _iTunes_Play_Pause()
  61. $iTunesApp.PlayPause
  62. EndFunc ;==>_iTunes_Play_Pause
  63. Func _iTunes_PlayList_Create($p_name)
  64. $iTunesApp.CreatePlaylist($p_name)
  65. EndFunc ;==>_iTunes_PlayList_Create
  66. Func _iTunes_PlayList_Add($PlayList_Name, $song_Name)
  67. $sng_nm = $Library_Tracks.ItemByName($song_Name)
  68. $Playlist_Handle.ItemByName($PlayList_Name).AddTrack($sng_nm)
  69. EndFunc ;==>_iTunes_PlayList_Add
  70. Func _iTunes_Playlist_Delete($PlayList_Name)
  71. $Playlist_Handle.ItemByName($PlayList_Name).Delete
  72. EndFunc ;==>_iTunes_Playlist_Delete
  73. Func _iTunes_Playlist_Info($PlayList_Name)
  74. $playlist = $Playlist_Handle.ItemByName($PlayList_Name)
  75. $pInfo = _ArrayCreate($playlist.Kind,$playlist.duration,$playlist.shuffle,$playlist.size,$playlist.SongRepeat,$playlist.time,$playlist.Visible)
  76. Return $pInfo
  77. EndFunc ;==>_iTunes_Playlist_Info
  78. Func _iTunes_Playlist_PlayFirst($PlayList_Name)
  79. $Playlist_Handle.ItemByName($PlayList_Name).PlayFirstTrack
  80. EndFunc ;==>_iTunes_Playlist_PlayFirst
  81. Func _iTunes_Playlist_Search($PlayList_Name,$search)
  82. dim $return
  83. $sResults = $Playlist_Handle.ItemByName($PlayList_Name).search($search,0)
  84. for $track in $sResults
  85. _ArrayAdd($return,$track)
  86. Next
  87. Return $return
  88. EndFunc
  89. Func _iTunes_Library_CountTracks()
  90. Return $Library_Tracks.Count
  91. EndFunc ;==>_iTunes_Library_CountTracks
  92. Func _iTunes_Library_AddTrack($path)
  93. $Library_Playlist.AddTrack($path)
  94. EndFunc ;==>_iTunes_Library_AddTrack
  95. Func _iTunes_Song_LyricsGet($song_Name)
  96. return $Library_Tracks.ItemByName($song_Name).Lyrics
  97. EndFunc
  98. Func _iTunes_Song_LyricsSet($song_Name,$lyrics)
  99. $Library_Tracks.ItemByName($song_Name).Lyrics = $lyrics
  100. EndFunc
  101. Func _iTunes_Song_ArtworkSaveToTmp($song_Name)
  102. $file = _TempFile(Default, Default, ".jpg")
  103. $Library_Tracks.ItemByName($song_Name).Artwork(1).SaveArtworkToFile($file)
  104. Return $file
  105. EndFunc ;==>_iTunes_Current_Artwork_Get_tmp
  106. Func _iTunes_Song_Artwork_Get($song_Name,$path)
  107. $Library_Tracks.ItemByName($song_Name).Artwork(1).SaveArtworkToFile($file)
  108. EndFunc ;==>_iTunes_Current_Artwork_Get
  109. Func _iTunes_Song_Artwork_Set($song_Name,$path)
  110. $Library_Tracks.ItemByName($song_Name).Artwork(1).SetArtworkFromFile($path)
  111. EndFunc ;==>_iTunes_Current_Artwork_Set
  112. Func _iTunes_Library_DeleteTrack($song_Name)
  113. $Library_Tracks.ItemByName($song_Name).Delete
  114. EndFunc ;==>_iTunes_Library_DeleteTrack
  115. Func _iTunes_Get_Vol()
  116. Return $iTunesApp.SoundVolume
  117. EndFunc ;==>_iTunes_Get_Vol
  118. Func _iTunes_Vol_Set($vol_percent)
  119. $iTunesApp.SoundVolume = $vol_percent
  120. EndFunc ;==>_iTunes_Set_Vol_Percent
  121. ;Func _iTunes_Get_Selected()
  122. ;dim $sTracks
  123. ;for $track in $iTunesApp.SelectedTracks
  124. ;_ArrayAdd($sTracks,$track)
  125. ;Next
  126. ;return $sTracks
  127. ;EndFunc
  128. Func _iTunes_Get_Selected($flag)
  129. Dim $aSelTracks[1]
  130. Switch $flag
  131. Case 1
  132. For $track In $iTunesApp.SelectedTracks
  133. _ArrayAdd($aSelTracks, $track.name)
  134. $aSelTracks[0] = UBound($aSelTracks)-1
  135. Next
  136. Case 2
  137. For $track In $iTunesApp.SelectedTracks
  138. _ArrayAdd($aSelTracks, $track.Location)
  139. $aSelTracks[0] = UBound($aSelTracks)-1
  140. Next
  141. Case 3
  142. For $track In $iTunesApp.SelectedTracks
  143. _ArrayAdd($aSelTracks, $track.Rating)
  144. $aSelTracks[0] = UBound($aSelTracks)-1
  145. Next
  146. Case 4
  147. For $track In $iTunesApp.SelectedTracks
  148. _ArrayAdd($aSelTracks, $track.Time)
  149. $aSelTracks[0] = UBound($aSelTracks)-1
  150. Next
  151. EndSwitch
  152. Return $aSelTracks
  153. EndFunc ;==>_iTunes_Get_Selected
  154. Func _iTunes_Selected_GetInfo()
  155. dim $sInfo
  156. For $track In $iTunesApp.SelectedTracks
  157. $tInfo = $track.Album & "|" & _
  158. $track.artist & "|" & _
  159. $track.BPM & "|" & _
  160. $track.comment & "|" & _
  161. $track.Compilation & "|" & _
  162. $track.Composer & "|" & _
  163. $track.DateAdded & "|" & _
  164. $track.Duration & "|" & _
  165. $track.EQ & "|" & _
  166. $track.Genre & "|" & _
  167. $track.KindAsString & "|" & _
  168. $track.ModificationDate & "|" & _
  169. $track.PlayedCount & "|" & _
  170. $track.PlayedDate & "|" & _
  171. $track.Playlist & "|" & _
  172. $track.Rating & "|" & _
  173. $track.SampleRate & "|" & _
  174. $track.Size & "|" & _
  175. $track.Time & "|" & _
  176. $track.TrackNumber & "|" & _
  177. $track.VolumeAdjustment & "|" & _
  178. $track.Year
  179. _ArrayAdd($sInfo,$tInfo)
  180. Next
  181. Return $sInfo
  182. EndFunc ;==>_iTunes_Selected_GetInfo
  183. Func _iTunes_Song_GetInfo($song_Name)
  184. $song = $Library_Tracks.ItemByName($song_Name)
  185. if IsObj($song) then
  186. $tInfo = _ArrayCreate($song.Album)
  187. _ArrayAdd($tInfo, $song.artist)
  188. _ArrayAdd($tInfo, $song.BPM)
  189. _ArrayAdd($tInfo, $song.comment)
  190. _ArrayAdd($tInfo, $song.Compilation)
  191. _ArrayAdd($tInfo, $song.Composer)
  192. _ArrayAdd($tInfo, $song.DateAdded)
  193. _ArrayAdd($tInfo, $song.Duration)
  194. _ArrayAdd($tInfo, $song.EQ)
  195. _ArrayAdd($tInfo, $song.Genre)
  196. _ArrayAdd($tInfo, $song.KindAsString)
  197. _ArrayAdd($tInfo, $song.ModificationDate)
  198. _ArrayAdd($tInfo, $song.PlayedCount)
  199. _ArrayAdd($tInfo, $song.PlayedDate)
  200. _ArrayAdd($tInfo, $song.Playlist)
  201. _ArrayAdd($tInfo, $song.Rating)
  202. _ArrayAdd($tInfo, $song.SampleRate)
  203. _ArrayAdd($tInfo, $song.Size)
  204. _ArrayAdd($tInfo, $song.Time)
  205. _ArrayAdd($tInfo, $song.TrackNumber)
  206. _ArrayAdd($tInfo, $song.VolumeAdjustment)
  207. _ArrayAdd($tInfo, $song.Year)
  208. Return $tInfo
  209. Else
  210. Return 1
  211. EndIf
  212. EndFunc ;==>_iTunes_Song_GetInfo
  213. Func _iTunes_Current_GetInfo()
  214. $tInfo = _ArrayCreate($iTunesApp.CurrentTrack.Album)
  215. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.artist)
  216. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.name)
  217. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.comment)
  218. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Compilation)
  219. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Composer)
  220. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.DateAdded)
  221. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Duration)
  222. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.EQ)
  223. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Genre)
  224. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.KindAsString)
  225. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.ModificationDate)
  226. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.PlayedCount)
  227. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.PlayedDate)
  228. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Playlist)
  229. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Rating)
  230. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.SampleRate)
  231. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Size)
  232. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Time)
  233. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.TrackNumber)
  234. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.VolumeAdjustment)
  235. _ArrayAdd($tInfo, $iTunesApp.CurrentTrack.Year)
  236. Return $tInfo
  237. EndFunc ;==>_iTunes_Current_Get_Info
  238. Func _iTunes_Quit()
  239. $iTunesApp.Quit
  240. EndFunc ;==>_iTunes_Quit
  241. Func _iTunes_iPod_Update()
  242. $iTunesApp.iPodSource.UpdateIPod
  243. EndFunc ;==>_iTunes_iPod_Update
  244. Func _iTunes_iPod_Eject()
  245. $iTunesApp.iPodSource.EjectIPod
  246. EndFunc ;==>_iTunes_iPod_Eject
  247. Func _iTunes_iPod_Version()
  248. Return $iTunesApp.iPodSource.SoftwareVersion
  249. EndFunc ;==>_iTunes_iPod_Version
  250. Func _iTunes_Visuals_Enable()
  251. $iTunesApp.VisualsEnabled = 1
  252. EndFunc ;==>_iTUnes_Visuals_Enable
  253. Func _iTunes_Visuals_Disable()
  254. $iTunesApp.VisualsEnabled = 0
  255. EndFunc ;==>_iTunes_Visuals_Disable
  256. Func _iTunes_Get_ITL_Path()
  257. Return $iTunesApp.LibraryXMLPath
  258. EndFunc ;==>_iTunes_Get_ITL_Path
  259. Func _iTunes_Podcast_Subscribe($podcast_url)
  260. $iTunesApp.SubscribeToPodcast($podcast_url)
  261. EndFunc ;==>_iTunes_Podcast_Subscribe
  262. Func _iTunes_Podcast_UpdateFeeds()
  263. $iTunesApp.UpdatePodcastFeeds
  264. EndFunc ;==>_iTunes_Podcast_UpdateFeeds
  265. Func _iTunes_Player_Get_State()
  266. Return $iTunesApp.PlayerState
  267. EndFunc ;==>_iTunes_Player_Get_State
  268. Func _iTunes_MiniPlayer($state = 1)
  269. If $state = 1 Then
  270. $iTunesApp.BrowserWindow.MiniPlayer = 1
  271. Else
  272. $iTunesApp.BrowserWindow.MiniPlayer = 0
  273. EndIf
  274. Return $iTunesApp.BrowserWindow.MiniPlayer
  275. EndFunc ;==>_iTunes_MiniPlayer
  276. Func _iTunes_Unload()
  277. If IsObj($iTunesApp) Then _iTunes_Quit()
  278. $iTunesApp = ""
  279. EndFunc
  280. Func _iTunes_Mute()
  281. $iTunesApp.Mute = String(not $iTunesApp.Mute)
  282. EndFunc
  283. #cs USER CALLTIP ENRTRIES
  284. _iTunes_Start() Starts iTunes If not running and initializes the functions. Required #include <iTunes.au3>
  285. _iTunes_Vol_Up([$vol_percent = 10]) Volume Up. Required #include <iTunes.au3>
  286. _iTunes_Vol_Down([$vol_percent = 10]) Volume Down. Required #include <iTunes.au3>
  287. _iTunes_Prev() Previous Song. Required #include <iTunes.au3>
  288. _iTunes_Next() Next Song. Required #include <iTunes.au3>
  289. _iTunes_Current_LyricsSet($Lyric_text) Set Lyrics to Current Song. Required #include <iTunes.au3>
  290. _iTunes_Current_LyricsGet() Get Lyrics for Current Song. Required #include <iTunes.au3>
  291. _iTunes_Current_ArtworkSaveToTmp() Save Current Song's Artwork to .tmp file (returns the tmp name). Required #include <iTunes.au3>
  292. _iTunes_Current_Artwork_Get($path) Saves Current Song's Artwork to path. Required #include <iTunes.au3>
  293. _iTunes_Current_Artwork_Set($path) Set Current Song's Artwork form image. Required #include <iTunes.au3>
  294. _iTunes_Play_Pause() Play/Pause. Required #include <iTunes.au3>
  295. _iTunes_PlayList_Create($p_name) Create Playlist. Required #include <iTunes.au3>
  296. _iTunes_PlayList_Add($PlayList_Name, $song_Name) Add a Library Song to a Playlist. Required #include <iTunes.au3>
  297. _iTunes_Playlist_Delete($PlayList_Name) Delete Playlist. Required #include <iTunes.au3>
  298. _iTunes_Playlist_Info($PlayList_Name) Get Playlist's info. Required #include <iTunes.au3>
  299. _iTunes_Playlist_PlayFirst($PlayList_Name) Play First Song in Playlist. Required #include <iTunes.au3>
  300. _iTunes_Playlist_Search($PlayList_Name,$search) Search Song in Playlist. Required #include <iTunes.au3>
  301. _iTunes_Library_CountTracks() Count Library Tracks. Required #include <iTunes.au3>
  302. _iTunes_Library_AddTrack($path) Add file to library. Required #include <iTunes.au3>
  303. _iTunes_Library_Tracks() Get the Librarie's Track List. Required <iTunes.au3>
  304. _iTunes_Song_LyricsGet($song_Name) Get Song's Lyrics. Required #include <iTunes.au3>
  305. _iTunes_Song_LyricsSet($song_Name,$lyrics) Set Song's Lyrics. Required #include <iTunes.au3>
  306. _iTunes_Song_ArtworkSaveToTmp($song_Name) Save Song's Artwork to .tmp file. Required #include <iTunes.au3>
  307. _iTunes_Song_Artwork_Get($song_Name,$path) Save Song's Artwork to file. Required #include <iTunes.au3>
  308. _iTunes_Song_Artwork_Set($song_Name,$path) Set Song's Artwork form image. Required #include <iTunes.au3>
  309. _iTunes_Library_DeleteTrack($song_Name) Delete track. Required #include <iTunes.au3>
  310. _iTunes_Get_Vol() Get Volume Percentage. Required #include <iTunes.au3>
  311. _iTunes_Vol_Set($vol_percent) Set Volume Percentage. Required #include <iTunes.au3>
  312. _iTunes_Get_Selected() Get Selected Tracks. Required #include <iTunes.au3>
  313. _iTunes_Selected_GetInfo() Returns an array containing Selected Tracks info. Required #include <iTunes.au3>
  314. _iTunes_Song_GetInfo($song_Name) Returns an array containing Song's info. Required #include <iTunes.au3>
  315. _iTunes_Current_GetInfo() Returns an array containing Current Song's Info. Required #include <iTunes.au3>
  316. _iTunes_Quit() Quit iTunes. Required #include <iTunes.au3>
  317. _iTunes_iPod_Update() Update iPod. Required #include <iTunes.au3>
  318. _iTunes_iPod_Eject() Eject iPod. Required #include <iTunes.au3>
  319. _iTunes_iPod_Version() Get iPod Software Version. Required #include <iTunes.au3>
  320. _iTunes_Visuals_Enable() Enable Visuals. Required #include <iTunes.au3>
  321. _iTunes_Visuals_Disable() Disable Visuals. Required #include <iTunes.au3>
  322. _iTunes_Get_ITL_Path() Returns "library.itl" (XML file containing iTunes library info) path. Required #include <iTunes.au3>
  323. _iTunes_Podcast_Subscribe($podcast_url) Subscribe to podcast. Required #include <iTunes.au3>
  324. _iTunes_Podcast_UpdateFeeds() Update Podcast Feeds. Required #include <iTunes.au3>
  325. _iTunes_Player_Get_State() Get Player State. Required #include <iTunes.au3>
  326. _iTunes_MiniPlayer([$state = 1]) Set MiniPlayer state. Required #include <iTunes.au3>
  327. _iTunes_UnLoad() Unload iTunes COM Object. Required #include <iTunes.au3>
  328. _iTunes_Mute() Mute iTunes. Required #include <iTunes.au3>
  329. #ce

comments powered by Disqus