Skip to content

Instantly share code, notes, and snippets.

@farfanoide
Last active October 25, 2015 03:36
Show Gist options
  • Save farfanoide/3fe37cb5fede2e2d3eb9 to your computer and use it in GitHub Desktop.
Save farfanoide/3fe37cb5fede2e2d3eb9 to your computer and use it in GitHub Desktop.
get latets yts.re movies and optionally download one or more
#!/usr/bin/env ruby
# encoding: utf-8
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Script to show last 20 torrents uploaded to yts.to and
# optionally download some of them
#
# ------------------------------------------------------------------------------
# Author
# -------
#
# * Farfanoide (https://github.com/farfanoide)
#
# ------------------------------------------------------------------------------
require 'net/http'
require 'json'
movies = JSON.parse(Net::HTTP.get(URI('http://yts.to/api/list.json?sort=date&order=desc')))['MovieList']
movies.each_with_index { |movie, index| puts "[#{index}] #{movie['MovieTitle']} -- (#{movie['Quality']}) -- (#{movie['Size']}) -- (★ #{movie['MovieRating']})" }
puts ''
puts 'To select a movie to download, just enter the movie\'s index'
puts 'if you want to select various torrents, enter them separated with a whitespace'
puts ''
if indexes = gets
indexes = indexes.split(' ').map {|index| index.to_i}
indexes.each do |index|
movie = movies[index]
`curl --progress -S #{movie['TorrentUrl']} -o "$HOME/Downloads/#{movie['MovieTitle']}.torrent"`
end
end
@jonlunsford
Copy link

Vey cool. I've also created a gem for the V2 API. Though YTS is down right now :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment