Changeset 666 for trunk


Ignore:
Timestamp:
07/10/13 17:08:00 (11 years ago)
Author:
Nicholas Riley
Message:

StreamVision.py: Send all images to Growl as TIFF.

Previously we used whatever iTunes returned to us, which could be a
JPEG (no longer supported in current Growl versions), or a file path
(not supported with sandboxing).

http://growl.info/documentation/applescript-support.php
https://groups.google.com/forum/#!topic/growldiscuss/GbtPcpgSoNY

Thanks to Rudy Richter for the help.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r665 r666  
    22# -*- coding: utf-8 -*-
    33
     4from aem.ae import newdesc
    45from appscript import app, k, its, CommandError
    5 from AppKit import NSApplication, NSApplicationDefined, NSBeep, NSSystemDefined, NSURL, NSWorkspace
    6 from Foundation import NSDistributedNotificationCenter, NSSearchPathForDirectoriesInDomains, NSCachesDirectory, NSUserDomainMask
     6from AppKit import (NSApplication, NSApplicationDefined, NSBeep, NSImage,
     7                    NSSystemDefined, NSURL, NSWorkspace)
     8from Foundation import (NSDistributedNotificationCenter,
     9                        NSSearchPathForDirectoriesInDomains,
     10                        NSCachesDirectory, NSUserDomainMask)
    711from PyObjCTools import AppHelper
    812from Carbon.CarbonEvt import RegisterEventHotKey, GetApplicationEventTarget
    913from Carbon.Events import cmdKey, shiftKey, controlKey
    10 from AudioDevice import default_output_device_is_airplay, set_default_output_device_changed_callback
     14from AudioDevice import (default_output_device_is_airplay,
     15                         set_default_output_device_changed_callback)
    1116import httplib2
    1217import os
     
    4146        if usingStereo:
    4247            description += '\n(AirPlay)'
     48
     49        if 'image' in kw:
     50            image = (NSImage.alloc().initWithData_(buffer(kw['image']))
     51                     .TIFFRepresentation())
     52            kw['image'] = newdesc('TIFF', image)
    4353
    4454        growl.notify(
     
    212222                else:
    213223                    if response['content-type'].startswith('image/'):
    214                         file(self.imagePath, 'w').write(content)
    215                         kw['image_from_location'] = self.imagePath
     224                        kw['image'] = content
    216225            growlNotify(cleanStreamTitle(iTunes.current_stream_title()),
    217226                        cleanStreamTrackName(trackName), **kw)
     
    226235            if artwork:
    227236                try:
    228                     kw['pictImage'] = artwork[0].data_()
     237                    kw['image'] = artwork[0].data_().data
    229238                except CommandError:
    230239                    pass
Note: See TracChangeset for help on using the changeset viewer.