Skip to content

Instantly share code, notes, and snippets.

@vtajzich
Last active August 29, 2015 14:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vtajzich/a38fe74230b12cd366b0 to your computer and use it in GitHub Desktop.
Save vtajzich/a38fe74230b12cd366b0 to your computer and use it in GitHub Desktop.
How to download a movies form regiojet train server :-)
class Movie {
String name
URL url
}
def downloads = new File('downloads')
downloads.mkdirs()
"http://portal.regiojet.cz/files/movies/".toURL().text.findAll(~/(?<=href=")([\S^"]*)(?=")/)
.parallelStream()
.filter({ it.contains('.mp4') || it.contains('.m4v') })
.map({ new Movie(name: it, url: "http://portal.regiojet.cz/files/movies/$it".toURL()) })
.peek({ println "Downloading: " + it.name})
.forEach({ new File(downloads, it.name) << it.url.openStream() })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment