Tested on Mac only.
play Game of Thrones S04E07
play Arrow S02E07
play Inception
| #!/usr/bin/env coffee | |
| # | |
| http = require('http') | |
| cheerio = require('cheerio') | |
| spawn = require('child_process').spawn | |
| searchTerm = process.argv[2..-1].join(' ') | |
| url = "http://thepiratebay.se/search/#{encodeURIComponent(searchTerm)}" | |
| req = http.get url, (res) -> | |
| res.setEncoding("utf8") | |
| content = "" | |
| res.on "data", (chunk) -> | |
| content += chunk | |
| res.on "end", -> | |
| $ = cheerio.load(content) | |
| magnetUri = $("table#searchResult a[href^=magnet]").first().attr("href") | |
| if magnetUri | |
| peerflix = spawn("peerflix", [magnetUri, "--vlc"], stdio: "inherit") | |
| else | |
| process.exit 1 | |
| req.end() |