Forked from anonymous/copy_cp_wanted_list_to_watcher.rb
Created
February 7, 2017 09:59
-
-
Save rantanlan/080f8139d8aff5eee5ee4c523d039a90 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ 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