Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set seasonNumPattern to "\\d\\d"
- set episodeNumPattern to "\\d\\d"
- tell application "iTunes"
- repeat with I from 1 to count tracks of user playlist "show"
- set track_ to track I of user playlist "show"
- set name_ to name of track_
- set seasonNum to (find text "(?<=S)(" & seasonNumPattern & ")" in name_ with regexp and string result) as integer
- set episodeNum to (find text "(?<=E)(" & episodeNumPattern & ")" in name_ with regexp and string result) as integer
- set showName to change "[[:space:]]+" into " " in (change "[[:punct:]]" into " " in (find text "^(.*)(?=S" & seasonNumPattern & ")" in name_ with regexp and string result) with regexp) with regexp
- set episodeId to change "^[[:space:]]" into "" in (change "[[:space:]]+" into " " in (change "[[:punct:]]" into " " in (find text "(?<=E" & episodeNumPattern & ")(.*)" in name_ with regexp and string result) with regexp) with regexp) with regexp
- set video kind of aTrack to TV show
- set show of aTrack to showName
- set season number of aTrack to seasonNum
- set episode number of aTrack to episodeNum
- set episode ID of aTrack to episodeId
- end repeat
- end tell
Add Comment
Please, Sign In to add comment