Changeset 489
- Timestamp:
- 02/14/09 11:05:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Update Podcasts/update_podcasts.py
r488 r489 3 3 4 4 from appscript import * 5 from aem import AEEnum 5 6 from itertools import izip 6 7 import htmlentitydefs 7 8 import re 9 import time 8 10 9 11 # based on <http://sebsauvage.net/python/snyppets/> … … 16 18 if entity in htmlentitydefs.name2codepoint: 17 19 return unichr(htmlentitydefs.name2codepoint[entity]) 18 return u' ' 20 return u' ' # Unknown entity: We replace with a space. 19 21 replaced = 0 20 22 s, n = RE_ENTITY_CHR.subn(entity2char, s) … … 49 51 return s 50 52 51 def podcasts_to_lyrics(): 52 iTunes = app('iTunes') 53 53 def podcasts_to_lyrics(iTunes): 54 54 podcasts = iTunes.tracks[its.podcast == True] 55 55 … … 75 75 iTunes.tracks[its.id == id_].lyrics.set(longdesc) 76 76 77 def iTunes_main_pane(): 78 return app(u'System Events').application_processes[u'iTunes'].windows[u'iTunes'].splitter_groups[1].scroll_areas[1] 77 79 80 def wait_for_podcast_update(iTunes): 81 # show 'Podcasts' 82 iTunes.playlists[its.special_kind == AEEnum('kSpP')].reveal() 83 podcast_status = iTunes_main_pane().outlines[1].rows.static_texts[1].value 84 while u'queued for download' in podcast_status.get(): 85 time.sleep(0.5) 86 87 def wait_for_iPod_update(iTunes): 88 # show iPod 89 iTunes.sources[its.kind == AEEnum('kPod')].sources[1].library_playlists[1].reveal() 90 sync_enabled = iTunes_main_pane().buttons[u'Sync'].enabled 91 while sync_enabled.get() == False: 92 time.sleep(0.5) 78 93 79 94 if __name__ == '__main__': 80 # sync_ipod()81 # - poll whether 'Sync' button is enabled82 # update_podcasts()83 # - poll '[queued for download]' on last podcast, then any remaining84 podcasts_to_lyrics()85 # sync_ipod()86 87 # write podcast entry replacing http://njr.sabi.net/2007/03/04/an-applescript-to-update-podcasts-and-your-ipod/ - now we can use accessibility 95 iTunes = app('iTunes') 96 iTunes.updateAllPodcasts() # start downloading 97 iTunes.update() # sync iPod 98 wait_for_iPod_update(iTunes) 99 iTunes.updateAllPodcasts() 100 wait_for_podcast_update(iTunes) 101 podcasts_to_lyrics(iTunes) 102 iTunes.update()
Note:
See TracChangeset
for help on using the changeset viewer.