Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- Scripting by Applehelpwriter 2013
- http://applehelpwriter.com
- ******How to use:
- Compile in AS Editor, save as an .app
- *****What it does:
- Lets you watch a series in order without you having to remember which episode you watched last.
- Set up the Preferences and it will automatically pick the next unwatched episode when you run it.
- Can keep track of multiple different series at the same time. Use the 'Watch' folder to choose which series you want at any given time. You can change the 'Watch' folder back to any previously watched series and it will know where you left off (so long as you started watching the series through Episodes.app - if you want it to pick up a series you've already started watching before using Episodes, go into Finder and change the colour label to 'grey' for each movie file that you've already seen; the app will take care of everything after that).
- ****NOTE
- Should only be used with VLC Player - some bugs in QT due to missing codecs in that app
- ***Known issues:
- Some minor bugs still need ironing out; non known as critical to date
- **Development:
- I'm working on a Cocoa version with a prettier interface, so I probably won't do much else with this one. Feel free to adapt it to your own purposes.
- Phil :)
- http://applehelpwriter.com
- *)
- property myName : "episodes"
- property theFolder : "Nothing!"
- property theApp : "unset.app"
- property theMovie : "unset"
- property theSeries : ""
- property thePlayer : "no player"
- property movieList : {}
- property myPath : ""
- property myList : {}
- property seriesValue : 0
- try
- display dialog "What would you like to do?" with title (myName & ".app") buttons {"Cancel", "Preferences", ("Watch " & theSeries)} default button ("Watch " & theSeries) with icon 1
- set dialogResult to the button returned of the result
- if dialogResult = ("Watch " & theSeries) then
- watchIt()
- else
- if dialogResult = "Preferences" then
- setUp()
- watchIt()
- end if
- end if
- on error number -1728
- error number -128
- end try
- on watchIt()
- try
- checkFolder()
- checkSeries()
- checkPlayer()
- checkMovie()
- try
- tell application id thePlayer
- activate
- open myPath
- end tell
- end try
- return
- on error number -1728
- error number -128
- end try
- end watchIt
- on checkFolder()
- try
- if theFolder = "Nothing!" then
- beep
- display dialog "You haven't set a folder to watch yet!" with title (myName & ".app") buttons {"Cancel", "Preferences"} default button "Preferences" with icon 1
- set dialogResult to the button returned of the result
- if dialogResult = "Preferences" then
- setUp()
- end if
- else
- return
- end if
- on error number -1728
- error number -128
- end try
- end checkFolder
- on checkSeries()
- try
- if seriesValue = 0 then
- try
- display dialog "Currently watching: " & return & return & theFolder & return & return & "Enter a short name for the series:" default answer theSeries buttons {"Cancel", "OK"} default button "OK" with title (myName & ".app") with icon 1
- on error number -128
- setUp()
- end try
- set theSeries to text returned of the result as string
- set the seriesValue to 1
- end if
- on error number -1728
- error number -128
- end try
- end checkSeries
- on checkPlayer()
- try
- if thePlayer = "no player" then
- setPlayer()
- else
- display dialog ("Ready to watch " & theSeries & "?") default button "OK" with icon 1
- end if
- on error number -1728
- error number -128
- end try
- end checkPlayer
- on checkMovie()
- try
- tell application "Finder"
- try
- set myList to the name of every document file of the theFolder whose label index is 0
- on error --error 1
- (* this whole error block needs fixing before release*)
- set seriesValue to 0
- display dialog "No unwatched movies here" buttons {"Cancel", "Preferences"} default button "Preferences" with icon 0
- set theNextAction to the button returned of the result
- if theNextAction is "Preferences" then
- set theFolder to choose folder with prompt "Choose the folder to watch:"
- try
- set myList to the name of every document file of the theFolder whose label index is 0
- on error --error 2
- display dialog "Still no unwatched movies here!" buttons {"Cancel", "Preferences"} default button "Preferences" with icon 0
- set theNextAction to the button returned of the result
- if theNextAction is "Preferences" then
- set theFolder to choose folder with prompt "Choose the folder to watch:"
- try
- set myList to the name of every document file of the theFolder whose label index is 0
- on error --error 3
- display dialog myName & ".app can't find any movies to play" & return & return & "Quitting — please restart " & myName & " to try again." with icon 0
- end try
- end if
- end try
- end if
- end try
- set theMovie to item 1 of myList as string
- set myPath to (theFolder & theMovie) as string
- set the label index of the document file theMovie of theFolder to 7
- end tell
- on error number -1728
- error number -128
- end try
- end checkMovie
- on setUp()
- try
- set optionsList to {"About", "Defaults", "Show settings", "Set Player", "Set Series Name", "Set Watch folder"}
- repeat
- choose from list optionsList with prompt "Choose an item:" with title (myName & ".app") default items "Set Watch Folder"
- set dialogResult to (item 1 of the result)
- if dialogResult = "Set Watch folder" then
- setFolder()
- exit repeat
- else if dialogResult = "Set Player" then
- setPlayer()
- exit repeat
- else if dialogResult = "Set Series Name" then
- set seriesValue to 0
- checkSeries()
- exit repeat
- else if dialogResult = "About" then
- display dialog ("Sorry, this feature hasn't been implemented yet!") buttons {"OK"} default button 1 with title (myName & ".app") with icon 1
- setUp()
- exit repeat
- else if dialogResult = "Show settings" then
- showSettings()
- exit repeat
- else if dialogResult = "Defaults" then
- try
- display dialog "Return " & myName & ".app to default settings?" buttons {"No", "Yes"} cancel button "No" default button "No" with title (myName & ".app") with icon 2
- on error number -128
- setUp()
- exit repeat
- end try
- doReset()
- setUp()
- exit repeat
- end if
- end repeat
- on error number -1728
- error number -128
- end try
- end setUp
- on showSettings()
- display dialog ("The current series is " & theSeries & return & "The current player is " & thePlayer & return & "The current folder being watched is " & theFolder & return) buttons {"OK"} default button 1 with title (myName & ".app") with icon 1
- setUp()
- end showSettings
- on doReset()
- set the theFolder to "Nothing!"
- set theApp to "unset.app"
- set theMovie to "unset"
- set theSeries to ""
- set thePlayer to "no player"
- set the movieList to {}
- set myPath to ""
- set myList to {}
- set seriesValue to 0
- display dialog myName & ".app has been reset to default settings." & return & return & "Finder labels have not been reset. This must be done manually in Finder." with title (myName & ".app") with icon 1
- return
- end doReset
- on setFolder()
- try
- set theFolder to choose folder with prompt "Choose the folder to watch:" default location path to "cusr" from the user domain
- on error number -128
- setUp()
- end try
- end setFolder
- on setPlayer()
- try
- try
- set theApp to (choose file with prompt ("Pick the MEDIA PLAYER to use with this folder. Note this does not change your default system media player") of type {"app"} default location path to "apps" from local domain) as text
- on error number -128
- setUp()
- end try
- set thePlayer to the id of application theApp
- if thePlayer = "com.apple.QuickTimePlayerX" then
- display dialog "QuickTime may not be able to play some movie files!" & return & return & myName & " works best with the open source VLC Player instead." with title (myName & ".app") buttons {"Cancel", "Use QT anyway", "Preferences"} default button "Preferences" with icon 2
- set nextAction to the button returned of the result
- if nextAction = "Use QT anyway" then
- return
- else if nextAction = "Preferences" then
- setPlayer()
- end if
- end if
- return
- on error number -1728
- error number -128
- end try
- end setPlayer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement