Guest User

Untitled

a guest
Feb 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. set seasonNumPattern to "\\d\\d"
  2. set episodeNumPattern to "\\d\\d"
  3.  
  4. tell application "iTunes"
  5. repeat with I from 1 to count tracks of user playlist "show"
  6.  
  7. set track_ to track I of user playlist "show"
  8. set name_ to name of track_
  9. set seasonNum to (find text "(?<=S)(" & seasonNumPattern & ")" in name_ with regexp and string result) as integer
  10. set episodeNum to (find text "(?<=E)(" & episodeNumPattern & ")" in name_ with regexp and string result) as integer
  11. 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
  12. 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
  13.  
  14. set video kind of aTrack to TV show
  15. set show of aTrack to showName
  16. set season number of aTrack to seasonNum
  17. set episode number of aTrack to episodeNum
  18. set episode ID of aTrack to episodeId
  19.  
  20. end repeat
  21. end tell
Add Comment
Please, Sign In to add comment