Skip to content

Instantly share code, notes, and snippets.

Created January 9, 2017 04:01
Show Gist options
  • Save anonymous/5ce4df44efa338bb305cd3336e5ab7a7 to your computer and use it in GitHub Desktop.
Save anonymous/5ce4df44efa338bb305cd3336e5ab7a7 to your computer and use it in GitHub Desktop.
def get_wantedlist_from_couch(couchurl)
api_call = "movie.list/?status=active"
couchurl = couchurl + api_call
puts "talking to couch using this call: " + couchurl.to_s
urlresponse = RestClient.get(couchurl)
puts "couch reponse code: " + urlresponse.code.to_s
wanted_response = Hashie::Mash.new (JSON.parse(urlresponse.body))
return wanted_response
end
def add_movietowatcherbyimdb(url_watcher)
#https://github.com/nosmokingbandit/watcher/wiki/API
urlresponse = RestClient.get(url_watcher)
puts "couch reponse code: " + urlresponse.code.to_s
end
require 'optparse'
require 'rest-client'
require 'json'
require 'rubygems'
require 'hashie'
# default options
server = '<watcher server name or ip here>'
port = "9090" #change this if watcher is on a different port
actionmode = "addmovie" #do not change this unless changing functionality
protocol = "http" #do not know if this works with https
apikey = "<INSERT watcher api key here>"
couch_api_key = "<INSERT couch potato api key here>"
couchport - "5050" #change if couchpotato is running on different port
restURI = protocol + ":" + "//" + server + ":" + port + "/api" + "?apikey=" + apikey + "&mode=" + actionmode
couchserver = server #assume on same box as watcher , change if not true
couch_uri = "http://" + couchserver + ":" + couchport + "/api/" + couch_api_key + "/"
puts "talking uri: " + couch_uri
(get_wantedlist_from_couch(couch_uri)).movies.each do |couchitem|
this_imdbID = couchitem.identifiers.imdb
this_title = couchitem.title
puts "movie: " + this_title + " imdbID: " + this_imdbID
add_movietowatcherbyimdb((restURI + "&imdbid=" + this_imdbID))
#end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment