Created
May 16, 2011 11:16
-
-
Save co3k/974257 to your computer and use it in GitHub Desktop.
iTunes で再生中のプレイリストのなかで「レートの低い」「あまり再生していない」曲を重点的に再生しまくるプレイリストを作成する Python スクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ScriptingBridge import * | |
iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes") | |
heavy_playlist = None | |
for playlist in iTunes.sources()[0].playlists().get(): | |
if "HEAVY" == playlist.name(): | |
playlist.delete() | |
break | |
heavy_playlist = iTunes.classForScriptingClass_("playlist").alloc().initWithProperties_({ | |
"name" : "HEAVY", | |
"shuffle" : True, | |
"songRepeat" : "kAll", | |
}) | |
iTunes.sources()[0].playlists().insertObject_atIndex_(heavy_playlist, 0) | |
playlist = iTunes.currentPlaylist() | |
for item in playlist.tracks(): | |
if (0 == item.rating()): | |
count = 1 | |
else: | |
count = ((100 - item.rating()) / item.playedCount() + 1) | |
for i in range(count): | |
item.duplicateTo_(heavy_playlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
うわ 25 行目モロゼロ除算じゃん