Alejandro Martinez

BlogPodcastPortfolioย Youtube

28 March, 2015Development๐Ÿ• 1min read

Swift script to download Youtube videos from Safari Reading List

When I wrote my srly script I thought on doing it in Swift, but at the end I decided to go with a well known scripting language, Ruby.

After Ayakaโ€™s talk in the Swift Summit I was really excited about writing some script in Swift, and I ported the original srly.rb script to Swift.

When porting the code to Swift I wanted to use the native Cocoa APIs to modify the original PLIST so the script could remove the links successfully downloaded. I was struggling a little at the begging because I wanted to write swifty code, but the fact that Swift arrays and dictionaries are structs was preventing me to accomplish that simple thing. At the end Iโ€™m using the Foundation NSArray and NSDictionary because of its reference semantics that allow me to mutate the dictionary and save it to disk.

I have to say that Iโ€™m really happy with the result and really excited to continue writing scripts in Swift. Having the convenience of the language and the power of Cocoa to write scripts itโ€™s very cool. I hope that the rest of the community realizes that and that the creation of little gems for swift scripting starts to grow quickly.

srly.swift on GitHub

๐Ÿ‘‰๐Ÿป If you have any feedback you can reach me at alexito4

ScrumVotesThe exploration phase

Alejandro Martinez
alexito4@gmail.com

Buka pintu

alexito4
alexito4