scripting-bridge

Python printing attributes with no __dict__

六月ゝ 毕业季﹏ 提交于 2019-12-10 01:56:46
问题 I am having trouble with scripting bridge for python I am trying to list the attributes of the iTunes object iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") using >>> from pprint import pprint >>> from Foundation import * >>> from ScriptingBridge import * >>> iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") >>> pprint (vars(iTunes)) I get back Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: vars()

Add movie to iTunes using Scripting Bridge

有些话、适合烂在心里 提交于 2019-12-09 05:59:45
问题 I want to use Scripting Bridge to add a movie to iTunes. And preferably letting me choose between a 'music video' and a 'movie'. I know both Objective-C and AppleScript so I thought it wouldn't be that hard but I can't figure it out. I know how I would use NSAppleScript for it but I'm targeting 10.5 or later and read that Scripting Bridge obsoletes NSAppleScript. Is that right? All I got is iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier: @"com.apple.iTunes"]; Which

How to add a track to an iTunes playlist using Python and Scripting Bridge

女生的网名这么多〃 提交于 2019-12-07 05:59:32
问题 I learned how to create a playlist in a previous question, but now I can't figure out how to add tracks to it. Right now I have: tracks.sort(key=lambda tup: tup[0]) i = 0 for trackList in generatePlaylists(tracks,10): i += 1 playlistname = str(i) p = {'name': playlistname} playlist = iTunes.classForScriptingClass_("playlist").alloc().initWithProperties_(p) iTunes.sources()[0].playlists().insertObject_atIndex_(playlist, 0) # Find the playlist I just made for playlist in iTunes.sources()[0]

Reading currently playing track in macOS using ScriptingBridge not working

亡梦爱人 提交于 2019-12-06 10:53:25
问题 I am trying to read the currently playing track of iTunes using ScriptingBridge. I found a couple of other threads here but no one seems to be working for me (macOS Mojave and iTunes 12.9.4). I have created the iTunes.h file using the following command: sdef /Applications/iTunes.app | sdp -fh --basename "iTunes" I am creating an instance of the Scripting Bridge as follows: if let itunes: AnyObject = SBApplication(bundleIdentifier: "com.apple.iTunes") { if itunes.isRunning { Swift.print(

Python printing attributes with no __dict__

浪尽此生 提交于 2019-12-05 03:59:51
I am having trouble with scripting bridge for python I am trying to list the attributes of the iTunes object iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") using >>> from pprint import pprint >>> from Foundation import * >>> from ScriptingBridge import * >>> iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") >>> pprint (vars(iTunes)) I get back Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: vars() argument must have __dict__ attribute anyone know how to get around this? Try dir(iTunes) . It's similar to

Finder Scripting Bridge to Shutdown

扶醉桌前 提交于 2019-12-04 20:47:40
I tried to use Application Scripting Bridge to send my Mac to sleep. The code look like the following: #import "Finder.h" FinderApplication *Finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"]; [Finder sleep]; But it doesn't work. Any ideas why it doesn't work? No compiling errors or warnings, but it doesn't work… NSGod As I posted in this answer , I've been using the following code for over 8 years without issues: MDRestartShutdownLogout.h: #import <CoreServices/CoreServices.h> /* * kAERestart will cause system to restart * kAEShutDown will cause system to shutdown *

Reading currently playing track in macOS using ScriptingBridge not working

。_饼干妹妹 提交于 2019-12-04 19:14:33
I am trying to read the currently playing track of iTunes using ScriptingBridge. I found a couple of other threads here but no one seems to be working for me (macOS Mojave and iTunes 12.9.4). I have created the iTunes.h file using the following command: sdef /Applications/iTunes.app | sdp -fh --basename "iTunes" I am creating an instance of the Scripting Bridge as follows: if let itunes: AnyObject = SBApplication(bundleIdentifier: "com.apple.iTunes") { if itunes.isRunning { Swift.print("iTunes is running...") } Swift.print(itunes.currentTrack?.name) Swift.print(itunes.currentTrack?.album) }

Creating playlists in iTunes using Scripting Bridge in a Sandboxed app

霸气de小男生 提交于 2019-12-04 17:10:40
Is this possible? In this question I saw that you add to the entitlements file: <key>com.apple.security.scripting-targets</key> <dict> <key>com.apple.iTunes</key> <array> <string>com.apple.iTunes.library.read</string> <string>com.apple.iTunes.playback</string> </array> </dict> for read access. But how do you get write access? I looked in the documentation and they suggest the manual for sdef , but I couldn't extract any information from this. Also, would this hamper a submission to the App Store? Alex Alright, from what I know (and from what logic tells me) adding entitlements which are not

How to import an mp3 song into iTunes using Objective-C?

给你一囗甜甜゛ 提交于 2019-12-04 14:38:39
I am building a Mac OS Application which needs to import an mp3 file into iTunes... Can't seem to find any framework that would help me achieve this. The only way I can think of doing this is modifying the "iTunes Music Library.xml". I'm hoping one of you can point me to a better and cleaner solution. Thank you in advance. Ok, so after some research on Scripting Bridge, just like Andrew Madsen suggested. Here is the answer to my own question. This has been implemented and tested... Add the ScriptingBridge Framework to your Mac OS Project. Generate the iTunes.h file by writing the following in

Get iTunes Artwork for Current Song with ScriptingBridge

六眼飞鱼酱① 提交于 2019-12-03 13:47:32
I have been trying to figure out how to get the iTunes artwork for the currently playing song with scripting bridge. I have gotten to a point where it works for some songs, but for others, I get a SIGABRT. I'm not sure what the issue could be, so any help would be greatly appreciated. Here is what I have so far: iTunesApplication * iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSImage *songArtwork; iTunesTrack *current = [iTunes currentTrack]; iTunesArtwork *artwork = (iTunesArtwork *)[[[current artworks] get] lastObject]; if(artwork != nil) songArtwork =